2 # Copyright (C) 2021 all contributors <meta@public-inbox.org>
3 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
4 use strict; use v5.10.1; use PublicInbox::TestCommon;
6 require_mods(qw(json DBD::SQLite Search::Xapian));
9 ok(!lei(qw(p2q this-better-cause-format-patch-to-fail)),
10 'p2q fails on bogus arg');
11 like($lei_err, qr/format-patch.*failed/, 'notes format-patch failure');
12 lei_ok(qw(p2q -w dfpost t/data/0001.patch));
13 is($lei_out, "dfpost:6e006fd73b1d\n", 'pathname') or diag $lei_err;
14 open my $fh, '+<', 't/data/0001.patch' or xbail "open: $!";
15 lei_ok([qw(p2q -w dfpost -)], undef, { %$lei_opt, 0 => $fh });
16 is($lei_out, "dfpost:6e006fd73b1d\n", '--stdin') or diag $lei_err;
18 sysseek($fh, 0, 0) or xbail "lseek: $!";
19 lei_ok([qw(p2q -w dfpost)], undef, { %$lei_opt, 0 => $fh });
20 is($lei_out, "dfpost:6e006fd73b1d\n", 'implicit --stdin');
22 lei_ok(qw(p2q --uri t/data/0001.patch -w), 'dfpost,dfn');
23 is($lei_out, "dfpost%3A6e006fd73b1d+".
24 "dfn%3Alib%2FPublicInbox%2FSearch.pm\n",
25 '--uri -w dfpost,dfn');
26 lei_ok(qw(p2q t/data/0001.patch), '--want=dfpost,OR,dfn');
27 is($lei_out, "dfpost:6e006fd73b1d OR dfn:lib/PublicInbox/Search.pm\n",
29 lei_ok(qw(p2q t/data/0001.patch --want=dfpost9));
30 is($lei_out, "dfpost:6e006fd73b1d OR " .
31 "dfpost:6e006fd73b1 OR " .
32 "dfpost:6e006fd73b OR " .
36 lei_ok(qw(p2q t/data/message_embed.eml --want=dfb));
37 like($lei_out, qr/\bdfb:\S+/, 'got dfb off /dev/null file');