[PATCH 05/20] t9300: make the series V tests self-contained
- From
Karthik Nayak <karthik.188@gmail.com>
- Date
- Nov 10, 2026, 11:49 UTC
- Message-ID
- <20261110-kn-fast-import-tests-1-v1-5-dbd9ee502aae@gmail.com>
- In-Reply-To
- <20261110-kn-fast-import-tests-1-v1-0-dbd9ee502aae@gmail.com>
Similar to the previous commits, modify the tests in 'series V' to make them independent of state from previous tests.
Move the setup to a 'setup_checkpoint_repo()' function, so each test can invoke it. The tests used to build on the 'U' branch from series U, so let the function create a 'base' commit instead. For the same reason, the tag test now tags 'base' and not 'V'.
'background_import_then_checkpoint()' registers a cleanup with 'test_when_finished', which is not allowed in a subshell, so call it from the main shell.
The 'no new objects' test needs the 'V' commit in a pack, because fast-import only detects duplicates against packs and not against loose objects. It used to rely on the 'fastimport.unpackLimit' set by an earlier test, so create the commit in the test with 'fastimport.unpackLimit' set to 0.
Signed-off-by: Karthik Nayak <karthik.188@gmail.com> --- t/t9300-fast-import.sh | 80 ++++++++++++++++++++++++++++++++++---------------- 1 file changed, 55 insertions(+), 25 deletions(-)
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh index 14af91cffd..8124983409 100755 --- a/t/t9300-fast-import.sh +++ b/t/t9300-fast-import.sh @@ -3777,7 +3777,7 @@ background_import_then_checkpoint () { rm V.output ( - git fast-import $options <&8 >&9 & + git -C repo fast-import $options <&8 >&9 & echo $! >&9 wait $! echo >&2 "background fast-import terminated too early with exit code $?" @@ -3829,80 +3829,110 @@ background_import_still_running () { fi } +setup_checkpoint_repo () { + test_when_finished "rm -rf repo" && + git init repo && + test_tick && + git -C repo fast-import <<-INPUT_END + commit refs/heads/base + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + data <<COMMIT + base commit + COMMIT + INPUT_END +} + test_expect_success PIPE 'V: checkpoint helper does not get stuck with extra output' ' - cat >input <<-INPUT_END && + setup_checkpoint_repo && + cat >repo/input <<-INPUT_END && progress foo progress bar INPUT_END - background_import_then_checkpoint "" input && + background_import_then_checkpoint "" repo/input && background_import_still_running ' test_expect_success PIPE 'V: checkpoint updates refs after reset' ' - cat >input <<-\INPUT_END && + setup_checkpoint_repo && + cat >repo/input <<-\INPUT_END && reset refs/heads/V - from refs/heads/U + from refs/heads/base INPUT_END - background_import_then_checkpoint "" input && - test "$(git rev-parse --verify V)" = "$(git rev-parse --verify U)" && + background_import_then_checkpoint "" repo/input && + test "$(git -C repo rev-parse --verify V)" = "$(git -C repo rev-parse --verify base)" && background_import_still_running ' test_expect_success PIPE 'V: checkpoint updates refs and marks after commit' ' - cat >input <<-INPUT_END && + setup_checkpoint_repo && + cat >repo/input <<-INPUT_END && commit refs/heads/V mark :1 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data 0 - from refs/heads/U + from refs/heads/base INPUT_END - background_import_then_checkpoint "--export-marks=marks.actual" input && + background_import_then_checkpoint "--export-marks=marks.actual" repo/input && + ( + cd repo && + echo ":1 $(git rev-parse --verify V)" >marks.expected && - echo ":1 $(git rev-parse --verify V)" >marks.expected && - - test "$(git rev-parse --verify V^)" = "$(git rev-parse --verify U)" && - test_cmp marks.expected marks.actual && + test "$(git rev-parse --verify V^)" = "$(git rev-parse --verify base)" && + test_cmp marks.expected marks.actual + ) && background_import_still_running ' # Re-create the exact same commit, but on a different branch: no new object is # created in the database, but the refs and marks still need to be updated. test_expect_success PIPE 'V: checkpoint updates refs and marks after commit (no new objects)' ' - cat >input <<-INPUT_END && + setup_checkpoint_repo && + git -C repo -c fastimport.unpackLimit=0 fast-import <<-INPUT_END && + commit refs/heads/V + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + data 0 + from refs/heads/base + + INPUT_END + + cat >repo/input <<-INPUT_END && commit refs/heads/V2 mark :2 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data 0 - from refs/heads/U + from refs/heads/base INPUT_END - background_import_then_checkpoint "--export-marks=marks.actual" input && + background_import_then_checkpoint "--export-marks=marks.actual" repo/input && + ( + cd repo && + echo ":2 $(git rev-parse --verify V2)" >marks.expected && - echo ":2 $(git rev-parse --verify V2)" >marks.expected && - - test "$(git rev-parse --verify V2)" = "$(git rev-parse --verify V)" && - test_cmp marks.expected marks.actual && + test "$(git rev-parse --verify V2)" = "$(git rev-parse --verify V)" && + test_cmp marks.expected marks.actual + ) && background_import_still_running ' test_expect_success PIPE 'V: checkpoint updates tags after tag' ' - cat >input <<-INPUT_END && + setup_checkpoint_repo && + cat >repo/input <<-INPUT_END && tag Vtag - from refs/heads/V + from refs/heads/base tagger $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data 0 INPUT_END - background_import_then_checkpoint "" input && - git show-ref -d Vtag && + background_import_then_checkpoint "" repo/input && + git -C repo show-ref -d Vtag && background_import_still_running '
-- 2.56.GIT