unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH] lei: XDG_RUNTIME_DIR=/dev/null disables daemon mode
Date: Thu, 22 Apr 2021 05:44:16 -0400	[thread overview]
Message-ID: <20210422094416.14989-1-e@80x24.org> (raw)

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 | 9 ++-------
 script/lei                    | 3 ++-
 t/lei-externals.t             | 2 +-
 3 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/lib/PublicInbox/TestCommon.pm b/lib/PublicInbox/TestCommon.pm
index 67fe6336..b5d0b9f8 100644
--- a/lib/PublicInbox/TestCommon.pm
+++ b/lib/PublicInbox/TestCommon.pm
@@ -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) {
diff --git a/script/lei b/script/lei
index 56e9d299..db302422 100755
--- a/script/lei
+++ b/script/lei
@@ -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__);
 }
diff --git a/t/lei-externals.t b/t/lei-externals.t
index 488bf5ad..2291dd99 100644
--- a/t/lei-externals.t
+++ b/t/lei-externals.t
@@ -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 _) {

                 reply	other threads:[~2021-04-22  9:44 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210422094416.14989-1-e@80x24.org \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).