]> Sergey Matveev's repositories - public-inbox.git/commitdiff
lei: XDG_RUNTIME_DIR=/dev/null disables daemon mode
authorEric Wong <e@80x24.org>
Thu, 22 Apr 2021 09:44:16 +0000 (05:44 -0400)
committerEric Wong <e@80x24.org>
Thu, 22 Apr 2021 21:05:52 +0000 (17:05 -0400)
We'll support this mode of operation for now to quiet down
testing of oneshot mode where the daemon doesn't persist.

lib/PublicInbox/TestCommon.pm
script/lei
t/lei-externals.t

index 67fe6336d260b49b1b53eabb38b0e833f0799d70..b5d0b9f8f8619e413fd82f37ada97bbab87ae93d 100644 (file)
@@ -468,7 +468,7 @@ sub have_xapian_compact () {
        PublicInbox::Spawn::which($ENV{XAPIAN_COMPACT} || 'xapian-compact');
 }
 
-our ($err_skip, $lei_opt, $lei_out, $lei_err);
+our ($lei_opt, $lei_out, $lei_err);
 # favor lei() or lei_ok() over $lei for new code
 sub lei (@) {
        my ($cmd, $env, $xopt) = @_;
@@ -478,8 +478,6 @@ sub lei (@) {
                $cmd = [ grep { defined && !ref } @_ ];
        }
        my $res = run_script(['lei', @$cmd], $env, $xopt // $lei_opt);
-       $err_skip and
-               $lei_err = join('', grep(!/$err_skip/, split(/^/m, $lei_err)));
        if ($lei_err ne '') {
                if ($lei_err =~ /Use of uninitialized/ ||
                        $lei_err =~ m!\bArgument .*? isn't numeric in !) {
@@ -570,10 +568,7 @@ EOM
                my $home = "$tmpdir/lei-oneshot";
                mkdir($home, 0700) or BAIL_OUT "mkdir: $!";
                local $ENV{HOME} = $home;
-               # force sun_path[108] overflow:
-               my $xrd = "$home/1shot-test".('.sun_path' x 108);
-               local $err_skip = qr!\Q$xrd!; # for lei() filtering
-               local $ENV{XDG_RUNTIME_DIR} = $xrd;
+               local $ENV{XDG_RUNTIME_DIR} = '/dev/null';
                $cb->();
        }
        if ($daemon_pid) {
index 56e9d299593b95c907aaf2a8482ce862a91d5aba..db302422f8b68989d061475e9f491fe07163ca53 100755 (executable)
@@ -62,6 +62,7 @@ my $exec_cmd = sub {
 if ($send_cmd && eval {
        my $path = do {
                my $runtime_dir = ($ENV{XDG_RUNTIME_DIR} // '') . '/lei';
+               die \0 if $runtime_dir eq '/dev/null/lei'; # oneshot forced
                if ($runtime_dir eq '/lei') {
                        require File::Spec;
                        $runtime_dir = File::Spec->tmpdir."/lei-$<";
@@ -131,7 +132,7 @@ Falling back to (slow) one-shot mode
        }
        exit($x_it_code >> 8);
 } else { # for systems lacking Socket::MsgHdr or Inline::C
-       warn $@ if $@;
+       warn $@ if $@ && !ref($@);
        require PublicInbox::LEI;
        PublicInbox::LEI::oneshot(__PACKAGE__);
 }
index 488bf5ad99ef07db571944db05ca0ba14af51767..2291dd992b619ee3a08ec3a9cbbac105b4872dd7 100644 (file)
@@ -49,7 +49,7 @@ SKIP: {
                ok(WIFSIGNALED($?), "signaled @$out");
                is(WTERMSIG($?), SIGPIPE, "got SIGPIPE @$out");
                seek($err, 0, 0);
-               my @err = grep(!m{mkdir .*sun_path\b}, <$err>);
+               my @err = <$err>;
                is_deeply(\@err, [], "no errors @$out");
        }
        if (-d $ENV{XDG_RUNTIME_DIR} && -w _) {