-my $test_external = sub {
- $setup_publicinboxes->();
- $cleanup->();
- $lei->('ls-external');
- is($out.$err, '', 'ls-external no output, yet');
- ok(!-e $config_file && !-e $store_dir,
- 'nothing created by ls-external');
-
- my $cfg = PublicInbox::Config->new;
- $cfg->each_inbox(sub {
- my ($ibx) = @_;
- ok($lei->(qw(add-external -q), $ibx->{inboxdir}),
- 'added external');
- is($out.$err, '', 'no output');
- });
- ok(-s $config_file && -e $store_dir,
- 'add-external created config + store');
- my $lcfg = PublicInbox::Config->new($config_file);
- $cfg->each_inbox(sub {
- my ($ibx) = @_;
- is($lcfg->{"external.$ibx->{inboxdir}.boost"}, 0,
- "configured boost on $ibx->{name}");
- });
- $lei->('ls-external');
- like($out, qr/boost=0\n/s, 'ls-external has output');
-
- # note, on a Bourne shell users should be able to use either:
- # s:"use boolean prefix"
- # "s:use boolean prefix"
- # or use single quotes, it should not matter. Users only need
- # to know shell quoting rules, not Xapian quoting rules.
- # No double-quoting should be imposed on users on the CLI
- $lei->('q', 's:use boolean prefix');
- like($out, qr/search: use boolean prefix/, 'phrase search got result');
-
- $lei->('q', '-o', "mboxcl2:$home/mbox", 's:use boolean prefix');
- open my $mb, '<', "$home/mbox" or fail "no mbox: $!";
- my @s = grep(/^Subject:/, <$mb>);
- is(scalar(@s), 1, '1 result in mbox');
- $lei->('q', '-a', '-o', "mboxcl2:$home/mbox", 's:see attachment');
- is($err, '', 'no errors from augment');
- seek($mb, 0, SEEK_SET) or BAIL_OUT "seek: $!";
- @s = grep(/^Subject:/, <$mb>);
- is(scalar(@s), 2, '2 results in mbox');
-
- $lei->('q', '-a', '-o', "mboxcl2:$home/mbox", 's:nonexistent');
- is($err, '', 'no errors on no results');
- seek($mb, 0, SEEK_SET) or BAIL_OUT "seek: $!";
- my @s2 = grep(/^Subject:/, <$mb>);
- is_deeply(\@s2, \@s, 'same 2 old results w/ --augment and bad search');
-
- $lei->('q', '-o', "mboxcl2:$home/mbox", 's:nonexistent');
- is(-s "$home/mbox", 0, 'clobber w/o --augment');
+my $test_fail = sub {
+ lei('q', 'whatever', '-C', '/dev/null');
+ is($? >> 8, 1, 'chdir at end fails to /dev/null');
+ lei('-C', '/dev/null', 'q', 'whatever');
+ is($? >> 8, 1, 'chdir at beginning fails to /dev/null');
+
+ lei_ok('q', "foo\n");
+ like($lei_err, qr/trailing `\\n' removed/s, "noted `\\n' removal");
+
+ for my $lk (qw(ei inbox)) {
+ my $d = "$home/newline\n$lk";
+ mkdir $d;
+ open my $fh, '>', "$d/$lk.lock" or BAIL_OUT "open $d/$lk.lock";
+ for my $fl (qw(-I --only)) {
+ ok(!lei('q', $fl, $d, 'whatever'),
+ "newline $lk.lock fails with q $fl");
+ like($lei_err, qr/`\\n' not allowed/,
+ "error noted with q $fl");
+ }
+ }
+ lei_ok('sucks', \'yes, but hopefully less every day');
+ like($lei_out, qr/loaded features/, 'loaded features shown');
+SKIP: {
+ skip 'no curl', 3 unless require_cmd('curl', 1);
+ lei(qw(q --only http://127.0.0.1:99999/bogus/ t:m));
+ is($? >> 8, 3, 'got curl exit for bogus URL');
+ lei(qw(q --only http://127.0.0.1:99999/bogus/ t:m -o), "$home/junk");
+ is($? >> 8, 3, 'got curl exit for bogus URL with Maildir') or
+ diag $lei_err;
+ is($lei_out, '', 'no output');
+}; # /SKIP