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, T_SCC_BODY_TEXT_LINE 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 752441F653 for ; Thu, 6 Jun 2024 07:44:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1717659857; bh=S0jgbZF5bQQOKtp4Qkt8rUwvKaNEBQEJFda2z6K6shY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=SV5BuIA+c2j2Zh+l2bcswSr0O+nCblvRtVV35SFRD4CwGGpvdTcnqKbDLc9kB7epg TwhhW9L/AfgyscgamlwP9z0XnkhalSmPTWN/GEMpEiGEkA13jlINCgK8iWYikdL3I6 /Rb3ERXfHT2TiHqPYq9v+7paWPjV5oKkEZya3iG4= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 3/5] test_common: use cached git lookup to reduce stat(2) Date: Thu, 6 Jun 2024 07:44:14 +0000 Message-ID: <20240606074416.3900983-4-e@80x24.org> In-Reply-To: <20240606074416.3900983-1-e@80x24.org> References: <20240606074416.3900983-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: This reduces syscalls required to run tests and IMHO improves readability since we're not having to import `git_exe' everywhere. --- lib/PublicInbox/TestCommon.pm | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/PublicInbox/TestCommon.pm b/lib/PublicInbox/TestCommon.pm index a01949a3..00e96aee 100644 --- a/lib/PublicInbox/TestCommon.pm +++ b/lib/PublicInbox/TestCommon.pm @@ -167,11 +167,8 @@ sub require_git ($;$) { sub require_git_http_backend (;$) { my ($nr) = @_; state $ok = do { - require PublicInbox::Git; - my $git = PublicInbox::Git::git_exe() or plan - skip_all => 'nothing in public-inbox works w/o git'; my $rdr = { 1 => \my $out, 2 => \my $err }; - xsys([$git, qw(http-backend)], undef, $rdr); + xsys([qw(git http-backend)], undef, $rdr); $out =~ /^Status:/ism; }; if (!$ok) { @@ -274,7 +271,9 @@ sub require_mods { sub key2script ($) { my ($key) = @_; - return $key if ($key eq 'git' || index($key, '/') >= 0); + require PublicInbox::Git; + return PublicInbox::Git::git_exe() if $key eq 'git'; + return $key if index($key, '/') >= 0; # n.b. we may have scripts which don't start with "public-inbox" in # the future: $key =~ s/\A([-\.])/public-inbox$1/;