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-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 7F0C81FA17 for ; Sun, 17 Jan 2021 07:10:00 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 4/5] t/shared_kv: workaround old File::Spec Date: Sun, 17 Jan 2021 07:09:58 +0000 Message-Id: <20210117070959.16826-5-e@80x24.org> In-Reply-To: <20210117070959.16826-1-e@80x24.org> References: <20210117070959.16826-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: From: Eric Wong 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 | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) 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');