about summary refs log tree commit homepage
path: root/t
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-03-25 06:20:24 +0200
committerEric Wong <e@80x24.org>2021-03-25 17:59:03 +0000
commitc1b912dea25f48958434f1e85337029b0959fc83 (patch)
tree108147df9e3c723efc906b9afb7a5c2a1f23a54f /t
parent64b1ce9f94127fc144d6205bb572fe43b4b552c2 (diff)
downloadpublic-inbox-c1b912dea25f48958434f1e85337029b0959fc83.tar.gz
"lei import" should never be without a {sto}, and *_done should
not be called multiple times, so ensure we can fail if it's
missing.

Update some existing tests to complain loudly by introducing a
handy "xbail" function which wraps "explain" and BAIL_OUT.
BAIL_OUT was painful to type and concatenating the result of
"explain" doesn't work as I thought it would since "explain"
always returns an array, and BAIL_OUT only accepts a single
scalar arg (unlike "die").
Diffstat (limited to 't')
-rw-r--r--t/lei-mark.t2
-rw-r--r--t/lei-q-kw.t6
2 files changed, 4 insertions, 4 deletions
diff --git a/t/lei-mark.t b/t/lei-mark.t
index ddf5634c..76995589 100644
--- a/t/lei-mark.t
+++ b/t/lei-mark.t
@@ -30,7 +30,7 @@ test_lei(sub {
         ok(-s $mb, 'wrote mbox result');
         lei_ok(qw(q m:testmessage@example.com -o), $md);
         my @fn = glob("$md/cur/*");
-        scalar(@fn) == 1 or BAIL_OUT 'no mail '.explain(\@fn);
+        scalar(@fn) == 1 or xbail $lei_err, 'no mail', \@fn;
         rename($fn[0], "$fn[0]S") or BAIL_OUT "rename $!";
         $check_kw->(['flagged'], msg => 'after bad request');
         lei_ok(qw(mark -F eml t/utf8.eml -kw:flagged));
diff --git a/t/lei-q-kw.t b/t/lei-q-kw.t
index 4db27363..c17411fb 100644
--- a/t/lei-q-kw.t
+++ b/t/lei-q-kw.t
@@ -21,7 +21,7 @@ lei_ok(qw(import -F eml t/plack-qp.eml));
 my $o = "$ENV{HOME}/dst";
 lei_ok(qw(q -o), "maildir:$o", qw(m:qp@example.com));
 my @fn = glob("$o/cur/*:2,");
-scalar(@fn) == 1 or BAIL_OUT "wrote multiple or zero files: ".explain(\@fn);
+scalar(@fn) == 1 or xbail $lei_err, 'wrote multiple or zero files:', \@fn;
 rename($fn[0], "$fn[0]S") or BAIL_OUT "rename $!";
 
 lei_ok(qw(q -o), "maildir:$o", qw(m:bogus-noresults@example.com));
@@ -124,7 +124,7 @@ lei_ok(qw(q -o), $o, "m:$m", @inc);
 
 # emulate MUA marking a Maildir message as read:
 @fn = glob("$o/cur/*");
-scalar(@fn) == 1 or BAIL_OUT "wrote multiple or zero files: ".explain(\@fn);
+scalar(@fn) == 1 or xbail $lei_err, 'wrote multiple or zero files:', \@fn;
 rename($fn[0], "$fn[0]S") or BAIL_OUT "rename $!";
 
 lei_ok(qw(q -o), $o, 'bogus', \'clobber output dir to import keywords');
@@ -178,7 +178,7 @@ $m = 'multipart@example.com';
 $o = "$ENV{HOME}/fuzz";
 lei_ok('q', '-o', $o, "m:$m", @inc);
 @fn = glob("$o/cur/*");
-scalar(@fn) == 1 or BAIL_OUT "wrote multiple or zero files: ".explain(\@fn);
+scalar(@fn) == 1 or xbail $lei_err, "wrote multiple or zero files", \@fn;
 rename($fn[0], "$fn[0]S") or BAIL_OUT "rename $!";
 lei_ok('q', '-o', $o, "m:$m");
 is_deeply([glob("$o/cur/*")], [], 'clobbered output results');