user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
From: Eric Wong <>
Subject: [PATCH] t/init.t: don't modify ~/.public-inbox/
Date: Sun, 26 Jul 2020 09:03:15 +0000	[thread overview]
Message-ID: <> (raw)

Tests for failures should not leave junk temporary files lying
around in a users' ~/.public-inbox/.

On a side note, I'm not sure if PI_DIR is or was ever
necessary.  It's never been documented, so perhaps
using $HOME for this is better...
 script/public-inbox-init | 2 ++
 t/init.t                 | 5 ++++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/script/public-inbox-init b/script/public-inbox-init
index 951338af0..b8d71f351 100755
--- a/script/public-inbox-init
+++ b/script/public-inbox-init
@@ -53,6 +53,7 @@ PublicInbox::Lock::lock_acquire($lock_obj);
 # git-config will operate on this (and rename on success):
 my ($fh, $pi_config_tmp) = tempfile('pi-init-XXXXXXXX', DIR => $dir);
+my $cfg_tmp = UnlinkMe->new($pi_config_tmp);
 # Now, we grab another lock to use git-config(1) locking, so it won't
 # wait on the lock, unlike some of our internal flock()-based locks.
@@ -176,6 +177,7 @@ if (defined $perm) {
 rename $pi_config_tmp, $pi_config or
 	die "failed to rename `$pi_config_tmp' to `$pi_config': $!\n";
+delete $cfg_tmp->{file};
 package UnlinkMe;
diff --git a/t/init.t b/t/init.t
index b8f17b5c4..165819554 100644
--- a/t/init.t
+++ b/t/init.t
@@ -50,12 +50,15 @@ sub quiet_fail {
 		'-init did not unlink lock on failure');
+	my $env = { PI_DIR => "$tmpdir/.public-inbox/" };
 	my $rdr = { 2 => \(my $err = '') };
 	my $cmd = [ '-init', 'alist', "$tmpdir/a\nlist",
 		   qw( ];
-	ok(!run_script($cmd, undef, $rdr),
+	ok(!run_script($cmd, $env, $rdr),
 		'public-inbox-init rejects LF in inboxdir');
 	like($err, qr/`\\n' not allowed in `/s, 'reported \\n');
+	is_deeply([glob("$tmpdir/.public-inbox/pi-init-*")], [],
+		'no junk files left behind');
 SKIP: {

                 reply	other threads:[~2020-07-26  9:03 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:

  List information:

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

  git send-email \ \ \ \
    --subject='Re: [PATCH] t/init.t: don'\''t modify ~/.public-inbox/' \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

user/dev discussion of public-inbox itself

This inbox may be cloned and mirrored by anyone:

	git clone --mirror
	git clone --mirror http://czquwvybam4bgbro.onion/meta
	git clone --mirror http://hjrcffqmbrq6wope.onion/meta
	git clone --mirror http://ou63pmih66umazou.onion/meta

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 meta meta/ \
	public-inbox-index meta

Example config snippet for mirrors.
Newsgroups are available over NNTP:
 note: .onion URLs require Tor:

code repositories for project(s) associated with this inbox:

AGPL code for this site: git clone