From b28dcf96700a79616e7338bb8610f89155dd57e4 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 18 Dec 2020 07:16:58 +0000 Subject: lei: support for -$DIGIT and -$SIG CLI switches I'm a bit spoiled by using single-dash digit options from common tools: ("git log -$DIGIT", "kill -9", "tail -1", ...), so we'll support it for limiting query results. But first, make it easier to send arbitrary signals to the daemon via "daemon-kill". "daemon-stop" is redundant, now, and removed, since the default for "daemon-kill" is SIGTERM to match kill(1) behavior. --- t/lei.t | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 't') diff --git a/t/lei.t b/t/lei.t index cce90fff..30f9d2b6 100644 --- a/t/lei.t +++ b/t/lei.t @@ -127,7 +127,7 @@ my $test_lei_common = sub { my $test_lei_oneshot = $ENV{TEST_LEI_ONESHOT}; SKIP: { last SKIP if $test_lei_oneshot; - require_mods(qw(IO::FDPass Cwd), 41); + require_mods(qw(IO::FDPass Cwd), 46); my $sock = "$ENV{XDG_RUNTIME_DIR}/lei/sock"; ok(run_script([qw(lei daemon-pid)], undef, $opt), 'daemon-pid'); @@ -174,9 +174,9 @@ SKIP: { ok(run_script([qw(lei daemon-env)], undef, $opt), 'env is empty'); is($out, '', 'env cleared'); - ok(run_script([qw(lei daemon-stop)], undef, $opt), 'daemon-stop'); - is($out, '', 'no output from daemon-stop'); - is($err, '', 'no error from daemon-stop'); + ok(run_script([qw(lei daemon-kill)], undef, $opt), 'daemon-kill'); + is($out, '', 'no output from daemon-kill'); + is($err, '', 'no error from daemon-kill'); for (0..100) { kill(0, $pid) or last; tick(); @@ -189,6 +189,16 @@ SKIP: { ok(kill(0, $new_pid), 'new pid is running'); ok(-S $sock, 'sock exists again'); + $out = $err = ''; + for my $sig (qw(-0 -CHLD)) { + ok(run_script([qw(lei daemon-kill), $sig ], undef, $opt), + "handles $sig"); + } + is($out.$err, '', 'no output on innocuous signals'); + ok(run_script([qw(lei daemon-pid)], undef, $opt), 'daemon-pid'); + chomp $out; + is($out, $new_pid, 'PID unchanged after -0/-CHLD'); + if ('socket inaccessible') { chmod 0000, $sock or BAIL_OUT "chmod 0000: $!"; $out = $err = ''; -- cgit v1.2.3-24-ge0c7