about summary refs log tree commit homepage
path: root/t
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2020-12-17 23:54:04 +0000
committerEric Wong <e@80x24.org>2020-12-19 09:32:08 +0000
commitf2c7b911a1c4a7520091ba7224773c30e409c337 (patch)
tree576386c92369a5f3f1005f68b18b4d6be1470b17 /t
parentcf731a1422064344f25c214670fb0007ab1d4c2c (diff)
downloadpublic-inbox-f2c7b911a1c4a7520091ba7224773c30e409c337.tar.gz
We'll force stdout+stderr to be a pipe the spawning client
controls, thus there's no need to lose error reporting by
prematurely redirecting stdout+stderr to /dev/null.

We can now rely exclusively on OnDestroy to write to syslog() on
uncaught die failures.

Also support falling back to oneshot mode on socket and cwd
failures, since some commands may still be useful if the current
working directory goes missing :P
Diffstat (limited to 't')
-rw-r--r--t/lei.t31
1 files changed, 29 insertions, 2 deletions
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();