From: Patrick Steinhardt Date: Wed, 17 Jan 2024 07:32:09 GMT Subject: Re: [PATCH 1/2] t5332-multi-pack-reuse.sh: extract pack-objects helper functions Message-ID: In-Reply-To: <94dd41e1afdd6d926a106ab387295cf5fce624cf.1705431816.git.me@ttaylorr.com> On Tue, Jan 16, 2024 at 02:03:44PM -0500, Taylor Blau wrote: > Most of the tests in t5332 perform some setup before repeating a common > refrain that looks like: > > : >trace2.txt && > GIT_TRACE2_EVENT="$PWD/trace2.txt" \ > git pack-objects --stdout --revs --all >/dev/null && > > test_pack_reused $objects_nr test_packs_reused $packs_nr > The next commit will add more tests which repeat the above refrain. > Avoid duplicating this invocation even further and prepare for the > following commit by wrapping the above in a helper function called > `test_pack_objects_reused_all()`. > > Introduce another similar function `test_pack_objects_reused`, which > expects to read a list of revisions over stdin for tests which need more > fine-grained control of the contents of the pack they generate. > > Signed-off-by: Taylor Blau > --- > t/t5332-multi-pack-reuse.sh | 70 +++++++++++++++---------------------- > 1 file changed, 28 insertions(+), 42 deletions(-) > > diff --git a/t/t5332-multi-pack-reuse.sh b/t/t5332-multi-pack-reuse.sh > index 2ba788b042..b53e821bc0 100755 > --- a/t/t5332-multi-pack-reuse.sh > +++ b/t/t5332-multi-pack-reuse.sh > @@ -23,6 +23,26 @@ pack_position () { > grep "$1" objects | cut -d" " -f1 > } > > +# test_pack_objects_reused_all > +test_pack_objects_reused_all () { > + : >trace2.txt && > + GIT_TRACE2_EVENT="$PWD/trace2.txt" \ > + git pack-objects --stdout --revs --all >/dev/null && > + > + test_pack_reused "$1" + test_packs_reused "$2" +} > + > +# test_pack_objects_reused > +test_pack_objects_reused () { > + : >trace2.txt && > + GIT_TRACE2_EVENT="$PWD/trace2.txt" \ > + git pack-objects --stdout --revs >/dev/null && > + > + test_pack_reused "$1" + test_packs_reused "$2" +} > + > test_expect_success 'preferred pack is reused for single-pack reuse' ' > test_config pack.allowPackReuse single && > [snip] > @@ -104,12 +110,7 @@ test_expect_success 'reuse objects from first pack with middle gap' ' > ^$(git rev-parse D) > EOF > > - : >trace2.txt && > - GIT_TRACE2_EVENT="$PWD/trace2.txt" \ > - git pack-objects --stdout --delta-base-offset --revs /dev/null && > - > - test_pack_reused 3 - test_packs_reused 1 + test_pack_objects_reused 3 1