From: Junio C Hamano <gitster@pobox.com>
To: Taylor Blau <me@ttaylorr.com>
Cc: git@vger.kernel.org, "Derrick Stolee" <derrickstolee@github.com>,
"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
"Emily Shaffer" <emilyshaffer@google.com>
Subject: Re: [PATCH v2 1/2] gc: add tests for --cruft and friends
Date: Wed, 26 Oct 2022 14:03:14 -0700 [thread overview]
Message-ID: <xmqqo7tyfgbx.fsf@gitster.g> (raw)
In-Reply-To: <35d2c97715008db3957a69a8260e2046c0e5e738.1666815209.git.me@ttaylorr.com> (Taylor Blau's message of "Wed, 26 Oct 2022 16:13:38 -0400")
Taylor Blau <me@ttaylorr.com> writes:
> +prepare_cruft_history () {
> + test_commit base &&
> +
> + test_commit --no-tag foo &&
> + test_commit --no-tag bar &&
> + git reset HEAD^^
> +}
OK. Three pearls on a single strand, then the tip-two gets rewound
away.
> +assert_cruft_pack_exists () {
> + find .git/objects/pack -name "*.mtimes" >mtimes &&
> + sed -e 's/\.mtimes$/\.pack/g' mtimes >packs &&
Somebody recently made comment that we already depend on the fact
that the default action for "find" is "-print". I do not see the
need for the 'mtimes' intermediary file. It does not hurt, but it
is not needed.
> + test_file_not_empty packs &&
> + while read pack
> + do
> + test_path_is_file "$pack" || return 1
> + done <packs
> +}
OK. We enumerate .mtimes files and ensure corresponding .pack
exists for each of them. That might miss a case where we thought we
created a cruft pack (i.e. .pack exists) but somehow failed to
create the matching .mtimes file by mistake, but it is hard to tell
such a "broken cruft pack" file from a normal pack file, so I think
the above is the best we can do.
> +test_expect_success 'gc --cruft generates a cruft pack' '
> + test_when_finished "rm -fr crufts" &&
> + git init crufts &&
> + (
> + cd crufts &&
> +
> + prepare_cruft_history &&
> + git gc --cruft &&
> + assert_cruft_pack_exists
> + )
> +'
> +
> +test_expect_success 'gc.cruftPacks=true generates a cruft pack' '
> + test_when_finished "rm -fr crufts" &&
> + git init crufts &&
> + (
> + cd crufts &&
> +
> + prepare_cruft_history &&
> + git -c gc.cruftPacks=true gc &&
> + assert_cruft_pack_exists
> + )
> +'
We could instead do away without when-finished clean-up and use
separate test subdirectory. Consistently doing so may make CI
forensic easier. I do not think it is necessary in the test history
used here that is too simple to be realisic. If something breaks at
CI, it is simple enough to reproduce it manually, so I do not think
it is worth a reroll for that.
> run_and_wait_for_auto_gc () {
> # We read stdout from gc for the side effect of waiting until the
> # background gc process exits, closing its fd 9. Furthermore, the
next prev parent reply other threads:[~2022-10-26 21:03 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-26 20:13 [PATCH v2 0/2] gc: let feature.experimental imply gc.cruftPacks Taylor Blau
2022-10-26 20:13 ` [PATCH v2 1/2] gc: add tests for --cruft and friends Taylor Blau
2022-10-26 21:03 ` Junio C Hamano [this message]
2022-10-26 20:13 ` [PATCH v2 2/2] config: let feature.experimental imply gc.cruftPacks=true Taylor Blau
2022-10-26 21:15 ` Junio C Hamano
2022-10-26 21:32 ` Taylor Blau
2022-10-26 20:53 ` [PATCH v2 0/2] gc: let feature.experimental imply gc.cruftPacks Junio C Hamano
2022-10-26 21:32 ` [PATCH v3 " Taylor Blau
2022-10-26 21:32 ` [PATCH v3 1/2] gc: add tests for --cruft and friends Taylor Blau
2022-10-26 21:32 ` [PATCH v3 2/2] config: let feature.experimental imply gc.cruftPacks=true Taylor Blau
2022-10-31 10:46 ` Derrick Stolee
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqo7tyfgbx.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=avarab@gmail.com \
--cc=derrickstolee@github.com \
--cc=emilyshaffer@google.com \
--cc=git@vger.kernel.org \
--cc=me@ttaylorr.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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 NNTP newsgroup(s).