* [PATCH] t/solver_git.t: avoid redundant work for snapshot test
@ 2023-01-01 10:54 Eric Wong
0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2023-01-01 10:54 UTC (permalink / raw)
To: meta
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"));
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2023-01-01 10:54 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-01 10:54 [PATCH] t/solver_git.t: avoid redundant work for snapshot test Eric Wong
Code repositories for project(s) associated with this public inbox
https://80x24.org/public-inbox.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).