diff options
Diffstat (limited to 't/lei.t')
-rw-r--r-- | t/lei.t | 36 |
1 files changed, 32 insertions, 4 deletions
@@ -1,7 +1,8 @@ #!perl -w -# Copyright (C) 2020-2021 all contributors <meta@public-inbox.org> +# Copyright (C) all contributors <meta@public-inbox.org> # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt> use strict; use v5.10.1; use PublicInbox::TestCommon; +require_mods 'lei'; use File::Path qw(rmtree); # this only tests the basic help/config/init/completion bits of lei; @@ -39,10 +40,21 @@ my $test_help = sub { lei_ok(qw(config -h)); like($lei_out, qr! \Q$home\E/\.config/lei/config\b!, 'actual path shown in config -h'); + my $exp_help = qr/\Q$lei_out\E/s; + ok(!lei('config'), 'config w/o args fails'); + like($lei_err, $exp_help, 'config w/o args shows our help in stderr'); lei_ok(qw(config -h), { XDG_CONFIG_HOME => '/XDC' }, \'config with XDG_CONFIG_HOME'); like($lei_out, qr! /XDC/lei/config\b!, 'XDG_CONFIG_HOME in config -h'); is($lei_err, '', 'no errors from config -h'); + + lei_ok(qw(-c foo.bar config dash.c works)); + lei_ok(qw(config dash.c)); + is($lei_out, "works\n", 'config set w/ -c'); + + lei_ok(qw(-c foo.bar config --add dash.c add-works)); + lei_ok(qw(config --get-all dash.c)); + is($lei_out, "works\nadd-works\n", 'config --add w/ -c'); }; my $ok_err_info = sub { @@ -100,9 +112,11 @@ my $test_config = sub { 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', EDITOR => 'cat' }); + my $env = { VISUAL => 'cat', EDITOR => 'cat' }; + lei_ok([qw(config -e)], $env); is($lei_out, "[a]\n\tb = c\n", '--edit works'); + ok(!lei([qw(-c a.b=c config -e)], $env), '-c conflicts with -e'); + like($lei_err, qr/not allowed/, 'error message shown'); }; my $test_completion = sub { @@ -146,9 +160,18 @@ my $test_fail = sub { lei_ok('q', "foo\n"); like($lei_err, qr/trailing `\\n' removed/s, "noted `\\n' removal"); + lei(qw(q from:infinity..)); + is($? >> 8, 22, 'combined query fails on invalid range op'); + lei(qw(q -t from:infinity..)); + is($? >> 8, 22, 'single query fails on invalid range op'); + for my $lk (qw(ei inbox)) { my $d = "$home/newline\n$lk"; - mkdir $d; + my $all = $lk eq 'ei' ? 'ALL' : 'all'; + { # quiet newline warning on older Perls + local $^W = undef if $^V lt v5.22.0; + File::Path::mkpath("$d/$all.git/objects"); + } 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'), @@ -159,6 +182,11 @@ my $test_fail = sub { } lei_ok('sucks', \'yes, but hopefully less every day'); like($lei_out, qr/loaded features/, 'loaded features shown'); + + lei_ok([qw(q --stdin -f text)], undef, { 0 => \'', %$lei_opt }); + is($lei_err, '', 'no errors on empty stdin'); + is($lei_out, '', 'no output on empty query'); + SKIP: { skip 'no curl', 3 unless require_cmd('curl', 1); lei(qw(q --only http://127.0.0.1:99999/bogus/ t:m)); |