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

[PATCH 07/20] t9300: make the series P 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-7-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 P' to make them independent of state from previous tests.

Move the setup to a 'setup_gitlinks_repo()' function, so each test can invoke it.

The 'fail on inline gitlink' and 'fail on blob mark in gitlink' tests create their commit on top of 'subuse2', which is only written by the 'verbatim SHA gitlinks' test. Use 'subuse1' from the setup instead, as these tests only check that the invalid gitlink is rejected.

Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
---
 t/t9300-fast-import.sh | 290 +++++++++++++++++++++++++++----------------------
 1 file changed, 161 insertions(+), 129 deletions(-)
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index 9b1827bae2..480ae2c47f 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -1866,157 +1866,189 @@ test_expect_success 'O: progress outputs as requested by input' '
 ### series P (gitlinks)
 ###
 
-test_expect_success 'P: superproject & submodule mix' '
-	cat >input <<-INPUT_END &&
-	blob
-	mark :1
-	data 10
-	test file
-
-	reset refs/heads/sub
-	commit refs/heads/sub
-	mark :2
-	committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-	data 12
-	sub_initial
-	M 100644 :1 file
-
-	blob
-	mark :3
-	data <<DATAEND
-	[submodule "sub"]
-		path = sub
-		url = "$(pwd)/sub"
-	DATAEND
-
-	commit refs/heads/subuse1
-	mark :4
-	committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-	data 8
-	initial
-	from refs/heads/main
-	M 100644 :3 .gitmodules
-	M 160000 :2 sub
-
-	blob
-	mark :5
-	data 20
-	test file
-	more data
-
-	commit refs/heads/sub
-	mark :6
-	committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-	data 11
-	sub_second
-	from :2
-	M 100644 :5 file
-
-	commit refs/heads/subuse1
-	mark :7
-	committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-	data 7
-	second
-	from :4
-	M 160000 :6 sub
-
-	INPUT_END
-
-	git fast-import <input &&
-	git checkout subuse1 &&
-	rm -rf sub &&
-	mkdir sub &&
+setup_gitlinks_repo () {
+	test_when_finished "rm -rf repo" &&
+	git init repo &&
+	test_commit -C repo base &&
 	(
-		cd sub &&
-		git init &&
-		git fetch --update-head-ok .. refs/heads/sub:refs/heads/main &&
-		git checkout main
-	) &&
-	git submodule init &&
-	git submodule update
+		cd repo &&
+
+		cat >input <<-INPUT_END &&
+		blob
+		mark :1
+		data 10
+		test file
+
+		reset refs/heads/sub
+		commit refs/heads/sub
+		mark :2
+		committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+		data 12
+		sub_initial
+		M 100644 :1 file
+
+		blob
+		mark :3
+		data <<DATAEND
+		[submodule "sub"]
+			path = sub
+			url = "$(pwd)/sub"
+		DATAEND
+
+		commit refs/heads/subuse1
+		mark :4
+		committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+		data 8
+		initial
+		from refs/heads/main
+		M 100644 :3 .gitmodules
+		M 160000 :2 sub
+
+		blob
+		mark :5
+		data 20
+		test file
+		more data
+
+		commit refs/heads/sub
+		mark :6
+		committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+		data 11
+		sub_second
+		from :2
+		M 100644 :5 file
+
+		commit refs/heads/subuse1
+		mark :7
+		committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+		data 7
+		second
+		from :4
+		M 160000 :6 sub
+
+		INPUT_END
+
+		git fast-import <input
+	)
+}
+
+test_expect_success 'P: superproject & submodule mix' '
+	setup_gitlinks_repo &&
+	(
+		cd repo &&
+
+		git checkout subuse1 &&
+		rm -rf sub &&
+		mkdir sub &&
+		(
+			cd sub &&
+			git init &&
+			git fetch --update-head-ok .. refs/heads/sub:refs/heads/main &&
+			git checkout main
+		) &&
+		git submodule init &&
+		git submodule update
+	)
 '
 
 test_expect_success 'P: verbatim SHA gitlinks' '
-	SUBLAST=$(git rev-parse --verify sub) &&
-	SUBPREV=$(git rev-parse --verify sub^) &&
+	setup_gitlinks_repo &&
+	(
+		cd repo &&
 
-	cat >input <<-INPUT_END &&
-	blob
-	mark :1
-	data <<DATAEND
-	[submodule "sub"]
-		path = sub
-		url = "$(pwd)/sub"
-	DATAEND
+		SUBLAST=$(git rev-parse --verify sub) &&
+		SUBPREV=$(git rev-parse --verify sub^) &&
 
-	commit refs/heads/subuse2
-	mark :2
-	committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-	data 8
-	initial
-	from refs/heads/main
-	M 100644 :1 .gitmodules
-	M 160000 $SUBPREV sub
+		cat >input <<-INPUT_END &&
+		blob
+		mark :1
+		data <<DATAEND
+		[submodule "sub"]
+			path = sub
+			url = "$(pwd)/sub"
+		DATAEND
 
-	commit refs/heads/subuse2
-	mark :3
-	committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-	data 7
-	second
-	from :2
-	M 160000 $SUBLAST sub
+		commit refs/heads/subuse2
+		mark :2
+		committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+		data 8
+		initial
+		from refs/heads/main
+		M 100644 :1 .gitmodules
+		M 160000 $SUBPREV sub
 
-	INPUT_END
+		commit refs/heads/subuse2
+		mark :3
+		committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+		data 7
+		second
+		from :2
+		M 160000 $SUBLAST sub
 
-	git branch -D sub &&
-	git gc --prune=now &&
-	git fast-import <input &&
-	test $(git rev-parse --verify subuse2) = $(git rev-parse --verify subuse1)
+		INPUT_END
+
+		git branch -D sub &&
+		git gc --prune=now &&
+		git fast-import <input &&
+		test $(git rev-parse --verify subuse2) = $(git rev-parse --verify subuse1)
+	)
 '
 
 test_expect_success 'P: fail on inline gitlink' '
-	test_tick &&
-	cat >input <<-INPUT_END &&
-	commit refs/heads/subuse3
-	mark :1
-	committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-	data <<COMMIT
-	corrupt
-	COMMIT
+	setup_gitlinks_repo &&
+	(
+		cd repo &&
 
-	from refs/heads/subuse2
-	M 160000 inline sub
-	data <<DATA
-	$SUBPREV
-	DATA
+		SUBPREV=$(git rev-parse --verify sub^) &&
+		test_tick &&
+		cat >input <<-INPUT_END &&
+		commit refs/heads/subuse3
+		mark :1
+		committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+		data <<COMMIT
+		corrupt
+		COMMIT
 
-	INPUT_END
+		from refs/heads/subuse1
+		M 160000 inline sub
+		data <<DATA
+		$SUBPREV
+		DATA
 
-	test_must_fail git fast-import <input
+		INPUT_END
+
+		test_must_fail git fast-import <input
+	)
 '
 
 test_expect_success 'P: fail on blob mark in gitlink' '
-	test_tick &&
-	cat >input <<-INPUT_END &&
-	blob
-	mark :1
-	data <<DATA
-	$SUBPREV
-	DATA
+	setup_gitlinks_repo &&
+	(
+		cd repo &&
 
-	commit refs/heads/subuse3
-	mark :2
-	committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-	data <<COMMIT
-	corrupt
-	COMMIT
+		SUBPREV=$(git rev-parse --verify sub^) &&
+		test_tick &&
+		cat >input <<-INPUT_END &&
+		blob
+		mark :1
+		data <<DATA
+		$SUBPREV
+		DATA
 
-	from refs/heads/subuse2
-	M 160000 :1 sub
+		commit refs/heads/subuse3
+		mark :2
+		committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+		data <<COMMIT
+		corrupt
+		COMMIT
 
-	INPUT_END
+		from refs/heads/subuse1
+		M 160000 :1 sub
 
-	test_must_fail git fast-import <input
+		INPUT_END
+
+		test_must_fail git fast-import <input
+	)
 '
 
 ###
-- 
2.56.GIT
Previous: Karthik NayakNext: Karthik Nayak
Message 8 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.