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,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 657421F698 for ; Sun, 1 Jan 2023 10:54:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1672570483; bh=pkI8l18CsV9dWzNnAw6kP2jtBbCWUo+K71Z5Dzl/w5I=; h=From:To:Subject:Date:From; b=00/GJt8KSW4T/sxPJlNjbntiOlyp+i/2TzBUJaXYOFR2kYIQZ3wgRvhjEqEprwHUK LBIgogvo3LYhf95vjIjsgQBtUOz3km4l/agOQ7DWJUJgUT4KENznE1o1oEdk9jKfNO Q/qJFilwU89nAlBU84vRGcUh8XY2JCRL0vlIea3c= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH] t/solver_git.t: avoid redundant work for snapshot test Date: Sun, 1 Jan 2023 10:54:40 +0000 Message-Id: <20230101105440.2659266-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: We only have to generate the expected tarball and checksum once for testing both -httpd and generic PSGI. And drop the redundant length check since the SHA-256 check is sufficient. This saves 20-30ms on my system. --- t/solver_git.t | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/t/solver_git.t b/t/solver_git.t index d8942747..82222031 100644 --- a/t/solver_git.t +++ b/t/solver_git.t @@ -263,6 +263,16 @@ SKIP: { cgiturl = http://example.com/binfoo EOF close $cfgfh or die; + my $exp_digest; + { + my $exp = xqx([qw(git archive --format=tar.gz + --prefix=public-inbox-1.0.0/ v1.0.0)], + { GIT_DIR => $git_dir }); + is($?, 0, 'no error from git archive'); + ok(length($exp) > 1024, 'expected archive generated'); + $exp_digest = git_sha(256, \$exp)->hexdigest; + }; + my $cfg = PublicInbox::Config->new($cfgpath); my $www = PublicInbox::WWW->new($cfg); my $client = sub { @@ -341,14 +351,11 @@ EOF is($res->header('Content-Disposition'), qq'inline; filename="$fn"', 'c-d header'); is($res->header('ETag'), qq'"$v1_0_0_rev"', 'etag header'); - my $exp = xqx([qw(git archive --format=tar.gz - --prefix=public-inbox-1.0.0/ v1.0.0)], - { GIT_DIR => $git_dir }); + my $got = $res->content; - is(length($got), length($exp), - "length matches installed `git archive' output") and - is(git_sha(1, \$got)->hexdigest, git_sha(1, \$exp)->hexdigest, + is(git_sha(256, \$got)->hexdigest, $exp_digest, "content matches installed `git archive' output"); + undef $got; $fn = 'public-inbox-1.0.2.tar.gz'; $res = $cb->(GET("/public-inbox/snapshot/$fn"));