git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 04/20] t9300: make the series S tests self-contained

From
Karthik Nayak <karthik.188@gmail.com>
Date
Nov 12, 2026, 17:34 UTC
Message-ID
<20261112-kn-fast-import-tests-1-v2-4-b8c3a0ab27e8@gmail.com>
In-Reply-To
<20261112-kn-fast-import-tests-1-v2-0-b8c3a0ab27e8@gmail.com>

Similar to the previous commits, modify the tests in 'series S' to make them independent of state from previous tests.

Replace the 'S: initialize for S tests' test with a 'setup_marks_repo()' function, so each test can invoke it to setup its own repo and tear it down when the test completes.

'S: from with garbage after mark must fail' used to create the 'S2' commit which 'S: merge with garbage after mark must fail' needs. Create that commit in the merge test instead.

Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
---
 t/t9300-fast-import.sh | 332 +++++++++++++++++++++++++++++--------------------
 1 file changed, 198 insertions(+), 134 deletions(-)
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index a0e322b866..f9359bbaf3 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -3100,10 +3100,12 @@ test_expect_success 'R: --git-completion-helper-all does not read from stdin' '
 #
 #   invalid dataref ..
 #
-test_expect_success 'S: initialize for S tests' '
+setup_marks_repo () {
+	test_when_finished "rm -rf repo" &&
+	git init repo &&
 	test_tick &&
 
-	cat >input <<-INPUT_END &&
+	cat >repo/input <<-INPUT_END &&
 	commit refs/heads/S
 	mark :301
 	committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
@@ -3140,142 +3142,168 @@ test_expect_success 'S: initialize for S tests' '
 	BLOB
 	INPUT_END
 
-	git fast-import --export-marks=marks <input
-'
+	git -C repo fast-import --export-marks=marks <repo/input
+}
 
 #
 # filemodify, three datarefs
 #
 test_expect_success 'S: filemodify with garbage after mark must fail' '
-	test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
-	commit refs/heads/S
-	committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-	data <<COMMIT
-	commit N
-	COMMIT
-	M 100644 :403x hello.c
-	EOF
-	test_grep "space after mark" err
+	setup_marks_repo &&
+	(
+		cd repo &&
+
+		test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
+		commit refs/heads/S
+		committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+		data <<COMMIT
+		commit N
+		COMMIT
+		M 100644 :403x hello.c
+		EOF
+		test_grep "space after mark" err
+	)
 '
 
 # inline is misspelled; fast-import thinks it is some unknown dataref
 test_expect_success 'S: filemodify with garbage after inline must fail' '
-	test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
-	commit refs/heads/S
-	committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-	data <<COMMIT
-	commit N
-	COMMIT
-	M 100644 inlineX hello.c
-	data <<BLOB
-	inline
-	BLOB
-	EOF
-	test_grep "nvalid dataref" err
+	setup_marks_repo &&
+	(
+		cd repo &&
+
+		test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
+		commit refs/heads/S
+		committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+		data <<COMMIT
+		commit N
+		COMMIT
+		M 100644 inlineX hello.c
+		data <<BLOB
+		inline
+		BLOB
+		EOF
+		test_grep "nvalid dataref" err
+	)
 '
 
 test_expect_success 'S: filemodify with garbage after sha1 must fail' '
-	sha1=$(grep :403 marks | cut -d\  -f2) &&
-	test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
-	commit refs/heads/S
-	committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-	data <<COMMIT
-	commit N
-	COMMIT
-	M 100644 ${sha1}x hello.c
-	EOF
-	test_grep "space after SHA1" err
+	setup_marks_repo &&
+	(
+		cd repo &&
+
+		sha1=$(grep :403 marks | cut -d\  -f2) &&
+		test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
+		commit refs/heads/S
+		committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+		data <<COMMIT
+		commit N
+		COMMIT
+		M 100644 ${sha1}x hello.c
+		EOF
+		test_grep "space after SHA1" err
+	)
 '
 
 #
 # notemodify, three ways to say dataref
 #
 test_expect_success 'S: notemodify with garbage after mark dataref must fail' '
-	test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
-	commit refs/heads/S
-	committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-	data <<COMMIT
-	commit S note dataref markref
-	COMMIT
-	N :202x :302
-	EOF
-	test_grep "space after mark" err
+	setup_marks_repo &&
+	(
+		cd repo &&
+
+		test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
+		commit refs/heads/S
+		committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+		data <<COMMIT
+		commit S note dataref markref
+		COMMIT
+		N :202x :302
+		EOF
+		test_grep "space after mark" err
+	)
 '
 
 test_expect_success 'S: notemodify with garbage after inline dataref must fail' '
-	test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
-	commit refs/heads/S
-	committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-	data <<COMMIT
-	commit S note dataref inline
-	COMMIT
-	N inlineX :302
-	data <<BLOB
-	note blob
-	BLOB
-	EOF
-	test_grep "nvalid dataref" err
+	setup_marks_repo &&
+	(
+		cd repo &&
+
+		test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
+		commit refs/heads/S
+		committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+		data <<COMMIT
+		commit S note dataref inline
+		COMMIT
+		N inlineX :302
+		data <<BLOB
+		note blob
+		BLOB
+		EOF
+		test_grep "nvalid dataref" err
+	)
 '
 
 test_expect_success 'S: notemodify with garbage after sha1 dataref must fail' '
-	sha1=$(grep :202 marks | cut -d\  -f2) &&
-	test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
-	commit refs/heads/S
-	committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-	data <<COMMIT
-	commit S note dataref sha1
-	COMMIT
-	N ${sha1}x :302
-	EOF
-	test_grep "space after SHA1" err
+	setup_marks_repo &&
+	(
+		cd repo &&
+
+		sha1=$(grep :202 marks | cut -d\  -f2) &&
+		test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
+		commit refs/heads/S
+		committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+		data <<COMMIT
+		commit S note dataref sha1
+		COMMIT
+		N ${sha1}x :302
+		EOF
+		test_grep "space after SHA1" err
+	)
 '
 
 #
 # notemodify, mark in commit-ish
 #
 test_expect_success 'S: notemodify with garbage after mark commit-ish must fail' '
-	test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
-	commit refs/heads/Snotes
-	committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-	data <<COMMIT
-	commit S note commit-ish
-	COMMIT
-	N :202 :302x
-	EOF
-	test_grep "after mark" err
+	setup_marks_repo &&
+	(
+		cd repo &&
+
+		test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
+		commit refs/heads/Snotes
+		committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+		data <<COMMIT
+		commit S note commit-ish
+		COMMIT
+		N :202 :302x
+		EOF
+		test_grep "after mark" err
+	)
 '
 
 #
 # from
 #
 test_expect_success 'S: from with garbage after mark must fail' '
-	test_must_fail \
-	git fast-import --import-marks=marks --export-marks=marks <<-EOF 2>err &&
-	commit refs/heads/S2
-	mark :303
-	committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-	data <<COMMIT
-	commit 3
-	COMMIT
-	from :301x
-	M 100644 :403 hello.c
-	EOF
+	setup_marks_repo &&
+	(
+		cd repo &&
 
+		test_must_fail \
+		git fast-import --import-marks=marks --export-marks=marks <<-EOF 2>err &&
+		commit refs/heads/S2
+		mark :303
+		committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+		data <<COMMIT
+		commit 3
+		COMMIT
+		from :301x
+		M 100644 :403 hello.c
+		EOF
 
-	# go create the commit, need it for merge test
-	git fast-import --import-marks=marks --export-marks=marks <<-EOF &&
-	commit refs/heads/S2
-	mark :303
-	committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-	data <<COMMIT
-	commit 3
-	COMMIT
-	from :301
-	M 100644 :403 hello.c
-	EOF
-
-	# now evaluate the error
-	test_grep "after mark" err
+		test_grep "after mark" err
+	)
 '
 
 
@@ -3283,61 +3311,97 @@ test_expect_success 'S: from with garbage after mark must fail' '
 # merge
 #
 test_expect_success 'S: merge with garbage after mark must fail' '
-	test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
-	commit refs/heads/S
-	mark :304
-	committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-	data <<COMMIT
-	merge 4
-	COMMIT
-	from :302
-	merge :303x
-	M 100644 :403 hello.c
-	EOF
-	test_grep "after mark" err
+	setup_marks_repo &&
+	(
+		cd repo &&
+
+		git fast-import --import-marks=marks --export-marks=marks <<-EOF &&
+		commit refs/heads/S2
+		mark :303
+		committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+		data <<COMMIT
+		commit 3
+		COMMIT
+		from :301
+		M 100644 :403 hello.c
+		EOF
+
+		test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
+		commit refs/heads/S
+		mark :304
+		committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+		data <<COMMIT
+		merge 4
+		COMMIT
+		from :302
+		merge :303x
+		M 100644 :403 hello.c
+		EOF
+		test_grep "after mark" err
+	)
 '
 
 #
 # tag, from markref
 #
 test_expect_success 'S: tag with garbage after mark must fail' '
-	test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
-	tag refs/tags/Stag
-	from :302x
-	tagger $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-	data <<TAG
-	tag S
-	TAG
-	EOF
-	test_grep "after mark" err
+	setup_marks_repo &&
+	(
+		cd repo &&
+
+		test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
+		tag refs/tags/Stag
+		from :302x
+		tagger $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+		data <<TAG
+		tag S
+		TAG
+		EOF
+		test_grep "after mark" err
+	)
 '
 
 #
 # cat-blob markref
 #
 test_expect_success 'S: cat-blob with garbage after mark must fail' '
-	test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
-	cat-blob :403x
-	EOF
-	test_grep "after mark" err
+	setup_marks_repo &&
+	(
+		cd repo &&
+
+		test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
+		cat-blob :403x
+		EOF
+		test_grep "after mark" err
+	)
 '
 
 #
 # ls markref
 #
 test_expect_success 'S: ls with garbage after mark must fail' '
-	test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
-	ls :302x hello.c
-	EOF
-	test_grep "space after mark" err
+	setup_marks_repo &&
+	(
+		cd repo &&
+
+		test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
+		ls :302x hello.c
+		EOF
+		test_grep "space after mark" err
+	)
 '
 
 test_expect_success 'S: ls with garbage after sha1 must fail' '
-	sha1=$(grep :302 marks | cut -d\  -f2) &&
-	test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
-	ls ${sha1}x hello.c
-	EOF
-	test_grep "space after tree-ish" err
+	setup_marks_repo &&
+	(
+		cd repo &&
+
+		sha1=$(grep :302 marks | cut -d\  -f2) &&
+		test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
+		ls ${sha1}x hello.c
+		EOF
+		test_grep "space after tree-ish" err
+	)
 '
 
 #
-- 
2.56.GIT
Previous: Karthik NayakNext: Karthik Nayak
Message 29 of 45 in “t9300: group and move tests to other files”
  1. 00/20 t9300: group and move tests to other filesKarthik Nayak, Nov 10, 2026
  2. 01/20 t9300: move 'fastimport.unpackLimit' to the required testKarthik Nayak, Nov 10, 2026
  3. 02/20 t9300: make the series B tests self-containedKarthik Nayak, Nov 10, 2026
  4. 03/20 t9300: make the series T tests self-containedKarthik Nayak, Nov 10, 2026
  5. 04/20 t9300: make the series S tests self-containedKarthik Nayak, Nov 10, 2026
  6. 05/20 t9300: make the series V tests self-containedKarthik Nayak, Nov 10, 2026
  7. 06/20 t9300: make the series Q tests self-containedKarthik Nayak, Nov 10, 2026
  8. 07/20 t9300: make the series P tests self-containedKarthik Nayak, Nov 10, 2026
  9. 08/20 t9300: make the series O tests self-containedKarthik Nayak, Nov 10, 2026
  10. 09/20 t9300: make the big blob tests self-containedKarthik Nayak, Nov 10, 2026
  11. 10/20 t9300: make the ref update tests self-containedKarthik Nayak, Nov 10, 2026
  12. 11/20 t9300: make the date format tests self-containedKarthik Nayak, Nov 10, 2026
  13. 12/20 t9300: make the pack edges test self-containedKarthik Nayak, Nov 10, 2026
  14. 13/20 t9300: make the marks tests self-containedKarthik Nayak, Nov 10, 2026
  15. 14/20 t9300: make the series Y tests self-containedKarthik Nayak, Nov 10, 2026
  16. 15/20 t9300: make the cat-blob tests self-containedKarthik Nayak, Nov 10, 2026
  17. 16/20 t9300: make the feature and option tests self-containedKarthik Nayak, Nov 10, 2026
  18. 17/20 t9300: make the stream tests self-containedKarthik Nayak, Nov 10, 2026
  19. 18/20 t9300: make the get-mark and encoding tests self-containedKarthik Nayak, Nov 10, 2026
  20. 19/20 t9300: move self-contained tests into dedicated filesKarthik Nayak, Nov 10, 2026
  21. 20/20 t93xx: drop the series letter from the moved test namesKarthik Nayak, Nov 10, 2026
  22. Junio C HamanoNov 10, 2026
  23. Junio C HamanoNov 10, 2026
  24. Karthik NayakNov 11, 2026
  25. 00/20 t9300: group and move tests to other filesKarthik Nayak, Nov 12, 2026
  26. 01/20 t9300: move 'fastimport.unpackLimit' to the required testKarthik Nayak, Nov 12, 2026
  27. 02/20 t9300: make the series B tests self-containedKarthik Nayak, Nov 12, 2026
  28. 03/20 t9300: make the series T tests self-containedKarthik Nayak, Nov 12, 2026
  29. 04/20 t9300: make the series S tests self-containedKarthik Nayak, Nov 12, 2026
  30. 05/20 t9300: make the series V tests self-containedKarthik Nayak, Nov 12, 2026
  31. 06/20 t9300: make the series Q tests self-containedKarthik Nayak, Nov 12, 2026
  32. 07/20 t9300: make the series P tests self-containedKarthik Nayak, Nov 12, 2026
  33. 08/20 t9300: make the series O tests self-containedKarthik Nayak, Nov 12, 2026
  34. 09/20 t9300: make the big blob tests self-containedKarthik Nayak, Nov 12, 2026
  35. 10/20 t9300: make the ref update tests self-containedKarthik Nayak, Nov 12, 2026
  36. 11/20 t9300: make the date format tests self-containedKarthik Nayak, Nov 12, 2026
  37. 12/20 t9300: make the pack edges test self-containedKarthik Nayak, Nov 12, 2026
  38. 13/20 t9300: make the marks tests self-containedKarthik Nayak, Nov 12, 2026
  39. 14/20 t9300: make the series Y tests self-containedKarthik Nayak, Nov 12, 2026
  40. 15/20 t9300: make the cat-blob tests self-containedKarthik Nayak, Nov 12, 2026
  41. 16/20 t9300: make the feature and option tests self-containedKarthik Nayak, Nov 12, 2026
  42. 17/20 t9300: make the stream tests self-containedKarthik Nayak, Nov 12, 2026
  43. 18/20 t9300: make the get-mark and encoding tests self-containedKarthik Nayak, Nov 12, 2026
  44. 19/20 t9300: move self-contained tests into dedicated filesKarthik Nayak, Nov 12, 2026
  45. 20/20 t93xx: drop the series letter from the moved test namesKarthik Nayak, Nov 12, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.