2 # Copyright (C) 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;
5 use autodie qw(sysseek);
7 require_mods(qw(json DBD::SQLite Xapian));
10 ok(!lei(qw(p2q this-better-cause-format-patch-to-fail)),
11 'p2q fails on bogus arg') or diag $lei_err;
12 like($lei_err, qr/format-patch.*failed/, 'notes format-patch failure');
13 lei_ok(qw(p2q -w dfpost t/data/0001.patch));
14 is($lei_out, "dfpost:6e006fd73b1d\n", 'pathname') or diag $lei_err;
15 open my $fh, '+<', 't/data/0001.patch' or xbail "open: $!";
16 lei_ok([qw(p2q -w dfpost -)], undef, { %$lei_opt, 0 => $fh });
17 is($lei_out, "dfpost:6e006fd73b1d\n", '--stdin') or diag $lei_err;
20 lei_ok([qw(p2q -w dfpost)], undef, { %$lei_opt, 0 => $fh });
21 is($lei_out, "dfpost:6e006fd73b1d\n", 'implicit --stdin');
23 lei_ok(qw(p2q --uri t/data/0001.patch -w), 'dfpost,dfn');
24 is($lei_out, "dfpost%3A6e006fd73b1d+".
25 "dfn%3Alib%2FPublicInbox%2FSearch.pm\n",
26 '--uri -w dfpost,dfn');
27 lei_ok(qw(p2q t/data/0001.patch), '--want=dfpost,OR,dfn');
28 is($lei_out, "dfpost:6e006fd73b1d OR dfn:lib/PublicInbox/Search.pm\n",
30 lei_ok(qw(p2q t/data/0001.patch --want=dfpost9));
31 is($lei_out, "dfpost:6e006fd73b1d OR " .
32 "dfpost:6e006fd73b1 OR " .
33 "dfpost:6e006fd73b OR " .
37 lei_ok(qw(p2q t/data/message_embed.eml --want=dfb));
38 like($lei_out, qr/\bdfb:\S+/, 'got dfb off /dev/null file');