summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2020-11-15 10:43:31 +0200
committerSergey Poznyakoff <gray@gnu.org>2020-11-15 10:43:31 +0200
commit9bfb66497ca7245a07c4168d023824ee2a2622c7 (patch)
treed56e257e990101bf1628779de40e646593e1bf1b
parentc07ccac7e95dc17f061f02ad0cff7ecf027cbd49 (diff)
downloadmailutils-9bfb66497ca7245a07c4168d023824ee2a2622c7.tar.gz
mailutils-9bfb66497ca7245a07c4168d023824ee2a2622c7.tar.bz2
Improve mbop interface
* testsuite/mbop.c: Use mu_cli_simple for option handling. Use the -m option to pass the mailbox file name (or URL). Mark qget as not requiring message selection.
-rw-r--r--libmailutils/tests/Makefile.am2
-rw-r--r--libproto/maildir/tests/append.at4
-rw-r--r--libproto/maildir/tests/attfixup.at8
-rw-r--r--libproto/maildir/tests/attr.at9
-rw-r--r--libproto/maildir/tests/body.at5
-rw-r--r--libproto/maildir/tests/count.at6
-rw-r--r--libproto/maildir/tests/delete.at2
-rw-r--r--libproto/maildir/tests/envelope.at6
-rw-r--r--libproto/maildir/tests/header.at4
-rw-r--r--libproto/maildir/tests/qget.at7
-rw-r--r--libproto/maildir/tests/uid.at4
-rw-r--r--libproto/maildir/tests/uidfixup.at7
-rw-r--r--libproto/maildir/tests/uidvalidity.at4
-rw-r--r--testsuite/mbop.c42
14 files changed, 58 insertions, 52 deletions
diff --git a/libmailutils/tests/Makefile.am b/libmailutils/tests/Makefile.am
index da5092fb2..19aa995e6 100644
--- a/libmailutils/tests/Makefile.am
+++ b/libmailutils/tests/Makefile.am
@@ -208,5 +208,5 @@ $(srcdir)/wordsplit-version.h: $(top_srcdir)/configure.ac
noinst_PROGRAMS += wsp
nodist_wsp_SOURCES = wsp.c
wsp.o: $(srcdir)/wordsplit-version.h
-VPATH = $(srcdir):$(top_srcdir)/libmailutils/wordsplit
+VPATH += $(top_srcdir)/libmailutils/wordsplit
diff --git a/libproto/maildir/tests/append.at b/libproto/maildir/tests/append.at
index 301622c8d..b9082c93d 100644
--- a/libproto/maildir/tests/append.at
+++ b/libproto/maildir/tests/append.at
@@ -40,7 +40,7 @@ headers
body_text
])
AT_CHECK([
-mbop inbox < commands
+mbop -m inbox < commands
],
[0],
[append: OK
@@ -63,7 +63,7 @@ X-Envelope-Sender:alice@wonder.land
])
AT_CHECK([
-mbop inbox uidvalidity
+mbop -m inbox uidvalidity
],
[0],
[uidvalidity: 10
diff --git a/libproto/maildir/tests/attfixup.at b/libproto/maildir/tests/attfixup.at
index 24fdb712b..e532be0a0 100644
--- a/libproto/maildir/tests/attfixup.at
+++ b/libproto/maildir/tests/attfixup.at
@@ -8,13 +8,13 @@ cur/1284628225.M21284P3883Q3.Trurl:2,S
cur/1284628225.M22502P3883Q4.Trurl:2,S
])
+AT_CHECK([mbox2dir -i names inbox $spooldir/mbox1])
+
AT_CHECK([
-set -e
-mbox2dir -i names inbox $spooldir/mbox1
AT_DATA([inbox/.mu-prop],
[uid-validity: 10
])
-mbop inbox count
+mbop -m inbox count
find inbox/cur -type f | sort
cp inbox/.mu-prop saved_mu_prop
],
@@ -29,7 +29,7 @@ inbox/cur/1284628225.M22502P3883Q4.Trurl,u=5:2,
AT_CHECK([
set -e
-mbop inbox count
+mbop -m inbox count
find inbox/cur -type f | sort
],
[0],
diff --git a/libproto/maildir/tests/attr.at b/libproto/maildir/tests/attr.at
index 0deca3dad..56825930b 100644
--- a/libproto/maildir/tests/attr.at
+++ b/libproto/maildir/tests/attr.at
@@ -22,9 +22,10 @@ cur/1284628225.M20118P3883Q2.Trurl,u=22:2,
cur/1284628225.M21284P3883Q3.Trurl,u=43:2,
cur/1284628225.M22502P3883Q4.Trurl,u=50:2,
])
+AT_CHECK([mbox2dir -i names -p -v 10 inbox $spooldir/mbox1])
+
AT_CHECK([
-mbox2dir -i names -p -v 10 inbox $spooldir/mbox1
-mbop inbox 1 \; attr \; 2 \; attr
+mbop -m inbox 1 \; attr \; 2 \; attr
],
[0],
[1 current message
@@ -47,7 +48,7 @@ set_answered
# Synchronize with the disk storage
sync
])
-mbop inbox < commands
+mbop -m inbox < commands
],
[0],
[3 current message
@@ -58,7 +59,7 @@ mbop inbox < commands
sync: OK
])
AT_CHECK([
-mbop inbox 3 \; attr \; 5 \; attr
+mbop -m inbox 3 \; attr \; 5 \; attr
],
[0],
[3 current message
diff --git a/libproto/maildir/tests/body.at b/libproto/maildir/tests/body.at
index a3bf9a011..8246eb471 100644
--- a/libproto/maildir/tests/body.at
+++ b/libproto/maildir/tests/body.at
@@ -25,9 +25,10 @@ body_lines
body_size
body_text
])
+AT_CHECK([mbox2dir -p -v 10 inbox $spooldir/mbox1])
+
AT_CHECK([
-mbox2dir -p -v 10 inbox $spooldir/mbox1
-mbop inbox < commands
+mbop -m inbox < commands
],
[0],
[1 current message
diff --git a/libproto/maildir/tests/count.at b/libproto/maildir/tests/count.at
index 69fa32ba2..eed6e1443 100644
--- a/libproto/maildir/tests/count.at
+++ b/libproto/maildir/tests/count.at
@@ -15,10 +15,10 @@
# along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
AT_SETUP([message count])
+AT_CHECK([mbox2dir inbox $spooldir/mbox1])
+
AT_CHECK([
-set -e
-mbox2dir inbox $spooldir/mbox1
-mbop inbox count
+mbop -m inbox count
],
[0],
[count: 5
diff --git a/libproto/maildir/tests/delete.at b/libproto/maildir/tests/delete.at
index 09c8ce163..bc92af5af 100644
--- a/libproto/maildir/tests/delete.at
+++ b/libproto/maildir/tests/delete.at
@@ -26,7 +26,7 @@ uid
headers
])
AT_CHECK([
-mbop inbox < commands
+mbop -m inbox < commands
],
[0],
[3 current message
diff --git a/libproto/maildir/tests/envelope.at b/libproto/maildir/tests/envelope.at
index d9763da7b..12c6ce7f9 100644
--- a/libproto/maildir/tests/envelope.at
+++ b/libproto/maildir/tests/envelope.at
@@ -22,10 +22,8 @@ cur/1284628225.M20118P3883Q2.Trurl,u=22:2,
cur/1284628225.M21284P3883Q3.Trurl,u=43:2,
cur/1284628225.M22502P3883Q4.Trurl,u=50:2,
])
-AT_CHECK([
-mbox2dir -i names -p -v 10 inbox $spooldir/mbox1
-mbop inbox 2 \; env_date \; env_sender
-],
+AT_CHECK([mbox2dir -i names -p -v 10 inbox $spooldir/mbox1])
+AT_CHECK([mbop -m inbox 2 \; env_date \; env_sender],
[0],
[2 current message
2 env_date: Fri Dec 28 20:18:08 2001
diff --git a/libproto/maildir/tests/header.at b/libproto/maildir/tests/header.at
index c26f3ad55..98b3be36a 100644
--- a/libproto/maildir/tests/header.at
+++ b/libproto/maildir/tests/header.at
@@ -34,9 +34,9 @@ header_size
header_count
headers
])
+AT_CHECK([mbox2dir -i names -p -v 10 inbox $spooldir/mbox1])
AT_CHECK([
-mbox2dir -i names -p -v 10 inbox $spooldir/mbox1
-mbop inbox < commands
+mbop -m inbox < commands
],
[0],
[1 current message
diff --git a/libproto/maildir/tests/qget.at b/libproto/maildir/tests/qget.at
index 7b2b7ba41..d7082f3ac 100644
--- a/libproto/maildir/tests/qget.at
+++ b/libproto/maildir/tests/qget.at
@@ -22,12 +22,12 @@ cur/1284628225.M20118P3883Q2.Trurl,u=3:2,
cur/1284628225.M21284P3883Q3.Trurl,u=4:2,
cur/1284628225.M22502P3883Q4.Trurl,u=5:2,
])
+AT_CHECK([mbox2dir -i names -p -v 10 inbox $spooldir/mbox1])
AT_CHECK([
-mbox2dir -i names -p -v 10 inbox $spooldir/mbox1
-mbop inbox qget cur/1284628225.M19181P3883Q1.Trurl,u=2:2,S
+mbop -m inbox qget cur/1284628225.M19181P3883Q1.Trurl,u=2:2,S
],
[0],
-[Received: (from bar@dontmailme.org)
+[qget: Received: (from bar@dontmailme.org)
by dontmailme.org id fERKR9N16790
for foobar@nonexistent.net; Fri, 28 Dec 2001 22:18:08 +0200
Date: Fri, 28 Dec 2001 23:28:08 +0200
@@ -40,6 +40,7 @@ It seems very pretty, but it's *rather* hard to understand!'
Somehow it seems to fill my head with ideas -- only I don't
exactly know what they are! However, SOMEBODY killed SOMETHING:
that's clear, at any rate...
+
])
AT_CLEANUP
diff --git a/libproto/maildir/tests/uid.at b/libproto/maildir/tests/uid.at
index 635b2390f..bab62e82d 100644
--- a/libproto/maildir/tests/uid.at
+++ b/libproto/maildir/tests/uid.at
@@ -22,9 +22,9 @@ cur/1284628225.M20118P3883Q2.Trurl,u=22:2,
cur/1284628225.M21284P3883Q3.Trurl,u=43:2,
cur/1284628225.M22502P3883Q4.Trurl,u=50:2,
])
+AT_CHECK([mbox2dir -i names -p -v 10 inbox $spooldir/mbox1])
AT_CHECK([
-mbox2dir -i names -p -v 10 inbox $spooldir/mbox1
-mbop inbox 1 \; uid \; 2 \; uid \; 3 \; uid \; 4 \; uid \; 5 \; uid
+mbop -m inbox 1 \; uid \; 2 \; uid \; 3 \; uid \; 4 \; uid \; 5 \; uid
],
[0],
[1 current message
diff --git a/libproto/maildir/tests/uidfixup.at b/libproto/maildir/tests/uidfixup.at
index b3762e38d..f03f94226 100644
--- a/libproto/maildir/tests/uidfixup.at
+++ b/libproto/maildir/tests/uidfixup.at
@@ -7,11 +7,10 @@ cur/1284628225.M21284P3883Q3.Trurl:2,
cur/1284628225.M22502P3883Q4.Trurl:2,
])
-AT_CHECK([
-set -e
-mbox2dir -i names -p -v 10 inbox $spooldir/mbox1
+AT_CHECK([mbox2dir -i names -p -v 10 inbox $spooldir/mbox1])
-mbop inbox count
+AT_CHECK([
+mbop -m inbox count
find inbox/cur -type f | sort
diff --git a/libproto/maildir/tests/uidvalidity.at b/libproto/maildir/tests/uidvalidity.at
index 791d0988b..806ceb85a 100644
--- a/libproto/maildir/tests/uidvalidity.at
+++ b/libproto/maildir/tests/uidvalidity.at
@@ -22,9 +22,9 @@ cur/1284628225.M20118P3883Q2.Trurl,u=22:2,
cur/1284628225.M21284P3883Q3.Trurl,u=43:2,
cur/1284628225.M22502P3883Q4.Trurl,u=50:2,
])
+AT_CHECK([mbox2dir -i names -p -v 10 inbox $spooldir/mbox1])
AT_CHECK([
-mbox2dir -i names -p -v 10 inbox $spooldir/mbox1
-mbop inbox uidvalidity \; uidnext
+mbop -m inbox uidvalidity \; uidnext
],
[0],
[uidvalidity: 10
diff --git a/testsuite/mbop.c b/testsuite/mbop.c
index a78e7e96d..c4823755a 100644
--- a/testsuite/mbop.c
+++ b/testsuite/mbop.c
@@ -350,6 +350,7 @@ static char const *mbox_actions[] = {
"count",
"recent",
"unseen",
+ "qget",
NULL
};
@@ -464,35 +465,40 @@ struct mu_tesh_command commands[] = {
{ "qget", "QID", mbop_qget },
{ NULL }
};
+
int
main (int argc, char **argv)
{
struct interp_env env = { NULL, NULL, NULL, 0 };
+ int debug_option;
+ struct mu_option options[] = {
+ { "debug", 'd', NULL, MU_OPTION_DEFAULT,
+ "enable debugging",
+ mu_c_incr, &debug_option },
+ { "mailbox", 'm', "FILE", MU_OPTION_DEFAULT,
+ "use this mailbox",
+ mu_c_string, &env.mbxname },
+ MU_OPTION_END
+ };
env.mbxname = getenv ("MAIL");
-
mu_tesh_init (argv[0]);
mu_registrar_record (MBOP_RECORD);
mu_registrar_set_default_scheme (MBOP_SCHEME);
-
- argc--;
- argv++;
-
- if (argc && strcmp (argv[0], "-d") == 0)
- {
- mu_debug_enable_category ("mailbox", 7,
- MU_DEBUG_LEVEL_UPTO (MU_DEBUG_PROT));
- argc--;
- argv++;
- }
- if (argc)
- {
- env.mbxname = argv[0];
- argc--;
- argv++;
- }
+ mu_cli_simple (argc, argv,
+ MU_CLI_OPTION_OPTIONS, options,
+ MU_CLI_OPTION_PROG_DOC, "test tool for " MBOP_SCHEME " mailboxes",
+ MU_CLI_OPTION_PROG_ARGS, "CMD [; CMD ;...]",
+ MU_CLI_OPTION_EX_USAGE, 2,
+ MU_CLI_OPTION_RETURN_ARGC, &argc,
+ MU_CLI_OPTION_RETURN_ARGV, &argv,
+ MU_CLI_OPTION_END);
+
+ if (debug_option)
+ mu_debug_enable_category ("mailbox", 7,
+ MU_DEBUG_LEVEL_UPTO (MU_DEBUG_PROT));
MU_ASSERT (mu_mailbox_create_default (&env.mbx, env.mbxname));
MU_ASSERT (mu_mailbox_open (env.mbx, MU_STREAM_RDWR));

Return to:

Send suggestions and report system problems to the System administrator.