X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=t%2Flei.t;h=cce90fff89c62c5bbaf5d30d03db24a65844de21;hb=f2c7b911a1c4a7520091ba7224773c30e409c337;hp=bdf6cc1c73731f784f877474250ce10041901cde;hpb=cf731a1422064344f25c214670fb0007ab1d4c2c;p=public-inbox.git diff --git a/t/lei.t b/t/lei.t index bdf6cc1c..cce90fff 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('IO::FDPass', 16); + require_mods(qw(IO::FDPass Cwd), 41); my $sock = "$ENV{XDG_RUNTIME_DIR}/lei/sock"; ok(run_script([qw(lei daemon-pid)], undef, $opt), 'daemon-pid'); @@ -188,7 +188,34 @@ SKIP: { chomp(my $new_pid = $out); ok(kill(0, $new_pid), 'new pid is running'); ok(-S $sock, 'sock exists again'); - unlink $sock or BAIL_OUT "unlink $!"; + + if ('socket inaccessible') { + chmod 0000, $sock or BAIL_OUT "chmod 0000: $!"; + $out = $err = ''; + ok(run_script([qw(lei help)], undef, $opt), + 'connect fail, one-shot fallback works'); + like($err, qr/\bconnect\(/, 'connect error noted'); + like($out, qr/^usage: /, 'help output works'); + chmod 0700, $sock or BAIL_OUT "chmod 0700: $!"; + } + if ('oneshot on cwd gone') { + my $cwd = Cwd::fastcwd() or BAIL_OUT "fastcwd: $!"; + my $d = "$home/to-be-removed"; + mkdir $d or BAIL_OUT "mkdir($d) $!"; + chdir $d or BAIL_OUT "chdir($d) $!"; + if (rmdir($d)) { + $out = $err = ''; + ok(run_script([qw(lei help)], undef, $opt), + 'cwd fail, one-shot fallback works'); + } else { + $err = "rmdir=$!"; + } + chdir $cwd or BAIL_OUT "chdir($cwd) $!"; + like($err, qr/cwd\(/, 'cwd error noted'); + like($out, qr/^usage: /, 'help output still works'); + } + + unlink $sock or BAIL_OUT "unlink($sock) $!"; for (0..100) { kill('CHLD', $new_pid) or last; tick();