# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
use strict; use v5.10.1; use PublicInbox::TestCommon;
use File::Path qw(rmtree);
-use PublicInbox::Spawn qw(which);
# this only tests the basic help/config/init/completion bits of lei;
# actual functionality is tested in other t/lei-*.t tests
-my $curl = which('curl');
my $home;
my $home_trash = [];
my $cleanup = sub { rmtree([@$home_trash, @_]) };
'config set var with -f fails');
like($lei_err, qr/not supported/, 'not supported noted');
ok(!-f "$home/config/f", 'no file created');
+
+ lei_ok(qw(-c imap.debug config --bool imap.debug));
+ is($lei_out, "true\n", "-c sets w/o value");
+ lei_ok(qw(-c imap.debug=1 config --bool imap.debug));
+ is($lei_out, "true\n", "-c coerces value");
+ lei_ok(qw(-c imap.debug=tr00 config imap.debug));
+ is($lei_out, "tr00\n", "-c string value passed as-is");
+ lei_ok(qw(-c imap.debug=a -c imap.debug=b config --get-all imap.debug));
+ is($lei_out, "a\nb\n", '-c and --get-all work together');
+
+ lei_ok([qw(config -e)], { VISUAL => 'cat' });
+ is($lei_out, "[a]\n\tb = c\n", '--edit works');
};
my $test_completion = sub {
%out = map { $_ => 1 } split(/\s+/s, $lei_out);
for my $sw (qw(-f --format -o --output --mfolder --augment -a
--mua --no-local --local --verbose -v
- --save-as --no-remote --remote --torsocks
+ --save --no-save --no-remote --remote --torsocks
--reverse -r )) {
ok($out{$sw}, "$sw offered as `lei q' completion");
}
}
lei_ok(qw(_complete lei import));
%out = map { $_ => 1 } split(/\s+/s, $lei_out);
- for my $sw (qw(--flags --no-flags --no-kw --kw --no-keywords
- --keywords)) {
+ for my $sw (qw(--no-kw --kw)) {
ok($out{$sw}, "$sw offered as `lei import' completion");
}
};
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');
+
+ 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 which('curl');
+ 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");
$test_fail->();
});
+test_lei({ mods => [] }, sub {
+ lei_ok('sucks', \'no optional modules required');
+});
+
done_testing;