]> Sergey Matveev's repositories - public-inbox.git/commitdiff
t/lei*: check error messages on failures
authorEric Wong <e@80x24.org>
Fri, 23 Jul 2021 10:56:10 +0000 (10:56 +0000)
committerEric Wong <e@80x24.org>
Sun, 25 Jul 2021 00:11:35 +0000 (00:11 +0000)
I just hit an unreproducible failure in t/lei-p2q.t and
lacked $lei_err information to diagnose it.  Hopefully
this helps track down odd failures in the future.

t/lei-externals.t
t/lei-import-http.t
t/lei-import-imap.t
t/lei-mirror.t
t/lei-p2q.t
t/lei-q-kw.t
t/lei-q-remote-import.t
t/lei-q-save.t
t/lei-tag.t
t/solver_git.t

index f148fa3c2b81a1859ac9bba5523f5aa8d24cf0c0..5e3c67bc638ed80ef6f9ff72cf82cc0354d24332 100644 (file)
@@ -211,6 +211,8 @@ test_lei(sub {
                like($lei_out, qr/use boolean prefix/, '--stdin on pipe');
        }
        ok(!lei(qw(q -q --stdin s:use)), "--stdin and argv don't mix");
+       like($lei_err, qr/no query allowed.*--stdin/,
+               '--stdin conflict error message');
 
        for my $fmt (qw(ldjson ndjson jsonl)) {
                lei_ok('q', '-f', $fmt, 's:use boolean prefix');
@@ -250,6 +252,8 @@ test_lei(sub {
        }
        ok(!lei('q', '-o', "$home/mbox", 's:nope'),
                        'fails if mbox format unspecified');
+       like($lei_err, qr/unable to determine mbox/, 'mbox-related message');
+
        ok(!lei(qw(q --no-local s:see)), '--no-local');
        is($? >> 8, 1, 'proper exit code');
        like($lei_err, qr/no local or remote.+? to search/, 'no inbox');
index 2104c778854c22c2793086fee266c229f89e9d22..e9eec1f7e895089658ef97b25bbf668beefa742b 100644 (file)
@@ -17,6 +17,7 @@ test_lei({ tmpdir => $tmpdir }, sub {
        my $url = "http://$host_port/t2";
        for my $p (qw(bogus@x/t.mbox.gz bogus@x/raw ?q=noresultever)) {
                ok(!lei('import', "$url/$p"), "/$p fails properly");
+               like($lei_err, qr/curl.*404/, 'got curl 404');
        }
        for my $p (qw(/ /T/ /t/ /t.atom)) {
                ok(!lei('import', "$url/m\@example$p"), "/$p fails");
@@ -42,5 +43,6 @@ test_lei({ tmpdir => $tmpdir }, sub {
 
        ok(!lei(qw(import --mail-sync), "$url/x\@example.com/raw"),
                '--mail-sync fails on HTTP');
+       like($lei_err, qr/--mail-sync/, 'error message notes --mail-sync');
 });
 done_testing;
index 12f6fad0bd88a075f7dcd0a10ae57cff18436d8a..315567b3b8d4fea66bd2211e11cf377aaee603ea 100644 (file)
@@ -43,6 +43,7 @@ test_lei({ tmpdir => $tmpdir }, sub {
        $url = $u;
        $u =~ s/;UIDVALIDITY=(\d+)\s*/;UIDVALIDITY=9$1/s;
        ok(!lei('import', $u), 'UIDVALIDITY mismatch in URL rejected');
+       like($lei_err, qr/UIDVALIDITY mismatch/, 'mismatch noted');
 
        lei_ok('inspect', $url);
        my $inspect = json_utf8->decode($lei_out);
index dfd35e1af5cae6a1866b64ae24d1c35d32c33575..80bc6ed5ab135f266addc9e63c9bbd2fc7e276de 100644 (file)
@@ -27,6 +27,7 @@ test_lei({ tmpdir => $tmpdir }, sub {
 
        ok(!lei('add-external', $t2, '--mirror', "$http/t2/"),
                '--mirror fails if reused') or diag "$lei_err.$lei_out = $?";
+       like($lei_err, qr/\Q$t2\E' already exists/, 'destination in error');
 
        ok(!lei('add-external', "$home/t2\nnewline", '--mirror', "$http/t2/"),
                '--mirror fails on newline');
@@ -37,13 +38,16 @@ test_lei({ tmpdir => $tmpdir }, sub {
        unlike($lei_out, qr!\Qnewline\E!, 'newline entry not added');
 
        ok(!lei('add-external', "$t2-fail", '-Lmedium'), '--mirror v2');
+       like($lei_err, qr/not a directory/, 'non-directory noted');
        ok(!-d "$t2-fail", 'destination not created on failure');
        lei_ok('ls-external');
        unlike($lei_out, qr!\Q$t2-fail\E!, 'not added to ls-external');
 
        my %phail = (
                HTTPS => 'https://public-inbox.org/' . 'phail',
-               ONION => 'http://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/' . 'phail,'
+               ONION =>
+'http://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/' .
+'phail,'
        );
        for my $t (qw(HTTPS ONION)) {
        SKIP: {
@@ -56,6 +60,7 @@ test_lei({ tmpdir => $tmpdir }, sub {
                is($? >> 8, 22, 'curl 404');
                ok(!-d $dir, 'directory not created');
                unlike($lei_err, qr/# mirrored/, 'no success message');
+               like($lei_err, qr/curl.*404/, "curl 404 shown for $k");
        } # SKIP
        } # for
 });
index 58506f944a208ad58501cd2f2724c8b5e6fcb7d5..495d81de78a5cce12aafc8c35b60c2b843982f7a 100644 (file)
@@ -8,6 +8,7 @@ require_mods(qw(json DBD::SQLite Search::Xapian));
 test_lei(sub {
        ok(!lei(qw(p2q this-better-cause-format-patch-to-fail)),
                'p2q fails on bogus arg');
+       like($lei_err, qr/format-patch.*failed/, 'notes format-patch failure');
        lei_ok(qw(p2q -w dfpost t/data/0001.patch));
        is($lei_out, "dfpost:6e006fd73b1d\n", 'pathname') or diag $lei_err;
        open my $fh, '+<', 't/data/0001.patch' or xbail "open: $!";
index 528751b4742e19eacd590535417baa0138aa6bc2..2e6be1f0dcf71ecd19a9c5fc202958778f38e34e 100644 (file)
@@ -48,6 +48,7 @@ SKIP: {
        my $cat = popen_rd(['cat', $o]);
        ok(!lei(qw(q --import-before bogus -o), "mboxrd:$o"),
                '--import-before fails on non-seekable output');
+       like($lei_err, qr/not seekable/, 'unseekable noted in error');
        is(do { local $/; <$cat> }, '', 'no output on FIFO');
        close $cat;
        $cat = popen_rd(['cat', $o]);
index 7db684d941a4b24097d312c73abb6a47848b8304..aaf56e2732de8b7a9a78e120f9e666fad02af552 100644 (file)
@@ -54,6 +54,7 @@ test_lei({ tmpdir => $tmpdir }, sub {
        ok(-f $o && -s _, '--lock=none respected') or diag $lei_err;
        unlink $o or xbail("unlink $o $! cwd=".Cwd::getcwd());
        ok(!lei(@cmd, '--lock=dotlock,timeout=0.000001'), 'dotlock fails');
+       like($lei_err, qr/dotlock timeout/, 'timeout noted');
        ok(-f $o && !-s _, 'nothing output on lock failure');
        unlink "$o.lock" or BAIL_OUT $!;
        lei_ok(@cmd, '--lock=dotlock,timeout=0.000001',
index 6c5920883a7cbae9481c982a2f611b1772834ca0..b1ca4e92ab656ea1ff6792d05b57bf870e895814 100644 (file)
@@ -69,6 +69,7 @@ test_lei(sub {
        ok(-s "$home/mbcl2" > $size, 'size increased after up');
 
        ok(!lei(qw(up -q), $home), 'up fails w/o --save');
+       like($lei_err, qr/--save was not used/, 'error noted --save');
 
        lei_ok qw(ls-search); my @d = split(/\n/, $lei_out);
        lei_ok qw(ls-search -z); my @z = split(/\0/, $lei_out);
@@ -115,6 +116,8 @@ test_lei(sub {
        lei_ok(qw(up --all=local));
 
        ok(!lei(qw(forget-search), "$home/bogus"), 'bogus forget');
+       like($lei_err, qr/--save was not used/, 'error noted --save');
+
        lei_ok qw(_complete lei forget-search);
        like($lei_out, qr/mbrd-aug/, 'forget-search completion');
        lei_ok(qw(forget-search -v), "$home/mbrd-aug");
@@ -124,6 +127,7 @@ test_lei(sub {
        unlike($lei_out, qr/mbrd-aug/,
                'forget-search completion cleared after forget');
        ok(!lei('up', "$home/mbrd-aug"), 'lei up fails after forget');
+       like($lei_err, qr/--save was not used/, 'error noted --save');
 
        # dedupe=mid
        my $o = "$home/dd-mid";
index 5cb6d9ce0ac8942016477b46eb19862408c1f380..44e4659fc2262db3b76420c85eae9d3f3210d28f 100644 (file)
@@ -32,8 +32,14 @@ test_lei(sub {
        lei_ok(qw(ls-label)); is($lei_out, "urgent\n", 'label found');
        ok(!lei(qw(tag -F eml t/utf8.eml +kw:seeen)), 'bad kw rejected');
        like($lei_err, qr/`seeen' is not one of/, 'got helpful error');
+
        ok(!lei(qw(tag -F eml t/utf8.eml +k:seen)), 'bad prefix rejected');
+       like($lei_err, qr/Unable to handle.*\Q+k:seen\E/, 'bad prefix noted');
+
        ok(!lei(qw(tag -F eml t/utf8.eml)), 'no keywords');
+       like($lei_err, qr/no keywords or labels specified/,
+               'lack of kw/L noted');
+
        my $mb = "$ENV{HOME}/mb";
        my $md = "$ENV{HOME}/md";
        lei_ok(qw(q m:testmessage@example.com -o), "mboxrd:$mb");
@@ -78,7 +84,7 @@ test_lei(sub {
        lei_ok(qw(ls-label));
        is($lei_out, "nope\nqp\nurgent\n", 'ls-label shows qp');
 
-       lei_ok qw(tag -F eml t/utf8.eml +L:INBOX +L:x); diag $lei_err;
+       lei_ok qw(tag -F eml t/utf8.eml +L:INBOX +L:x);
        lei_ok qw(q m:testmessage@example.com);
        $check_kw->([qw(answered seen)], L => [qw(INBOX nope urgent x)]);
        lei_ok(qw(ls-label));
index fe1aff0bb2a06e6b655ea521a2c59632481ef3d6..f5cc592c6a60822f641028c2c01df0718376c0ab 100644 (file)
@@ -43,6 +43,7 @@ test_lei({tmpdir => "$tmpdir/blob"}, sub {
        is($lei_out, $patch2->as_string, 'blob matches');
        ok(!lei('blob', '--mail', '69df7d5', '-I', $ibx->{inboxdir}),
                "--mail won't run solver");
+       like($lei_err, qr/\b69df7d5\b/, 'OID in error by git(1)');
 
        lei_ok('blob', '69df7d5', '-I', $ibx->{inboxdir});
        is(git_sha(1, \$lei_out)->hexdigest, $expect, 'blob contents output');
@@ -51,6 +52,8 @@ test_lei({tmpdir => "$tmpdir/blob"}, sub {
        is($lei_out, $prev, '--no-mail works');
        ok(!lei(qw(blob -I), $ibx->{inboxdir}, $non_existent),
                        'non-existent blob fails');
+       my $abbrev = substr($non_existent, 0, 7);
+       like($lei_err, qr/could not find $abbrev/, 'failed abbreviation noted');
        SKIP: {
                skip '/.git exists', 1 if -e '/.git';
                lei_ok(qw(-C / blob 69df7d5 -I), $ibx->{inboxdir},
@@ -59,9 +62,13 @@ test_lei({tmpdir => "$tmpdir/blob"}, sub {
 
                ok(!lei(qw(-C / blob --no-cwd 69df7d5 -I), $ibx->{inboxdir}),
                        '--no-cwd works');
+               like($lei_err, qr/no --git-dir to try/,
+                       'lack of --git-dir noted');
 
                ok(!lei(qw(-C / blob -I), $ibx->{inboxdir}, $non_existent),
                        'non-existent blob fails');
+               like($lei_err, qr/no --git-dir to try/,
+                       'lack of --git-dir noted');
        }
 
        # fallbacks