t/lei-externals.t | 4 ++++ t/lei-import-http.t | 2 ++ t/lei-import-imap.t | 1 + t/lei-mirror.t | 7 ++++++- t/lei-p2q.t | 1 + t/lei-q-kw.t | 1 + t/lei-q-remote-import.t | 1 + t/lei-q-save.t | 4 ++++ t/lei-tag.t | 8 +++++++- t/solver_git.t | 7 +++++++ diff --git a/t/lei-externals.t b/t/lei-externals.t index f148fa3c2b81a1859ac9bba5523f5aa8d24cf0c0..5e3c67bc638ed80ef6f9ff72cf82cc0354d24332 100644 --- a/t/lei-externals.t +++ b/t/lei-externals.t @@ -211,6 +211,8 @@ \'--stdin on pipe file works'); 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 @@ is_deeply(\@res, [], "clobber w/o --augment $sfx"); } 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'); diff --git a/t/lei-import-http.t b/t/lei-import-http.t index 2104c778854c22c2793086fee266c229f89e9d22..e9eec1f7e895089658ef97b25bbf668beefa742b 100644 --- a/t/lei-import-http.t +++ b/t/lei-import-http.t @@ -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 @@ 'imported search result') or diag explain($res); 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; diff --git a/t/lei-import-imap.t b/t/lei-import-imap.t index 12f6fad0bd88a075f7dcd0a10ae57cff18436d8a..315567b3b8d4fea66bd2211e11cf377aaee603ea 100644 --- a/t/lei-import-imap.t +++ b/t/lei-import-imap.t @@ -43,6 +43,7 @@ lei_ok('import', $u, \'UIDVALIDITY match in URL'); $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); diff --git a/t/lei-mirror.t b/t/lei-mirror.t index dfd35e1af5cae6a1866b64ae24d1c35d32c33575..80bc6ed5ab135f266addc9e63c9bbd2fc7e276de 100644 --- a/t/lei-mirror.t +++ b/t/lei-mirror.t @@ -27,6 +27,7 @@ like($lei_out, qr!\Q$t2\E!, 't2 added to ls-externals'); 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 @@ like($lei_out, qr!\Q$t2\E!, 'still in ls-externals'); 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 @@ $url, $dir), '--mirror non-existent v2'); 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 }); diff --git a/t/lei-p2q.t b/t/lei-p2q.t index 58506f944a208ad58501cd2f2724c8b5e6fcb7d5..495d81de78a5cce12aafc8c35b60c2b843982f7a 100644 --- a/t/lei-p2q.t +++ b/t/lei-p2q.t @@ -8,6 +8,7 @@ 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: $!"; diff --git a/t/lei-q-kw.t b/t/lei-q-kw.t index 528751b4742e19eacd590535417baa0138aa6bc2..2e6be1f0dcf71ecd19a9c5fc202958778f38e34e 100644 --- a/t/lei-q-kw.t +++ b/t/lei-q-kw.t @@ -48,6 +48,7 @@ # cat(1) since lei() may not execve for FD_CLOEXEC to work 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]); diff --git a/t/lei-q-remote-import.t b/t/lei-q-remote-import.t index 7db684d941a4b24097d312c73abb6a47848b8304..aaf56e2732de8b7a9a78e120f9e666fad02af552 100644 --- a/t/lei-q-remote-import.t +++ b/t/lei-q-remote-import.t @@ -54,6 +54,7 @@ lei_ok(@cmd, '--lock=none'); 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', diff --git a/t/lei-q-save.t b/t/lei-q-save.t index 6c5920883a7cbae9481c982a2f611b1772834ca0..b1ca4e92ab656ea1ff6792d05b57bf870e895814 100644 --- a/t/lei-q-save.t +++ b/t/lei-q-save.t @@ -69,6 +69,7 @@ lei_ok([qw(up mbcl2)], undef, { -C => $home, %$lei_opt }); 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 @@ 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 @@ lei_ok qw(_complete lei forget-search); 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"; diff --git a/t/lei-tag.t b/t/lei-tag.t index 5cb6d9ce0ac8942016477b46eb19862408c1f380..44e4659fc2262db3b76420c85eae9d3f3210d28f 100644 --- a/t/lei-tag.t +++ b/t/lei-tag.t @@ -32,8 +32,14 @@ $check_kw->(['flagged'], L => ['urgent']); 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 @@ msg => 'external-only message'); 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)); diff --git a/t/solver_git.t b/t/solver_git.t index fe1aff0bb2a06e6b655ea521a2c59632481ef3d6..f5cc592c6a60822f641028c2c01df0718376c0ab 100644 --- a/t/solver_git.t +++ b/t/solver_git.t @@ -43,6 +43,7 @@ \'--mail works for existing oid'); 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 @@ lei_ok(qw(blob --no-mail 69df7d5 -I), $ibx->{inboxdir}); 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 @@ is($lei_out, $prev, '--git-dir works'); 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