From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id D33191FAD3 for ; Sun, 24 Nov 2019 00:22:42 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 14/17] tests: use File::Temp->newdir instead of tempdir() Date: Sun, 24 Nov 2019 00:22:34 +0000 Message-Id: <20191124002237.15713-15-e@80x24.org> In-Reply-To: <20191124002237.15713-1-e@80x24.org> References: <20191124002237.15713-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: We'll also introduce a tmpdir() API to give tempdirs consistent names. --- t/admin.t | 4 ++-- t/altid.t | 4 ++-- t/altid_v2.t | 3 +-- t/cgi.t | 3 +-- t/common.perl | 10 ++++++++++ t/config.t | 4 ++-- t/convert-compact.t | 3 +-- t/edit.t | 3 +-- t/emergency.t | 4 ++-- t/feed.t | 3 +-- t/filter_rubylang.t | 5 ++--- t/git-http-backend.t | 5 ++--- t/git.t | 6 +++--- t/html_index.t | 4 ++-- t/httpd-corner.t | 3 +-- t/httpd-https.t | 3 +-- t/httpd-unix.t | 3 +-- t/httpd.t | 3 +-- t/import.t | 4 ++-- t/indexlevels-mirror.t | 3 +-- t/init.t | 3 +-- t/mda.t | 3 +-- t/mda_filter_rubylang.t | 3 +-- t/msgmap.t | 4 ++-- t/nntpd-tls.t | 3 +-- t/nntpd-validate.t | 7 +++---- t/nntpd.t | 3 +-- t/nulsubject.t | 4 ++-- t/over.t | 4 ++-- t/perf-nntpd.t | 6 +++--- t/plack.t | 4 ++-- t/psgi_attach.t | 4 ++-- t/psgi_bad_mids.t | 4 ++-- t/psgi_mount.t | 4 ++-- t/psgi_multipart_not.t | 4 ++-- t/psgi_scan_all.t | 4 ++-- t/psgi_search.t | 4 ++-- t/psgi_text.t | 4 ++-- t/psgi_v2.t | 3 +-- t/purge.t | 3 +-- t/replace.t | 3 +-- t/search-thr-index.t | 4 ++-- t/search.t | 4 ++-- t/solver_git.t | 3 +-- t/spamcheck_spamc.t | 4 ++-- t/v1-add-remove-add.t | 6 +++--- t/v1reindex.t | 3 +-- t/v2-add-remove-add.t | 3 +-- t/v2mda.t | 3 +-- t/v2mirror.t | 3 +-- t/v2reindex.t | 3 +-- t/v2writable.t | 3 +-- t/watch_filter_rubylang.t | 3 +-- t/watch_maildir.t | 4 ++-- t/watch_maildir_v2.t | 3 +-- t/www_listing.t | 3 +-- t/xcpdb-reshard.t | 3 +-- 57 files changed, 97 insertions(+), 119 deletions(-) diff --git a/t/admin.t b/t/admin.t index 0024df15..6458982b 100644 --- a/t/admin.t +++ b/t/admin.t @@ -3,9 +3,9 @@ use strict; use warnings; use Test::More; -use File::Temp qw(tempdir); +require './t/common.perl'; use_ok 'PublicInbox::Admin', qw(resolve_repo_dir); -my $tmpdir = tempdir('pi-admin.XXXXXX', TMPDIR => 1, CLEANUP => 1); +my ($tmpdir, $for_destroy) = tmpdir(); my $git_dir = "$tmpdir/v1"; my $v2_dir = "$tmpdir/v2"; my ($res, $err, $v); diff --git a/t/altid.t b/t/altid.t index 4ab004c4..86e7f9de 100644 --- a/t/altid.t +++ b/t/altid.t @@ -3,7 +3,7 @@ use strict; use warnings; use Test::More; -use File::Temp qw/tempdir/; +require './t/common.perl'; foreach my $mod (qw(DBD::SQLite Search::Xapian)) { eval "require $mod"; plan skip_all => "$mod missing for altid.t" if $@; @@ -13,7 +13,7 @@ use_ok 'PublicInbox::Msgmap'; use_ok 'PublicInbox::SearchIdx'; use_ok 'PublicInbox::Import'; use_ok 'PublicInbox::Inbox'; -my $tmpdir = tempdir('pi-altid-XXXXXX', TMPDIR => 1, CLEANUP => 1); +my ($tmpdir, $for_destroy) = tmpdir(); my $git_dir = "$tmpdir/a.git"; my $alt_file = "$tmpdir/another-nntp.sqlite3"; my $altid = [ "serial:gmane:file=$alt_file" ]; diff --git a/t/altid_v2.t b/t/altid_v2.t index 2c1d8616..9e152fc4 100644 --- a/t/altid_v2.t +++ b/t/altid_v2.t @@ -3,7 +3,6 @@ use strict; use warnings; use Test::More; -use File::Temp qw/tempdir/; require './t/common.perl'; require_git(2.6); foreach my $mod (qw(DBD::SQLite Search::Xapian)) { @@ -13,7 +12,7 @@ foreach my $mod (qw(DBD::SQLite Search::Xapian)) { use_ok 'PublicInbox::V2Writable'; use_ok 'PublicInbox::Inbox'; -my $tmpdir = tempdir('pi-altidv2-XXXXXX', TMPDIR => 1, CLEANUP => 1); +my ($tmpdir, $for_destroy) = tmpdir(); my $inboxdir = "$tmpdir/inbox"; my $full = "$tmpdir/inbox/another-nntp.sqlite3"; my $altid = [ 'serial:gmane:file=another-nntp.sqlite3' ]; diff --git a/t/cgi.t b/t/cgi.t index 3c09ecd6..62cea499 100644 --- a/t/cgi.t +++ b/t/cgi.t @@ -6,9 +6,8 @@ use strict; use warnings; use Test::More; use Email::MIME; -use File::Temp qw/tempdir/; require './t/common.perl'; -my $tmpdir = tempdir('pi-cgi-XXXXXX', TMPDIR => 1, CLEANUP => 1); +my ($tmpdir, $for_destroy) = tmpdir(); my $home = "$tmpdir/pi-home"; my $pi_home = "$home/.public-inbox"; my $pi_config = "$pi_home/config"; diff --git a/t/common.perl b/t/common.perl index 2126a761..0ff5de4a 100644 --- a/t/common.perl +++ b/t/common.perl @@ -7,6 +7,16 @@ use strict; use warnings; use IO::Socket::INET; +sub tmpdir (;$) { + my ($base) = @_; + require File::Temp; + unless (defined $base) { + ($base) = ($0 =~ m!\b([^/]+)\.[^\.]+\z!); + } + my $tmpdir = File::Temp->newdir("pi-$base-$$-XXXXXX", TMPDIR => 1); + ($tmpdir->dirname, $tmpdir); +} + sub tcp_server () { IO::Socket::INET->new( LocalAddr => '127.0.0.1', diff --git a/t/config.t b/t/config.t index 0866f264..ade2e796 100644 --- a/t/config.t +++ b/t/config.t @@ -4,8 +4,8 @@ use strict; use warnings; use Test::More; use PublicInbox::Config; -use File::Temp qw/tempdir/; -my $tmpdir = tempdir('pi-config-XXXXXX', TMPDIR => 1, CLEANUP => 1); +require './t/common.perl'; +my ($tmpdir, $for_destroy) = tmpdir(); { is(system(qw(git init -q --bare), $tmpdir), 0, "git init successful"); diff --git a/t/convert-compact.t b/t/convert-compact.t index 0661ed14..b8dc5ed5 100644 --- a/t/convert-compact.t +++ b/t/convert-compact.t @@ -3,7 +3,6 @@ use strict; use warnings; use Test::More; -use File::Temp qw/tempdir/; use PublicInbox::MIME; use PublicInbox::Spawn qw(which); require './t/common.perl'; @@ -18,7 +17,7 @@ which('xapian-compact') or use_ok 'PublicInbox::V2Writable'; use PublicInbox::Import; -my $tmpdir = tempdir('convert-compact-XXXXXX', TMPDIR => 1, CLEANUP => 1); +my ($tmpdir, $for_destroy) = tmpdir(); my $ibx = { inboxdir => "$tmpdir/v1", name => 'test-v1', diff --git a/t/edit.t b/t/edit.t index 09e0cddd..02df6cda 100644 --- a/t/edit.t +++ b/t/edit.t @@ -4,7 +4,6 @@ use strict; use warnings; use Test::More; -use File::Temp qw/tempdir/; require './t/common.perl'; require_git(2.6); require PublicInbox::Inbox; @@ -18,7 +17,7 @@ foreach my $mod (@mods) { plan skip_all => "missing $mod for $0" if $@; }; -my $tmpdir = tempdir('pi-edit-XXXXXX', TMPDIR => 1, CLEANUP => 1); +my ($tmpdir, $for_destroy) = tmpdir(); my $inboxdir = "$tmpdir/v2"; my $ibx = PublicInbox::Inbox->new({ inboxdir => $inboxdir, diff --git a/t/emergency.t b/t/emergency.t index c28826a0..d6c7b6d5 100644 --- a/t/emergency.t +++ b/t/emergency.t @@ -3,8 +3,8 @@ use strict; use warnings; use Test::More; -use File::Temp qw/tempdir/; -my $tmpdir = tempdir('emergency-XXXXXX', TMPDIR => 1, CLEANUP => 1); +require './t/common.perl'; +my ($tmpdir, $for_destroy) = tmpdir(); use_ok 'PublicInbox::Emergency'; { diff --git a/t/feed.t b/t/feed.t index 93da3717..daf97a72 100644 --- a/t/feed.t +++ b/t/feed.t @@ -9,7 +9,6 @@ use PublicInbox::Git; use PublicInbox::Import; use PublicInbox::Config; use PublicInbox::Inbox; -use File::Temp qw/tempdir/; my $have_xml_feed = eval { require XML::Feed; 1 }; require './t/common.perl'; @@ -24,7 +23,7 @@ sub string_feed { $str; } -my $tmpdir = tempdir('pi-feed-XXXXXX', TMPDIR => 1, CLEANUP => 1); +my ($tmpdir, $for_destroy) = tmpdir(); my $git_dir = "$tmpdir/gittest"; my $ibx = PublicInbox::Inbox->new({ address => 'test@example', diff --git a/t/filter_rubylang.t b/t/filter_rubylang.t index 7b1da11c..33753925 100644 --- a/t/filter_rubylang.t +++ b/t/filter_rubylang.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More; use Email::MIME; -use File::Temp qw/tempdir/; +require './t/common.perl'; use_ok 'PublicInbox::Filter::RubyLang'; my $f = PublicInbox::Filter::RubyLang->new; @@ -26,8 +26,7 @@ SKIP: { eval 'require DBD::SQLite'; skip 'DBD::SQLite missing for altid mapping', 4 if $@; use_ok 'PublicInbox::Inbox'; - my $git_dir = tempdir('pi-filter_rubylang-XXXXXX', - TMPDIR => 1, CLEANUP => 1); + my ($git_dir, $for_destroy) = tmpdir(); is(mkdir("$git_dir/public-inbox"), 1, "created public-inbox dir"); my $altid = [ "serial:ruby-core:file=msgmap.sqlite3" ]; my $ibx = PublicInbox::Inbox->new({ inboxdir => $git_dir, diff --git a/t/git-http-backend.t b/t/git-http-backend.t index c4dc09a1..a927d89e 100644 --- a/t/git-http-backend.t +++ b/t/git-http-backend.t @@ -6,8 +6,8 @@ use strict; use warnings; use Test::More; -use File::Temp qw/tempdir/; use POSIX qw(setsid); +require './t/common.perl'; my $git_dir = $ENV{GIANT_GIT_DIR}; plan 'skip_all' => 'GIANT_GIT_DIR not defined' unless $git_dir; @@ -17,9 +17,8 @@ foreach my $mod (qw(BSD::Resource eval "require $mod"; plan skip_all => "$mod missing for git-http-backend.t" if $@; } -require './t/common.perl'; my $psgi = "./t/git-http-backend.psgi"; -my $tmpdir = tempdir('pi-git-http-backend-XXXXXX', TMPDIR => 1, CLEANUP => 1); +my ($tmpdir, $for_destroy) = tmpdir(); my $err = "$tmpdir/stderr.log"; my $out = "$tmpdir/stdout.log"; my $sock = tcp_server(); diff --git a/t/git.t b/t/git.t index a496f851..cc4fc591 100644 --- a/t/git.t +++ b/t/git.t @@ -3,8 +3,8 @@ use strict; use warnings; use Test::More; -use File::Temp qw/tempdir/; -my $dir = tempdir('pi-git-XXXXXX', TMPDIR => 1, CLEANUP => 1); +require './t/common.perl'; +my ($dir, $for_destroy) = tmpdir(); use PublicInbox::Spawn qw(popen_rd); use_ok 'PublicInbox::Git'; @@ -67,7 +67,7 @@ if (1) { } if ('alternates reloaded') { - my $alt = tempdir('pi-git-XXXXXX', TMPDIR => 1, CLEANUP => 1); + my ($alt, $alt_obj) = tmpdir(); my @cmd = ('git', "--git-dir=$alt", qw(hash-object -w --stdin)); is(system(qw(git init -q --bare), $alt), 0, 'create alt directory'); open my $fh, '<', "$alt/config" or die "open failed: $!\n"; diff --git a/t/html_index.t b/t/html_index.t index 2f4b4d1b..51ea9a25 100644 --- a/t/html_index.t +++ b/t/html_index.t @@ -8,8 +8,8 @@ use PublicInbox::Feed; use PublicInbox::Git; use PublicInbox::Import; use PublicInbox::Inbox; -use File::Temp qw/tempdir/; -my $tmpdir = tempdir('pi-http-XXXXXX', TMPDIR => 1, CLEANUP => 1); +require './t/common.perl'; +my ($tmpdir, $for_destroy) = tmpdir(); my $git_dir = "$tmpdir/gittest"; my $ibx = PublicInbox::Inbox->new({ address => 'test@example', diff --git a/t/httpd-corner.t b/t/httpd-corner.t index eca77d7f..551af2b2 100644 --- a/t/httpd-corner.t +++ b/t/httpd-corner.t @@ -14,14 +14,13 @@ foreach my $mod (qw(Plack::Util Plack::Builder HTTP::Date HTTP::Status)) { } use Digest::SHA qw(sha1_hex); -use File::Temp qw/tempdir/; use IO::Socket; use IO::Socket::UNIX; use Fcntl qw(:seek); use Socket qw(IPPROTO_TCP TCP_NODELAY SOL_SOCKET); use POSIX qw(mkfifo); require './t/common.perl'; -my $tmpdir = tempdir('httpd-corner-XXXXXX', TMPDIR => 1, CLEANUP => 1); +my ($tmpdir, $for_destroy) = tmpdir(); my $fifo = "$tmpdir/fifo"; ok(defined mkfifo($fifo, 0777), 'created FIFO'); my $err = "$tmpdir/stderr.log"; diff --git a/t/httpd-https.t b/t/httpd-https.t index 81a11108..de74c20e 100644 --- a/t/httpd-https.t +++ b/t/httpd-https.t @@ -3,7 +3,6 @@ use strict; use warnings; use Test::More; -use File::Temp qw(tempdir); use Socket qw(SOCK_STREAM IPPROTO_TCP SOL_SOCKET); # IO::Poll is part of the standard library, but distros may split them off... foreach my $mod (qw(IO::Socket::SSL IO::Poll)) { @@ -20,7 +19,7 @@ use_ok 'PublicInbox::TLS'; use_ok 'IO::Socket::SSL'; require './t/common.perl'; my $psgi = "./t/httpd-corner.psgi"; -my $tmpdir = tempdir('pi-httpd-https-XXXXXX', TMPDIR => 1, CLEANUP => 1); +my ($tmpdir, $for_destroy) = tmpdir(); my $err = "$tmpdir/stderr.log"; my $out = "$tmpdir/stdout.log"; my $https = tcp_server(); diff --git a/t/httpd-unix.t b/t/httpd-unix.t index 5ec70fd8..f7881cfa 100644 --- a/t/httpd-unix.t +++ b/t/httpd-unix.t @@ -12,9 +12,8 @@ foreach my $mod (qw(Plack::Util Plack::Builder HTTP::Date HTTP::Status)) { plan skip_all => "$mod missing for httpd-unix.t" if $@; } -use File::Temp qw/tempdir/; use IO::Socket::UNIX; -my $tmpdir = tempdir('httpd-unix-XXXXXX', TMPDIR => 1, CLEANUP => 1); +my ($tmpdir, $for_destroy) = tmpdir(); my $unix = "$tmpdir/unix.sock"; my $psgi = './t/httpd-corner.psgi'; my $out = "$tmpdir/out.log"; diff --git a/t/httpd.t b/t/httpd.t index ce8063b2..f0b4efb4 100644 --- a/t/httpd.t +++ b/t/httpd.t @@ -8,12 +8,11 @@ foreach my $mod (qw(Plack::Util Plack::Builder HTTP::Date HTTP::Status)) { eval "require $mod"; plan skip_all => "$mod missing for httpd.t" if $@; } -use File::Temp qw/tempdir/; use Socket qw(IPPROTO_TCP SOL_SOCKET); require './t/common.perl'; # FIXME: too much setup -my $tmpdir = tempdir('pi-httpd-XXXXXX', TMPDIR => 1, CLEANUP => 1); +my ($tmpdir, $for_destroy) = tmpdir(); my $home = "$tmpdir/pi-home"; my $err = "$tmpdir/stderr.log"; my $out = "$tmpdir/stdout.log"; diff --git a/t/import.t b/t/import.t index d309eec5..2f5b08a5 100644 --- a/t/import.t +++ b/t/import.t @@ -9,9 +9,9 @@ use PublicInbox::Import; use PublicInbox::Spawn qw(spawn); use IO::File; use Fcntl qw(:DEFAULT); -use File::Temp qw/tempdir tempfile/; -my $dir = tempdir('pi-import-XXXXXX', TMPDIR => 1, CLEANUP => 1); +use File::Temp qw/tempfile/; require './t/common.perl'; +my ($dir, $for_destroy) = tmpdir(); is(system(qw(git init -q --bare), $dir), 0, 'git init successful'); my $git = PublicInbox::Git->new($dir); diff --git a/t/indexlevels-mirror.t b/t/indexlevels-mirror.t index d129237e..f1c338e1 100644 --- a/t/indexlevels-mirror.t +++ b/t/indexlevels-mirror.t @@ -6,7 +6,6 @@ use Test::More; use PublicInbox::MIME; use PublicInbox::Inbox; use PublicInbox::InboxWritable; -use File::Temp qw/tempdir/; require PublicInbox::Admin; require './t/common.perl'; my $PI_TEST_VERSION = $ENV{PI_TEST_VERSION} || 2; @@ -32,7 +31,7 @@ my $mime = PublicInbox::MIME->create( sub import_index_incremental { my ($v, $level) = @_; my $this = "pi-$v-$level-indexlevels"; - my $tmpdir = tempdir("$this-tmp-XXXXXX", TMPDIR => 1, CLEANUP => 1); + my ($tmpdir, $for_destroy) = tmpdir(); my $ibx = PublicInbox::Inbox->new({ inboxdir => "$tmpdir/testbox", name => $this, diff --git a/t/init.t b/t/init.t index 2442eeec..16550868 100644 --- a/t/init.t +++ b/t/init.t @@ -4,10 +4,9 @@ use strict; use warnings; use Test::More; use PublicInbox::Config; -use File::Temp qw/tempdir/; require './t/common.perl'; -my $tmpdir = tempdir('pi-init-XXXXXX', TMPDIR => 1, CLEANUP => 1); use File::Basename; +my ($tmpdir, $for_destroy) = tmpdir(); sub quiet_fail { my ($cmd, $msg) = @_; my $err = ''; diff --git a/t/mda.t b/t/mda.t index 89dedd4a..47d06132 100644 --- a/t/mda.t +++ b/t/mda.t @@ -4,12 +4,11 @@ use strict; use warnings; use Test::More; use Email::MIME; -use File::Temp qw/tempdir/; use Cwd qw(getcwd); use PublicInbox::MID qw(mid2path); use PublicInbox::Git; require './t/common.perl'; -my $tmpdir = tempdir('pi-mda-XXXXXX', TMPDIR => 1, CLEANUP => 1); +my ($tmpdir, $for_destroy) = tmpdir(); my $home = "$tmpdir/pi-home"; my $pi_home = "$home/.public-inbox"; my $pi_config = "$pi_home/config"; diff --git a/t/mda_filter_rubylang.t b/t/mda_filter_rubylang.t index e971b440..ce17d5a9 100644 --- a/t/mda_filter_rubylang.t +++ b/t/mda_filter_rubylang.t @@ -3,7 +3,6 @@ use strict; use warnings; use Test::More; -use File::Temp qw/tempdir/; use PublicInbox::MIME; use PublicInbox::Config; require './t/common.perl'; @@ -15,7 +14,7 @@ foreach my $mod (@mods) { } use_ok 'PublicInbox::V2Writable'; -my $tmpdir = tempdir('mda-XXXXXX', TMPDIR => 1, CLEANUP => 1); +my ($tmpdir, $for_destroy) = tmpdir(); my $pi_config = "$tmpdir/pi_config"; local $ENV{PI_CONFIG} = $pi_config; local $ENV{PI_EMERGENCY} = "$tmpdir/emergency"; diff --git a/t/msgmap.t b/t/msgmap.t index f1250bca..7fcd131a 100644 --- a/t/msgmap.t +++ b/t/msgmap.t @@ -3,7 +3,7 @@ use strict; use warnings; use Test::More; -use File::Temp qw/tempdir/; +require './t/common.perl'; foreach my $mod (qw(DBD::SQLite)) { eval "require $mod"; @@ -11,7 +11,7 @@ foreach my $mod (qw(DBD::SQLite)) { } use_ok 'PublicInbox::Msgmap'; -my $tmpdir = tempdir('pi-msgmap-XXXXXX', TMPDIR => 1, CLEANUP => 1); +my ($tmpdir, $for_destroy) = tmpdir(); my $d = PublicInbox::Msgmap->new($tmpdir, 1); my %mid2num; diff --git a/t/nntpd-tls.t b/t/nntpd-tls.t index 5d170b78..bbcc04c0 100644 --- a/t/nntpd-tls.t +++ b/t/nntpd-tls.t @@ -3,7 +3,6 @@ use strict; use warnings; use Test::More; -use File::Temp qw(tempdir); use Socket qw(SOCK_STREAM IPPROTO_TCP SOL_SOCKET); # IO::Poll and Net::NNTP are part of the standard library, but # distros may split them off... @@ -34,7 +33,7 @@ eval { require Compress::Raw::Zlib } or $need_zlib = 'Compress::Raw::Zlib missing'; my $version = 2; # v2 needs newer git require_git('2.6') if $version >= 2; -my $tmpdir = tempdir('pi-nntpd-tls-XXXXXX', TMPDIR => 1, CLEANUP => 1); +my ($tmpdir, $for_destroy) = tmpdir(); my $err = "$tmpdir/stderr.log"; my $out = "$tmpdir/stdout.log"; my $inboxdir = "$tmpdir"; diff --git a/t/nntpd-validate.t b/t/nntpd-validate.t index da6985be..39108639 100644 --- a/t/nntpd-validate.t +++ b/t/nntpd-validate.t @@ -4,7 +4,6 @@ # Integration test to validate compression. use strict; use warnings; -use File::Temp qw(tempdir); use Test::More; use Symbol qw(gensym); use Time::HiRes qw(clock_gettime CLOCK_MONOTONIC); @@ -31,8 +30,8 @@ if ($test_tls && !-r $key || !-r $cert) { plan skip_all => "certs/ missing for $0, run $^X ./certs/create-certs.perl"; } require './t/common.perl'; -my $keep_tmp = !!$ENV{TEST_KEEP_TMP}; -my $tmpdir = tempdir('nntpd-validate-XXXXXX',TMPDIR => 1,CLEANUP => $keep_tmp); +my ($tmpdir, $ftd) = tmpdir(); +$File::Temp::KEEP_ALL = !!$ENV{TEST_KEEP_TMP}; my (%OPT, $td, $host_port, $group); my $batch = 1000; if (($ENV{NNTP_TEST_URL} // '') =~ m!\Anntp://([^/]+)/([^/]+)\z!) { @@ -63,7 +62,7 @@ sub do_get_all { my $dig = Digest::SHA->new(1); my $digfh = gensym; my $tmpfh; - if ($keep_tmp) { + if ($File::Temp::KEEP_ALL) { open $tmpfh, '>', "$tmpdir/$desc.raw" or die $!; } my $tmp = { dig => $dig, tmpfh => $tmpfh }; diff --git a/t/nntpd.t b/t/nntpd.t index 3c928610..5b697344 100644 --- a/t/nntpd.t +++ b/t/nntpd.t @@ -13,7 +13,6 @@ require PublicInbox::InboxWritable; use Email::Simple; use IO::Socket; use Socket qw(IPPROTO_TCP TCP_NODELAY); -use File::Temp qw/tempdir/; use Net::NNTP; use Sys::Hostname; require './t/common.perl'; @@ -22,7 +21,7 @@ require './t/common.perl'; my $version = $ENV{PI_TEST_VERSION} || 2; require_git('2.6') if $version == 2; -my $tmpdir = tempdir('pi-nntpd-XXXXXX', TMPDIR => 1, CLEANUP => 1); +my ($tmpdir, $for_destroy) = tmpdir(); my $home = "$tmpdir/pi-home"; my $err = "$tmpdir/stderr.log"; my $out = "$tmpdir/stdout.log"; diff --git a/t/nulsubject.t b/t/nulsubject.t index 4c07f509..617997c0 100644 --- a/t/nulsubject.t +++ b/t/nulsubject.t @@ -3,11 +3,11 @@ use strict; use warnings; use Test::More; -use File::Temp qw/tempdir/; +require './t/common.perl'; use_ok 'PublicInbox::Import'; use_ok 'PublicInbox::Git'; -my $tmpdir = tempdir('pi-nulsubject-XXXXXX', TMPDIR => 1, CLEANUP => 1); +my ($tmpdir, $for_destroy) = tmpdir(); my $git_dir = "$tmpdir/a.git"; { diff --git a/t/over.t b/t/over.t index 48c835f8..27168a33 100644 --- a/t/over.t +++ b/t/over.t @@ -3,15 +3,15 @@ use strict; use warnings; use Test::More; -use File::Temp qw/tempdir/; use Compress::Zlib qw(compress); +require './t/common.perl'; foreach my $mod (qw(DBD::SQLite)) { eval "require $mod"; plan skip_all => "$mod missing for over.t" if $@; } use_ok 'PublicInbox::OverIdx'; -my $tmpdir = tempdir('pi-over-XXXXXX', TMPDIR => 1, CLEANUP => 1); +my ($tmpdir, $for_destroy) = tmpdir(); my $over = PublicInbox::OverIdx->new("$tmpdir/over.sqlite3"); $over->connect; my $x = $over->next_tid; diff --git a/t/perf-nntpd.t b/t/perf-nntpd.t index c7d2eaff..6f891ddb 100644 --- a/t/perf-nntpd.t +++ b/t/perf-nntpd.t @@ -5,12 +5,11 @@ use warnings; use Test::More; use Benchmark qw(:all :hireswallclock); use PublicInbox::Inbox; -use File::Temp qw/tempdir/; use Net::NNTP; my $pi_dir = $ENV{GIANT_PI_DIR}; plan skip_all => "GIANT_PI_DIR not defined for $0" unless $pi_dir; eval { require PublicInbox::Search }; -my ($host_port, $group, %opts, $s, $td); +my ($host_port, $group, %opts, $s, $td, $tmp_obj); require './t/common.perl'; if (($ENV{NNTP_TEST_URL} || '') =~ m!\Anntp://([^/]+)/([^/]+)\z!) { @@ -20,7 +19,8 @@ if (($ENV{NNTP_TEST_URL} || '') =~ m!\Anntp://([^/]+)/([^/]+)\z!) { $group = 'inbox.test.perf.nntpd'; my $ibx = { inboxdir => $pi_dir, newsgroup => $group }; $ibx = PublicInbox::Inbox->new($ibx); - my $tmpdir = tempdir('perf-nntpd-XXXXXX', TMPDIR => 1, CLEANUP => 1); + my $tmpdir; + ($tmpdir, $tmp_obj) = tmpdir(); my $pi_config = "$tmpdir/config"; { diff --git a/t/plack.t b/t/plack.t index 9308813f..6023a419 100644 --- a/t/plack.t +++ b/t/plack.t @@ -4,9 +4,9 @@ use strict; use warnings; use Test::More; use Email::MIME; -use File::Temp qw/tempdir/; +require './t/common.perl'; my $psgi = "./examples/public-inbox.psgi"; -my $tmpdir = tempdir('pi-plack-XXXXXX', TMPDIR => 1, CLEANUP => 1); +my ($tmpdir, $for_destroy) = tmpdir(); my $pi_config = "$tmpdir/config"; my $maindir = "$tmpdir/main.git"; my $addr = 'test-public@example.com'; diff --git a/t/psgi_attach.t b/t/psgi_attach.t index 96f0cb47..45f05bac 100644 --- a/t/psgi_attach.t +++ b/t/psgi_attach.t @@ -4,8 +4,8 @@ use strict; use warnings; use Test::More; use Email::MIME; -use File::Temp qw/tempdir/; -my $tmpdir = tempdir('psgi-attach-XXXXXX', TMPDIR => 1, CLEANUP => 1); +require './t/common.perl'; +my ($tmpdir, $for_destroy) = tmpdir(); my $maindir = "$tmpdir/main.git"; my $addr = 'test-public@example.com'; my $cfgpfx = "publicinbox.test"; diff --git a/t/psgi_bad_mids.t b/t/psgi_bad_mids.t index c7c94718..0e8fa114 100644 --- a/t/psgi_bad_mids.t +++ b/t/psgi_bad_mids.t @@ -3,10 +3,10 @@ use strict; use warnings; use Test::More; -use File::Temp qw/tempdir/; use PublicInbox::MIME; use PublicInbox::Config; use PublicInbox::WWW; +require './t/common.perl'; my @mods = qw(DBD::SQLite HTTP::Request::Common Plack::Test URI::Escape Plack::Builder); foreach my $mod (@mods) { @@ -15,7 +15,7 @@ foreach my $mod (@mods) { } use_ok($_) for @mods; use_ok 'PublicInbox::V2Writable'; -my $inboxdir = tempdir('pi-bad-mids-XXXXXX', TMPDIR => 1, CLEANUP => 1); +my ($inboxdir, $for_destroy) = tmpdir(); my $cfgpfx = "publicinbox.bad-mids"; my $ibx = { inboxdir => $inboxdir, diff --git a/t/psgi_mount.t b/t/psgi_mount.t index 7de2bc0e..ca573e1e 100644 --- a/t/psgi_mount.t +++ b/t/psgi_mount.t @@ -4,8 +4,8 @@ use strict; use warnings; use Test::More; use Email::MIME; -use File::Temp qw/tempdir/; -my $tmpdir = tempdir('psgi-path-XXXXXX', TMPDIR => 1, CLEANUP => 1); +require './t/common.perl'; +my ($tmpdir, $for_destroy) = tmpdir(); my $maindir = "$tmpdir/main.git"; my $addr = 'test-public@example.com'; my $cfgpfx = "publicinbox.test"; diff --git a/t/psgi_multipart_not.t b/t/psgi_multipart_not.t index 40bc3c18..d3489f2d 100644 --- a/t/psgi_multipart_not.t +++ b/t/psgi_multipart_not.t @@ -3,10 +3,10 @@ use strict; use warnings; use Test::More; -use File::Temp qw/tempdir/; use Email::MIME; use PublicInbox::Config; use PublicInbox::WWW; +require './t/common.perl'; my @mods = qw(DBD::SQLite Search::Xapian HTTP::Request::Common Plack::Test URI::Escape Plack::Builder Plack::Test); foreach my $mod (@mods) { @@ -15,7 +15,7 @@ foreach my $mod (@mods) { } use_ok($_) for @mods; use_ok 'PublicInbox::V2Writable'; -my $repo = tempdir('pi-psgi-multipart-not.XXXXXX', TMPDIR => 1, CLEANUP => 1); +my ($repo, $for_destroy) = tmpdir(); my $ibx = PublicInbox::Inbox->new({ inboxdir => $repo, name => 'multipart-not', diff --git a/t/psgi_scan_all.t b/t/psgi_scan_all.t index 707807a7..5d4cc263 100644 --- a/t/psgi_scan_all.t +++ b/t/psgi_scan_all.t @@ -4,8 +4,8 @@ use strict; use warnings; use Test::More; use Email::MIME; -use File::Temp qw/tempdir/; use PublicInbox::Config; +require './t/common.perl'; my @mods = qw(HTTP::Request::Common Plack::Test URI::Escape DBD::SQLite); foreach my $mod (@mods) { eval "require $mod"; @@ -13,7 +13,7 @@ foreach my $mod (@mods) { } use_ok 'PublicInbox::V2Writable'; foreach my $mod (@mods) { use_ok $mod; } -my $tmp = tempdir('pi-scan_all-XXXXXX', TMPDIR => 1, CLEANUP => 1); +my ($tmp, $for_destroy) = tmpdir(); my $cfg = ''; foreach my $i (1..2) { diff --git a/t/psgi_search.t b/t/psgi_search.t index 4cd0e499..0c430aea 100644 --- a/t/psgi_search.t +++ b/t/psgi_search.t @@ -3,13 +3,13 @@ use strict; use warnings; use Test::More; -use File::Temp qw/tempdir/; use Email::MIME; use PublicInbox::Config; use PublicInbox::Inbox; use PublicInbox::InboxWritable; use PublicInbox::WWW; use bytes (); # only for bytes::length +require './t/common.perl'; my @mods = qw(DBD::SQLite Search::Xapian HTTP::Request::Common Plack::Test URI::Escape Plack::Builder); foreach my $mod (@mods) { @@ -18,7 +18,7 @@ foreach my $mod (@mods) { } use_ok $_ foreach (@mods, qw(PublicInbox::SearchIdx)); -my $tmpdir = tempdir('pi-psgi-search.XXXXXX', TMPDIR => 1, CLEANUP => 1); +my ($tmpdir, $for_destroy) = tmpdir(); my $ibx = PublicInbox::Inbox->new({ inboxdir => $tmpdir, diff --git a/t/psgi_text.t b/t/psgi_text.t index da7c6f57..b9564181 100644 --- a/t/psgi_text.t +++ b/t/psgi_text.t @@ -4,8 +4,8 @@ use strict; use warnings; use Test::More; use Email::MIME; -use File::Temp qw/tempdir/; -my $tmpdir = tempdir('psgi-text-XXXXXX', TMPDIR => 1, CLEANUP => 1); +require './t/common.perl'; +my ($tmpdir, $for_destroy) = tmpdir(); my $maindir = "$tmpdir/main.git"; my $addr = 'test-public@example.com'; my $cfgpfx = "publicinbox.test"; diff --git a/t/psgi_v2.t b/t/psgi_v2.t index c7550e2d..1163e2bf 100644 --- a/t/psgi_v2.t +++ b/t/psgi_v2.t @@ -5,7 +5,6 @@ use warnings; use Test::More; require './t/common.perl'; require_git(2.6); -use File::Temp qw/tempdir/; use PublicInbox::MIME; use PublicInbox::Config; use PublicInbox::WWW; @@ -18,7 +17,7 @@ foreach my $mod (@mods) { } use_ok($_) for @mods; use_ok 'PublicInbox::V2Writable'; -my $inboxdir = tempdir('pi-v2_dupes-XXXXXX', TMPDIR => 1, CLEANUP => 1); +my ($inboxdir, $for_destroy) = tmpdir(); my $ibx = { inboxdir => $inboxdir, name => 'test-v2writable', diff --git a/t/purge.t b/t/purge.t index bcdbad52..12644d69 100644 --- a/t/purge.t +++ b/t/purge.t @@ -3,7 +3,6 @@ use strict; use warnings; use Test::More; -use File::Temp qw/tempdir/; require './t/common.perl'; require_git(2.6); my @mods = qw(DBI DBD::SQLite); @@ -13,7 +12,7 @@ foreach my $mod (@mods) { }; use Cwd qw(abs_path); # we need this since we chdir below my $purge = abs_path('blib/script/public-inbox-purge'); -my $tmpdir = tempdir('pi-purge-XXXXXX', TMPDIR => 1, CLEANUP => 1); +my ($tmpdir, $for_destroy) = tmpdir(); use_ok 'PublicInbox::V2Writable'; my $inboxdir = "$tmpdir/v2"; my $ibx = PublicInbox::Inbox->new({ diff --git a/t/replace.t b/t/replace.t index 24f7537c..039c6bc6 100644 --- a/t/replace.t +++ b/t/replace.t @@ -5,7 +5,6 @@ use warnings; use Test::More; use PublicInbox::MIME; use PublicInbox::InboxWritable; -use File::Temp qw/tempdir/; require './t/common.perl'; require_git(2.6); # replace is v2 only, for now... foreach my $mod (qw(DBD::SQLite)) { @@ -17,7 +16,7 @@ sub test_replace ($$$) { my ($v, $level, $opt) = @_; diag "v$v $level replace"; my $this = "pi-$v-$level-replace"; - my $tmpdir = tempdir("$this-tmp-XXXXXX", TMPDIR => 1, CLEANUP => 1); + my ($tmpdir, $for_destroy) = tmpdir($this); my $ibx = PublicInbox::Inbox->new({ inboxdir => "$tmpdir/testbox", name => $this, diff --git a/t/search-thr-index.t b/t/search-thr-index.t index 26339989..4f793657 100644 --- a/t/search-thr-index.t +++ b/t/search-thr-index.t @@ -4,7 +4,6 @@ use strict; use warnings; use bytes (); # only for bytes::length use Test::More; -use File::Temp qw/tempdir/; use PublicInbox::MID qw(mids); use Email::MIME; my @mods = qw(DBI DBD::SQLite Search::Xapian); @@ -14,7 +13,8 @@ foreach my $mod (@mods) { } require PublicInbox::SearchIdx; require PublicInbox::Inbox; -my $tmpdir = tempdir('pi-search-thr-index.XXXXXX', TMPDIR => 1, CLEANUP => 1); +require './t/common.perl'; +my ($tmpdir, $for_destroy) = tmpdir(); my $git_dir = "$tmpdir/a.git"; is(0, system(qw(git init -q --bare), $git_dir), "git init (main)"); diff --git a/t/search.t b/t/search.t index b6531ab3..58684138 100644 --- a/t/search.t +++ b/t/search.t @@ -10,9 +10,9 @@ foreach my $mod (@mods) { }; require PublicInbox::SearchIdx; require PublicInbox::Inbox; -use File::Temp qw/tempdir/; +require './t/common.perl'; use Email::MIME; -my $tmpdir = tempdir('pi-search-XXXXXX', TMPDIR => 1, CLEANUP => 1); +my ($tmpdir, $for_destroy) = tmpdir(); my $git_dir = "$tmpdir/a.git"; my $ibx = PublicInbox::Inbox->new({ inboxdir => $git_dir }); my ($root_id, $last_id); diff --git a/t/solver_git.t b/t/solver_git.t index baab40a4..9bda157d 100644 --- a/t/solver_git.t +++ b/t/solver_git.t @@ -3,7 +3,6 @@ use strict; use warnings; use Test::More; -use File::Temp qw(tempdir); use Cwd qw(abs_path); require './t/common.perl'; require_git(2.6); @@ -22,7 +21,7 @@ $git_dir = abs_path($git_dir); use_ok "PublicInbox::$_" for (qw(Inbox V2Writable MIME Git SolverGit)); -my $inboxdir = tempdir('pi-solver-XXXXXX', TMPDIR => 1, CLEANUP => 1); +my ($inboxdir, $for_destroy) = tmpdir(); my $opts = { inboxdir => $inboxdir, name => 'test-v2writable', diff --git a/t/spamcheck_spamc.t b/t/spamcheck_spamc.t index c13108f4..a4a01a8b 100644 --- a/t/spamcheck_spamc.t +++ b/t/spamcheck_spamc.t @@ -5,9 +5,9 @@ use warnings; use Test::More; use Email::Simple; use IO::File; -use File::Temp qw/tempdir/; use Fcntl qw(:DEFAULT SEEK_SET); -my $tmpdir = tempdir('spamcheck_spamc-XXXXXX', TMPDIR => 1, CLEANUP => 1); +require './t/common.perl'; +my ($tmpdir, $for_destroy) = tmpdir(); use_ok 'PublicInbox::Spamcheck::Spamc'; my $spamc = PublicInbox::Spamcheck::Spamc->new; diff --git a/t/v1-add-remove-add.t b/t/v1-add-remove-add.t index 035fba5c..13e9f29c 100644 --- a/t/v1-add-remove-add.t +++ b/t/v1-add-remove-add.t @@ -5,15 +5,15 @@ use warnings; use Test::More; use PublicInbox::MIME; use PublicInbox::Import; -use File::Temp qw/tempdir/; +require './t/common.perl'; foreach my $mod (qw(DBD::SQLite Search::Xapian)) { eval "require $mod"; plan skip_all => "$mod missing for v1-add-remove-add.t" if $@; } require PublicInbox::SearchIdx; -my $inboxdir = tempdir('pi-add-remove-add-XXXXXX', TMPDIR => 1, CLEANUP => 1); -is(system(qw(git init -q --bare), $inboxdir), 0); +my ($inboxdir, $for_destroy) = tmpdir(); +is(system(qw(git init --bare -q), $inboxdir), 0); my $ibx = { inboxdir => $inboxdir, name => 'test-add-remove-add', diff --git a/t/v1reindex.t b/t/v1reindex.t index e3547753..c0e21a56 100644 --- a/t/v1reindex.t +++ b/t/v1reindex.t @@ -5,7 +5,6 @@ use warnings; use Test::More; use PublicInbox::MIME; use PublicInbox::ContentId qw(content_digest); -use File::Temp qw/tempdir/; use File::Path qw(remove_tree); require './t/common.perl'; require_git(2.6); @@ -16,7 +15,7 @@ foreach my $mod (qw(DBD::SQLite Search::Xapian)) { } use_ok 'PublicInbox::SearchIdx'; use_ok 'PublicInbox::Import'; -my $inboxdir = tempdir('pi-v1reindex-XXXXXX', TMPDIR => 1, CLEANUP => 1); +my ($inboxdir, $for_destroy) = tmpdir(); is(system(qw(git init -q --bare), $inboxdir), 0); my $ibx_config = { inboxdir => $inboxdir, diff --git a/t/v2-add-remove-add.t b/t/v2-add-remove-add.t index 438fe3db..c0dec300 100644 --- a/t/v2-add-remove-add.t +++ b/t/v2-add-remove-add.t @@ -4,7 +4,6 @@ use strict; use warnings; use Test::More; use PublicInbox::MIME; -use File::Temp qw/tempdir/; require './t/common.perl'; require_git(2.6); @@ -13,7 +12,7 @@ foreach my $mod (qw(DBD::SQLite Search::Xapian)) { plan skip_all => "$mod missing for v2-add-remove-add.t" if $@; } use_ok 'PublicInbox::V2Writable'; -my $inboxdir = tempdir('pi-add-remove-add-XXXXXX', TMPDIR => 1, CLEANUP => 1); +my ($inboxdir, $for_destroy) = tmpdir(); my $ibx = { inboxdir => "$inboxdir/v2", name => 'test-v2writable', diff --git a/t/v2mda.t b/t/v2mda.t index 0cd852b1..11a517e4 100644 --- a/t/v2mda.t +++ b/t/v2mda.t @@ -4,7 +4,6 @@ use strict; use warnings; use Test::More; use PublicInbox::MIME; -use File::Temp qw/tempdir/; use Fcntl qw(SEEK_SET); use Cwd; require './t/common.perl'; @@ -16,7 +15,7 @@ foreach my $mod (qw(DBD::SQLite Search::Xapian)) { plan skip_all => "$mod missing for v2mda.t" if $@; } use_ok 'PublicInbox::V2Writable'; -my $tmpdir = tempdir('pi-v2mda-XXXXXX', TMPDIR => 1, CLEANUP => 1); +my ($tmpdir, $for_destroy) = tmpdir(); my $ibx = { inboxdir => "$tmpdir/inbox", name => 'test-v2writable', diff --git a/t/v2mirror.t b/t/v2mirror.t index 1a39ce49..96657fdc 100644 --- a/t/v2mirror.t +++ b/t/v2mirror.t @@ -12,7 +12,6 @@ foreach my $mod (qw(Plack::Util Plack::Builder eval "require $mod"; plan skip_all => "$mod missing for v2mirror.t" if $@; } -use File::Temp qw/tempdir/; use IO::Socket; use POSIX qw(dup2); use_ok 'PublicInbox::V2Writable'; @@ -20,7 +19,7 @@ use PublicInbox::InboxWritable; use PublicInbox::MIME; use PublicInbox::Config; # FIXME: too much setup -my $tmpdir = tempdir('pi-v2mirror-XXXXXX', TMPDIR => 1, CLEANUP => 1); +my ($tmpdir, $for_destroy) = tmpdir(); my $pi_config = "$tmpdir/config"; { open my $fh, '>', $pi_config or die "open($pi_config): $!"; diff --git a/t/v2reindex.t b/t/v2reindex.t index 3e56ddfa..e222d0f1 100644 --- a/t/v2reindex.t +++ b/t/v2reindex.t @@ -5,7 +5,6 @@ use warnings; use Test::More; use PublicInbox::MIME; use PublicInbox::ContentId qw(content_digest); -use File::Temp qw/tempdir/; use File::Path qw(remove_tree); require './t/common.perl'; require_git(2.6); @@ -15,7 +14,7 @@ foreach my $mod (qw(DBD::SQLite Search::Xapian)) { plan skip_all => "$mod missing for v2reindex.t" if $@; } use_ok 'PublicInbox::V2Writable'; -my $inboxdir = tempdir('pi-v2reindex-XXXXXX', TMPDIR => 1, CLEANUP => 1); +my ($inboxdir, $for_destroy) = tmpdir(); my $ibx_config = { inboxdir => $inboxdir, name => 'test-v2writable', diff --git a/t/v2writable.t b/t/v2writable.t index 4bb6d733..7519b487 100644 --- a/t/v2writable.t +++ b/t/v2writable.t @@ -5,7 +5,6 @@ use warnings; use Test::More; use PublicInbox::MIME; use PublicInbox::ContentId qw(content_digest); -use File::Temp qw/tempdir/; require './t/common.perl'; require_git(2.6); foreach my $mod (qw(DBD::SQLite Search::Xapian)) { @@ -14,7 +13,7 @@ foreach my $mod (qw(DBD::SQLite Search::Xapian)) { } use_ok 'PublicInbox::V2Writable'; umask 007; -my $inboxdir = tempdir('pi-v2writable-XXXXXX', TMPDIR => 1, CLEANUP => 1); +my ($inboxdir, $for_destroy) = tmpdir(); my $ibx = { inboxdir => $inboxdir, name => 'test-v2writable', diff --git a/t/watch_filter_rubylang.t b/t/watch_filter_rubylang.t index 57ab3b91..c4078879 100644 --- a/t/watch_filter_rubylang.t +++ b/t/watch_filter_rubylang.t @@ -4,7 +4,6 @@ use strict; use warnings; require './t/common.perl'; use Test::More; -use File::Temp qw/tempdir/; use PublicInbox::MIME; use PublicInbox::Config; my @mods = qw(Filesys::Notify::Simple DBD::SQLite Search::Xapian); @@ -15,7 +14,7 @@ foreach my $mod (@mods) { use_ok 'PublicInbox::WatchMaildir'; use_ok 'PublicInbox::Emergency'; -my $tmpdir = tempdir('watch-XXXXXX', TMPDIR => 1, CLEANUP => 1); +my ($tmpdir, $for_destroy) = tmpdir(); local $ENV{PI_CONFIG} = "$tmpdir/pi_config"; my @v = qw(V1); diff --git a/t/watch_maildir.t b/t/watch_maildir.t index 41d50329..d2e6fecd 100644 --- a/t/watch_maildir.t +++ b/t/watch_maildir.t @@ -2,17 +2,17 @@ # License: AGPL-3.0+ use strict; use Test::More; -use File::Temp qw/tempdir/; use Email::MIME; use Cwd; use PublicInbox::Config; +require './t/common.perl'; my @mods = qw(Filesys::Notify::Simple); foreach my $mod (@mods) { eval "require $mod"; plan skip_all => "$mod missing for watch_maildir.t" if $@; } -my $tmpdir = tempdir('watch_maildir-XXXXXX', TMPDIR => 1, CLEANUP => 1); +my ($tmpdir, $for_destroy) = tmpdir(); my $git_dir = "$tmpdir/test.git"; my $maildir = "$tmpdir/md"; my $spamdir = "$tmpdir/spam"; diff --git a/t/watch_maildir_v2.t b/t/watch_maildir_v2.t index e0e8a13f..53f1bdfc 100644 --- a/t/watch_maildir_v2.t +++ b/t/watch_maildir_v2.t @@ -2,7 +2,6 @@ # License: AGPL-3.0+ use strict; use Test::More; -use File::Temp qw/tempdir/; use PublicInbox::MIME; use Cwd; use PublicInbox::Config; @@ -14,7 +13,7 @@ foreach my $mod (@mods) { plan skip_all => "$mod missing for watch_maildir_v2.t" if $@; } require PublicInbox::V2Writable; -my $tmpdir = tempdir('watch_maildir-v2-XXXXXX', TMPDIR => 1, CLEANUP => 1); +my ($tmpdir, $for_destroy) = tmpdir(); my $inboxdir = "$tmpdir/v2"; my $maildir = "$tmpdir/md"; my $spamdir = "$tmpdir/spam"; diff --git a/t/www_listing.t b/t/www_listing.t index 9cde3575..c9201213 100644 --- a/t/www_listing.t +++ b/t/www_listing.t @@ -5,7 +5,6 @@ use strict; use warnings; use Test::More; use PublicInbox::Spawn qw(which); -use File::Temp qw/tempdir/; require './t/common.perl'; my @mods = qw(URI::Escape Plack::Builder Digest::SHA IO::Compress::Gzip IO::Uncompress::Gunzip HTTP::Tiny); @@ -19,7 +18,7 @@ plan skip_all => "JSON module missing: $@" if $@; use_ok 'PublicInbox::Git'; -my $tmpdir = tempdir('www_listing-tmp-XXXXXX', TMPDIR => 1, CLEANUP => 1); +my ($tmpdir, $for_destroy) = tmpdir(); my $bare = PublicInbox::Git->new("$tmpdir/bare.git"); is(system(qw(git init -q --bare), $bare->{git_dir}), 0, 'git init --bare'); is(PublicInbox::WwwListing::fingerprint($bare), undef, diff --git a/t/xcpdb-reshard.t b/t/xcpdb-reshard.t index 9335843d..ebf156a3 100644 --- a/t/xcpdb-reshard.t +++ b/t/xcpdb-reshard.t @@ -10,7 +10,6 @@ foreach my $mod (@mods) { }; require './t/common.perl'; require_git('2.6'); -use File::Temp qw/tempdir/; use PublicInbox::MIME; use PublicInbox::InboxWritable; @@ -25,7 +24,7 @@ my $mime = PublicInbox::MIME->create( ); my ($this) = (split('/', $0))[-1]; -my $tmpdir = tempdir($this.'-XXXXXX', TMPDIR => 1, CLEANUP => 1); +my ($tmpdir, $for_destroy) = tmpdir(); my $ibx = PublicInbox::Inbox->new({ inboxdir => "$tmpdir/testbox", name => $this,