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

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

The tests import on top of 'branch' and compare the result against the 'N3' commit from series N. Import on top of a commit created by the new 'setup_import_repo()' function instead, and compare the result against the same commit imported from a stream without comments and with blank lines, so that the whole commit is still checked and not just its tree. The function sets 'fastimport.unpackLimit' to 0, which 'O: blank lines not necessary after other commands' relies on.

Drop the 'O: repack before next test' test, and repack in the test which relies on it.

Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
---
 t/t9300-fast-import.sh | 291 +++++++++++++++++++++++++++++++------------------
 1 file changed, 182 insertions(+), 109 deletions(-)
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index 480ae2c47f..75c2de46ed 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -1723,143 +1723,216 @@ done
 ### series O
 ###
 
-test_expect_success 'O: comments are all skipped' '
-	cat >input <<-INPUT_END &&
-	#we will
-	commit refs/heads/O1
-	# -- ignore all of this text
+setup_import_repo () {
+	test_when_finished "rm -rf repo" &&
+	git init repo &&
+	git -C repo config fastimport.unpackLimit 0 &&
+	mkdir repo/file2 &&
+	echo abcd >repo/file2/file4 &&
+	git -C repo add file2/file4 &&
+	test_tick &&
+	git -C repo commit -m base
+}
+
+import_reference_commit () {
+	git fast-import <<-INPUT_END
+	commit refs/heads/$1
 	committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
 	data <<COMMIT
 	dirty directory copy
 	COMMIT
 
-	# do not forget the import blank line!
-	#
-	# yes, we started from our usual base of branch^0.
-	# i like branch^0.
-	from refs/heads/branch^0
-	# and we need to reuse file2/file5 from N3 above.
+	from refs/heads/main
 	M 644 inline file2/file5
-	# otherwise the tree will be different
 	data <<EOF
-	$file5_data
+	an inline file.
+	  we should see it later.
 	EOF
 
-	# do not forget to copy file2 to file3
 	C file2 file3
-	#
-	# or to delete file5 from file2.
 	D file2/file5
-	# are we done yet?
 
 	INPUT_END
+}
 
-	git fast-import <input &&
-	test $(git rev-parse N3) = $(git rev-parse O1)
+test_expect_success 'O: comments are all skipped' '
+	setup_import_repo &&
+	(
+		cd repo &&
+
+		cat >input <<-INPUT_END &&
+		#we will
+		commit refs/heads/O1
+		# -- ignore all of this text
+		committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+		data <<COMMIT
+		dirty directory copy
+		COMMIT
+
+		# do not forget the import blank line!
+		#
+		# yes, we started from our usual base of main.
+		# i like main.
+		from refs/heads/main
+		# and we need to add file2/file5 to file2.
+		M 644 inline file2/file5
+		# otherwise the tree will be different
+		data <<EOF
+		an inline file.
+		  we should see it later.
+		EOF
+
+		# do not forget to copy file2 to file3
+		C file2 file3
+		#
+		# or to delete file5 from file2.
+		D file2/file5
+		# are we done yet?
+
+		INPUT_END
+
+		git fast-import <input &&
+		blob4=$(echo abcd | git hash-object --stdin) &&
+		blob5=$(printf "an inline file.\n  we should see it later.\n" | git hash-object --stdin) &&
+		cat >expect <<-EOF &&
+		100644 blob $blob4	file2/file4
+		100644 blob $blob4	file3/file4
+		100644 blob $blob5	file3/file5
+		EOF
+		git ls-tree -r O1 >actual &&
+		test_cmp expect actual &&
+
+		import_reference_commit O1-reference &&
+		test_cmp_rev O1-reference O1
+	)
 '
 
 test_expect_success 'O: blank lines not necessary after data commands' '
-	cat >input <<-INPUT_END &&
-	commit refs/heads/O2
-	committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-	data <<COMMIT
-	dirty directory copy
-	COMMIT
-	from refs/heads/branch^0
-	M 644 inline file2/file5
-	data <<EOF
-	$file5_data
-	EOF
-	C file2 file3
-	D file2/file5
+	setup_import_repo &&
+	(
+		cd repo &&
 
-	INPUT_END
+		cat >input <<-INPUT_END &&
+		commit refs/heads/O2
+		committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+		data <<COMMIT
+		dirty directory copy
+		COMMIT
+		from refs/heads/main
+		M 644 inline file2/file5
+		data <<EOF
+		an inline file.
+		  we should see it later.
+		EOF
+		C file2 file3
+		D file2/file5
 
-	git fast-import <input &&
-	test $(git rev-parse N3) = $(git rev-parse O2)
-'
+		INPUT_END
 
-test_expect_success 'O: repack before next test' '
-	git repack -a -d
+		git fast-import <input &&
+		blob4=$(echo abcd | git hash-object --stdin) &&
+		blob5=$(printf "an inline file.\n  we should see it later.\n" | git hash-object --stdin) &&
+		cat >expect <<-EOF &&
+		100644 blob $blob4	file2/file4
+		100644 blob $blob4	file3/file4
+		100644 blob $blob5	file3/file5
+		EOF
+		git ls-tree -r O2 >actual &&
+		test_cmp expect actual &&
+
+		import_reference_commit O2-reference &&
+		test_cmp_rev O2-reference O2
+	)
 '
 
 test_expect_success 'O: blank lines not necessary after other commands' '
-	cat >input <<-INPUT_END &&
-	commit refs/heads/O3
-	committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-	data <<COMMIT
-	zstring
-	COMMIT
-	commit refs/heads/O3
-	committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-	data <<COMMIT
-	zof
-	COMMIT
-	checkpoint
-	commit refs/heads/O3
-	mark :5
-	committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-	data <<COMMIT
-	zempty
-	COMMIT
-	checkpoint
-	commit refs/heads/O3
-	committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-	data <<COMMIT
-	zcommits
-	COMMIT
-	reset refs/tags/O3-2nd
-	from :5
-	reset refs/tags/O3-3rd
-	from :5
-	INPUT_END
+	setup_import_repo &&
+	(
+		cd repo &&
+		git repack -a -d &&
 
-	cat >expect <<-INPUT_END &&
-	string
-	of
-	empty
-	commits
-	INPUT_END
+		cat >input <<-INPUT_END &&
+		commit refs/heads/O3
+		committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+		data <<COMMIT
+		zstring
+		COMMIT
+		commit refs/heads/O3
+		committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+		data <<COMMIT
+		zof
+		COMMIT
+		checkpoint
+		commit refs/heads/O3
+		mark :5
+		committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+		data <<COMMIT
+		zempty
+		COMMIT
+		checkpoint
+		commit refs/heads/O3
+		committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+		data <<COMMIT
+		zcommits
+		COMMIT
+		reset refs/tags/O3-2nd
+		from :5
+		reset refs/tags/O3-3rd
+		from :5
+		INPUT_END
 
-	git fast-import <input &&
-	ls -la .git/objects/pack/pack-*.pack >packlist &&
-	ls -la .git/objects/pack/pack-*.pack >idxlist &&
-	test_line_count = 4 idxlist &&
-	test_line_count = 4 packlist &&
-	test $(git rev-parse refs/tags/O3-2nd) = $(git rev-parse O3^) &&
-	git log --reverse --pretty=oneline O3 | sed s/^.*z// >actual &&
-	test_cmp expect actual
+		cat >expect <<-INPUT_END &&
+		string
+		of
+		empty
+		commits
+		INPUT_END
+
+		git fast-import <input &&
+		ls -la .git/objects/pack/pack-*.pack >packlist &&
+		ls -la .git/objects/pack/pack-*.pack >idxlist &&
+		test_line_count = 4 idxlist &&
+		test_line_count = 4 packlist &&
+		test $(git rev-parse refs/tags/O3-2nd) = $(git rev-parse O3^) &&
+		git log --reverse --pretty=oneline O3 | sed s/^.*z// >actual &&
+		test_cmp expect actual
+	)
 '
 
 test_expect_success 'O: progress outputs as requested by input' '
-	cat >input <<-INPUT_END &&
-	commit refs/heads/O4
-	committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-	data <<COMMIT
-	zstring
-	COMMIT
-	commit refs/heads/O4
-	committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-	data <<COMMIT
-	zof
-	COMMIT
-	progress Two commits down, 2 to go!
-	commit refs/heads/O4
-	committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-	data <<COMMIT
-	zempty
-	COMMIT
-	progress Three commits down, 1 to go!
-	commit refs/heads/O4
-	committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-	data <<COMMIT
-	zcommits
-	COMMIT
-	progress done!
-	INPUT_END
-	git fast-import <input >actual &&
-	grep "progress " <input >expect &&
-	test_cmp expect actual
+	setup_import_repo &&
+	(
+		cd repo &&
+
+		cat >input <<-INPUT_END &&
+		commit refs/heads/O4
+		committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+		data <<COMMIT
+		zstring
+		COMMIT
+		commit refs/heads/O4
+		committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+		data <<COMMIT
+		zof
+		COMMIT
+		progress Two commits down, 2 to go!
+		commit refs/heads/O4
+		committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+		data <<COMMIT
+		zempty
+		COMMIT
+		progress Three commits down, 1 to go!
+		commit refs/heads/O4
+		committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+		data <<COMMIT
+		zcommits
+		COMMIT
+		progress done!
+		INPUT_END
+		git fast-import <input >actual &&
+		grep "progress " <input >expect &&
+		test_cmp expect actual
+	)
 '
 
 ###
-- 
2.56.GIT
Previous: Karthik NayakNext: Karthik Nayak
Message 9 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.