From: Eric Wong Date: Sun, 17 Jan 2021 07:09:58 +0000 (+0000) Subject: t/shared_kv: workaround old File::Spec X-Git-Tag: v1.7.0~1359 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=6b498db4b518938e32d7feff85816f3c6dcf3651;p=public-inbox.git t/shared_kv: workaround old File::Spec 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). --- diff --git a/t/shared_kv.t b/t/shared_kv.t index e7a8e05e..6f6374f2 100644 --- a/t/shared_kv.t +++ b/t/shared_kv.t @@ -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');