]> Sergey Matveev's repositories - public-inbox.git/commitdiff
t/shared_kv: workaround old File::Spec
authorEric Wong <e@yhbt.net>
Sun, 17 Jan 2021 07:09:58 +0000 (07:09 +0000)
committerEric Wong <e@80x24.org>
Mon, 18 Jan 2021 09:25:11 +0000 (09:25 +0000)
The version of File::Spec shipped with Perl 5.16.3 memoizes the
value of File::Spec->tmpdir, causing changes to $ENV{TMPDIR}
after-the-fact to be ignored.

We'll only work around this in the test since it's innocuous and
unlikely to matter in real-world usage (and there's many places
where we'd have to workaround this in non-test code).

t/shared_kv.t

index e7a8e05e29ea99e388550d01bfa5bc7d0424be84..6f6374f28f351ccf76b7451f0d1ee280b2212052 100644 (file)
@@ -9,9 +9,8 @@ use_ok 'PublicInbox::SharedKV';
 my ($tmpdir, $for_destroy) = tmpdir();
 local $ENV{TMPDIR} = $tmpdir;
 my $skv = PublicInbox::SharedKV->new;
-opendir(my $dh, $tmpdir) or BAIL_OUT $!;
-my @ent = grep(!/\A\.\.?\z/, readdir($dh));
-is(scalar(@ent), 1, 'created a temporary dir');
+my $skv_tmpdir = $skv->{tmpdir};
+ok(-d $skv_tmpdir, 'created a temporary dir');
 $skv->dbh;
 my $dead = "\xde\xad";
 my $beef = "\xbe\xef";
@@ -48,10 +47,7 @@ is($skv->delete_by_val($dead), 2, 'delete_by_val hits');
 is($skv->delete_by_val($dead), 0, 'delete_by_val misses again');
 
 undef $skv;
-rewinddir($dh);
-@ent = grep(!/\A\.\.?\z/, readdir($dh));
-is(scalar(@ent), 0, 'temporary dir gone');
-undef $dh;
+ok(!-d $skv_tmpdir, 'temporary dir gone');
 $skv = PublicInbox::SharedKV->new("$tmpdir/dir", 'base');
 ok(-e "$tmpdir/dir/base.sqlite3", 'file created');