From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id B42441FA4D for ; Tue, 17 Oct 2023 23:38:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1697585899; bh=MWJL1c9y5oR2ThRYzQk8dGDDBjcQVckaLtEiO8ZPDGM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=tmjNzU97lbp01L5d2UWMR9OEBK+ieA1z+II7gMiPKCjUvf7qqdOQcz5I1r+HTS0AK ikau67qG9uY2l9qbrORKycIynfb7VdaUxl9VXtMByH73gXKENG7jxx8tomT3J/TzUK RDz9ZKXdGttqJbdyvbd1uH4L86ly6+vSqwco14aI= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 21/30] test_common: use $cwdfh for every run_script command Date: Tue, 17 Oct 2023 23:38:06 +0000 Message-ID: <20231017233815.1637932-22-e@80x24.org> In-Reply-To: <20231017233815.1637932-1-e@80x24.org> References: <20231017233815.1637932-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: It's not lei-specific since we have `-C' to perform chdir for multiple admin commands. --- lib/PublicInbox/TestCommon.pm | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/lib/PublicInbox/TestCommon.pm b/lib/PublicInbox/TestCommon.pm index 96663731..5ad12942 100644 --- a/lib/PublicInbox/TestCommon.pm +++ b/lib/PublicInbox/TestCommon.pm @@ -15,7 +15,7 @@ use Carp (); our @EXPORT; my $lei_loud = $ENV{TEST_LEI_ERR_LOUD}; my $tail_cmd = $ENV{TAIL}; -our ($lei_opt, $lei_out, $lei_err, $lei_cwdfh); +our ($lei_opt, $lei_out, $lei_err); use autodie qw(chdir close fcntl open opendir seek unlink); $_ = File::Spec->rel2abs($_) for (grep(!m!^/!, @INC)); @@ -410,15 +410,12 @@ sub run_script ($;$$) { local $SIG{FPE} = 'IGNORE'; # Perl default local $0 = join(' ', @$cmd); my $orig_io = _prepare_redirects($fhref); - my $cwdfh = $lei_cwdfh; - if (my $d = $opt->{'-C'}) { - $cwdfh or opendir $cwdfh, '.'; - chdir $d; - } + opendir(my $cwdfh, '.'); + chdir $opt->{-C} if defined $opt->{-C}; _run_sub($sub, $key, \@argv); # n.b. all our uses of PublicInbox::DS should be fine # with this and we can't Reset here. - chdir($cwdfh) if $cwdfh; + chdir($cwdfh); _undo_redirects($orig_io); select STDOUT; umask($umask); @@ -672,9 +669,7 @@ sub test_lei { SKIP: { my ($cb) = pop @_; my $test_opt = shift // {}; - local $lei_cwdfh; use autodie qw(mkdir); - opendir $lei_cwdfh, '.'; require_git(2.6, 1); my $mods = $test_opt->{mods} // [ 'lei' ]; require_mods(@$mods, 2);