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

[PATCH v2 13/20] t9300: make the marks 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-13-b8c3a0ab27e8@gmail.com>
In-Reply-To
<20261112-kn-fast-import-tests-1-v2-0-b8c3a0ab27e8@gmail.com>

Similar to the previous commits, modify the marks tests to make them independent of state from previous tests.

Several tests import the marks file written by an earlier test. Add a 'create_marks_file()' function which writes one, with marks for commits and tags too, so each test can invoke it in its own repository.

'R: feature import-marks-if-exists' writes a marks file pointing to a blob it never stores, relying on an earlier test having written it. Write the blob in the test itself. Also run 'A: export marks with large values' in its own repository.

Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
---
 t/t9300-fast-import.sh | 512 +++++++++++++++++++++++++++++++------------------
 1 file changed, 322 insertions(+), 190 deletions(-)
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index 5b8550584e..1022299b7d 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -298,59 +298,65 @@ test_expect_success 'A: verify diff' '
 '
 
 test_expect_success 'A: export marks with large values' '
-	test_tick &&
-	mt=$(git hash-object --stdin < /dev/null) &&
-	>input.blob &&
-	>marks.exp &&
-	>tree.exp &&
+	test_when_finished "rm -rf repo" &&
+	git init repo &&
+	(
+		cd repo &&
 
-	cat >input.commit <<-EOF &&
-	commit refs/heads/verify--dump-marks
-	committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-	data <<COMMIT
-	test the sparse array dumping routines with exponentially growing marks
-	COMMIT
-	EOF
+		test_tick &&
+		mt=$(git hash-object --stdin < /dev/null) &&
+		>input.blob &&
+		>marks.exp &&
+		>tree.exp &&
 
-	i=0 l=4 m=6 n=7 &&
-	while test "$i" -lt 27
-	do
-		cat >>input.blob <<-EOF &&
-		blob
-		mark :$l
-		data 0
-		blob
-		mark :$m
-		data 0
-		blob
-		mark :$n
-		data 0
+		cat >input.commit <<-EOF &&
+		commit refs/heads/verify--dump-marks
+		committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+		data <<COMMIT
+		test the sparse array dumping routines with exponentially growing marks
+		COMMIT
 		EOF
-		echo "M 100644 :$l l$i" >>input.commit &&
-		echo "M 100644 :$m m$i" >>input.commit &&
-		echo "M 100644 :$n n$i" >>input.commit &&
 
-		echo ":$l $mt" >>marks.exp &&
-		echo ":$m $mt" >>marks.exp &&
-		echo ":$n $mt" >>marks.exp &&
+		i=0 l=4 m=6 n=7 &&
+		while test "$i" -lt 27
+		do
+			cat >>input.blob <<-EOF &&
+			blob
+			mark :$l
+			data 0
+			blob
+			mark :$m
+			data 0
+			blob
+			mark :$n
+			data 0
+			EOF
+			echo "M 100644 :$l l$i" >>input.commit &&
+			echo "M 100644 :$m m$i" >>input.commit &&
+			echo "M 100644 :$n n$i" >>input.commit &&
 
-		printf "100644 blob $mt\tl$i\n" >>tree.exp &&
-		printf "100644 blob $mt\tm$i\n" >>tree.exp &&
-		printf "100644 blob $mt\tn$i\n" >>tree.exp &&
+			echo ":$l $mt" >>marks.exp &&
+			echo ":$m $mt" >>marks.exp &&
+			echo ":$n $mt" >>marks.exp &&
 
-		l=$(($l + $l)) &&
-		m=$(($m + $m)) &&
-		n=$(($l + $n)) &&
+			printf "100644 blob $mt\tl$i\n" >>tree.exp &&
+			printf "100644 blob $mt\tm$i\n" >>tree.exp &&
+			printf "100644 blob $mt\tn$i\n" >>tree.exp &&
 
-		i=$((1 + $i)) || return 1
-	done &&
+			l=$(($l + $l)) &&
+			m=$(($m + $m)) &&
+			n=$(($l + $n)) &&
 
-	sort tree.exp > tree.exp_s &&
+			i=$((1 + $i)) || return 1
+		done &&
 
-	cat input.blob input.commit | git fast-import --export-marks=marks.large &&
-	git ls-tree refs/heads/verify--dump-marks >tree.out &&
-	test_cmp tree.exp_s tree.out &&
-	test_cmp marks.exp marks.large
+		sort tree.exp > tree.exp_s &&
+
+		cat input.blob input.commit | git fast-import --export-marks=marks.large &&
+		git ls-tree refs/heads/verify--dump-marks >tree.out &&
+		test_cmp tree.exp_s tree.out &&
+		test_cmp marks.exp marks.large
+	)
 '
 
 ###
@@ -2681,32 +2687,44 @@ test_expect_success 'R: export-marks feature forbidden by default' '
 '
 
 test_expect_success 'R: export-marks feature results in a marks file being created' '
-	cat >input <<-EOF &&
-	feature export-marks=git.marks
-	blob
-	mark :1
-	data 3
-	hi
+	test_when_finished "rm -rf repo" &&
+	git init repo &&
+	(
+		cd repo &&
 
-	EOF
+		cat >input <<-EOF &&
+		feature export-marks=git.marks
+		blob
+		mark :1
+		data 3
+		hi
 
-	git fast-import --allow-unsafe-features <input &&
-	test_grep :1 git.marks
+		EOF
+
+		git fast-import --allow-unsafe-features <input &&
+		test_grep :1 git.marks
+	)
 '
 
 test_expect_success 'R: export-marks options can be overridden by commandline options' '
-	cat >input <<-\EOF &&
-	feature export-marks=feature-sub/git.marks
-	blob
-	mark :1
-	data 3
-	hi
+	test_when_finished "rm -rf repo" &&
+	git init repo &&
+	(
+		cd repo &&
 
-	EOF
-	git fast-import --allow-unsafe-features \
-			--export-marks=cmdline-sub/other.marks <input &&
-	test_grep :1 cmdline-sub/other.marks &&
-	test_path_is_missing feature-sub
+		cat >input <<-\EOF &&
+		feature export-marks=feature-sub/git.marks
+		blob
+		mark :1
+		data 3
+		hi
+
+		EOF
+		git fast-import --allow-unsafe-features \
+				--export-marks=cmdline-sub/other.marks <input &&
+		test_grep :1 cmdline-sub/other.marks &&
+		test_path_is_missing feature-sub
+	)
 '
 
 test_expect_success 'R: --allow-unsafe-features found after a value' '
@@ -2746,167 +2764,275 @@ test_expect_success 'R: --allow-unsafe-features after a non-option' '
 '
 
 test_expect_success 'R: catch typo in marks file name' '
-	test_must_fail git fast-import --import-marks=nonexistent.marks </dev/null &&
-	echo "feature import-marks=nonexistent.marks" |
-	test_must_fail git fast-import --allow-unsafe-features
+	test_when_finished "rm -rf repo" &&
+	git init repo &&
+	(
+		cd repo &&
+
+		test_must_fail git fast-import --import-marks=nonexistent.marks </dev/null &&
+		echo "feature import-marks=nonexistent.marks" |
+		test_must_fail git fast-import --allow-unsafe-features
+	)
 '
 
 test_expect_success 'R: import and output marks can be the same file' '
-	rm -f io.marks &&
-	blob=$(echo hi | git hash-object --stdin) &&
-	cat >expect <<-EOF &&
-	:1 $blob
-	:2 $blob
-	EOF
-	git fast-import --export-marks=io.marks <<-\EOF &&
-	blob
-	mark :1
-	data 3
-	hi
+	test_when_finished "rm -rf repo" &&
+	git init repo &&
+	(
+		cd repo &&
 
-	EOF
-	git fast-import --import-marks=io.marks --export-marks=io.marks <<-\EOF &&
-	blob
-	mark :2
-	data 3
-	hi
+		rm -f io.marks &&
+		blob=$(echo hi | git hash-object --stdin) &&
+		cat >expect <<-EOF &&
+		:1 $blob
+		:2 $blob
+		EOF
+		git fast-import --export-marks=io.marks <<-\EOF &&
+		blob
+		mark :1
+		data 3
+		hi
 
-	EOF
-	test_cmp expect io.marks
+		EOF
+		git fast-import --import-marks=io.marks --export-marks=io.marks <<-\EOF &&
+		blob
+		mark :2
+		data 3
+		hi
+
+		EOF
+		test_cmp expect io.marks
+	)
 '
 
 test_expect_success 'R: --import-marks=foo --output-marks=foo to create foo fails' '
-	rm -f io.marks &&
-	test_must_fail git fast-import --import-marks=io.marks --export-marks=io.marks <<-\EOF
-	blob
-	mark :1
-	data 3
-	hi
+	test_when_finished "rm -rf repo" &&
+	git init repo &&
+	(
+		cd repo &&
 
-	EOF
+		rm -f io.marks &&
+		test_must_fail git fast-import --import-marks=io.marks --export-marks=io.marks <<-\EOF
+		blob
+		mark :1
+		data 3
+		hi
+
+		EOF
+	)
 '
 
 test_expect_success 'R: --import-marks-if-exists' '
-	rm -f io.marks &&
-	blob=$(echo hi | git hash-object --stdin) &&
-	echo ":1 $blob" >expect &&
-	git fast-import --import-marks-if-exists=io.marks --export-marks=io.marks <<-\EOF &&
-	blob
-	mark :1
-	data 3
-	hi
+	test_when_finished "rm -rf repo" &&
+	git init repo &&
+	(
+		cd repo &&
 
-	EOF
-	test_cmp expect io.marks
+		rm -f io.marks &&
+		blob=$(echo hi | git hash-object --stdin) &&
+		echo ":1 $blob" >expect &&
+		git fast-import --import-marks-if-exists=io.marks --export-marks=io.marks <<-\EOF &&
+		blob
+		mark :1
+		data 3
+		hi
+
+		EOF
+		test_cmp expect io.marks
+	)
 '
 
 test_expect_success 'R: feature import-marks-if-exists' '
-	rm -f io.marks &&
+	test_when_finished "rm -rf repo" &&
+	git init repo &&
+	(
+		cd repo &&
 
-	git fast-import --export-marks=io.marks \
-			--allow-unsafe-features <<-\EOF &&
-	feature import-marks-if-exists=not_io.marks
-	EOF
-	test_must_be_empty io.marks &&
+		rm -f io.marks &&
 
-	blob=$(echo hi | git hash-object --stdin) &&
+		git fast-import --export-marks=io.marks \
+				--allow-unsafe-features <<-\EOF &&
+		feature import-marks-if-exists=not_io.marks
+		EOF
+		test_must_be_empty io.marks &&
 
-	echo ":1 $blob" >io.marks &&
-	echo ":1 $blob" >expect &&
-	echo ":2 $blob" >>expect &&
+		blob=$(echo hi | git hash-object -w --stdin) &&
 
-	git fast-import --export-marks=io.marks \
-			--allow-unsafe-features <<-\EOF &&
-	feature import-marks-if-exists=io.marks
-	blob
-	mark :2
-	data 3
-	hi
+		echo ":1 $blob" >io.marks &&
+		echo ":1 $blob" >expect &&
+		echo ":2 $blob" >>expect &&
 
-	EOF
-	test_cmp expect io.marks &&
+		git fast-import --export-marks=io.marks \
+				--allow-unsafe-features <<-\EOF &&
+		feature import-marks-if-exists=io.marks
+		blob
+		mark :2
+		data 3
+		hi
 
-	echo ":3 $blob" >>expect &&
+		EOF
+		test_cmp expect io.marks &&
 
-	git fast-import --import-marks=io.marks \
-			--export-marks=io.marks \
-			--allow-unsafe-features <<-\EOF &&
-	feature import-marks-if-exists=not_io.marks
-	blob
-	mark :3
-	data 3
-	hi
+		echo ":3 $blob" >>expect &&
 
-	EOF
-	test_cmp expect io.marks &&
+		git fast-import --import-marks=io.marks \
+				--export-marks=io.marks \
+				--allow-unsafe-features <<-\EOF &&
+		feature import-marks-if-exists=not_io.marks
+		blob
+		mark :3
+		data 3
+		hi
 
-	git fast-import --import-marks-if-exists=not_io.marks \
-			--export-marks=io.marks \
-			--allow-unsafe-features <<-\EOF &&
-	feature import-marks-if-exists=io.marks
-	EOF
-	test_must_be_empty io.marks
+		EOF
+		test_cmp expect io.marks &&
+
+		git fast-import --import-marks-if-exists=not_io.marks \
+				--export-marks=io.marks \
+				--allow-unsafe-features <<-\EOF &&
+		feature import-marks-if-exists=io.marks
+		EOF
+		test_must_be_empty io.marks
+	)
 '
 
-test_expect_success 'R: import to output marks works without any content' '
-	cat >input <<-EOF &&
-	feature import-marks=marks.out
-	feature export-marks=marks.new
-	EOF
+create_marks_file () {
+	git fast-import --export-marks="$1" <<-EOF
+	blob
+	mark :1
+	data 4
+	one
 
-	git fast-import --allow-unsafe-features <input &&
-	test_cmp marks.out marks.new
+	blob
+	mark :2
+	data 4
+	two
+
+	blob
+	mark :3
+	data 6
+	three
+
+	blob
+	mark :4
+	data 5
+	four
+
+	commit refs/heads/marks
+	mark :5
+	committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+	data <<COMMIT
+	commit with a mark
+	COMMIT
+	M 100644 :1 one
+
+	tag marks-tag
+	mark :6
+	from :5
+	tagger $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+	data <<TAG
+	tag with a mark
+	TAG
+
+	EOF
+}
+
+test_expect_success 'R: import to output marks works without any content' '
+	test_when_finished "rm -rf repo" &&
+	git init repo &&
+	(
+		cd repo &&
+		create_marks_file marks.out &&
+
+		cat >input <<-EOF &&
+		feature import-marks=marks.out
+		feature export-marks=marks.new
+		EOF
+
+		git fast-import --allow-unsafe-features <input &&
+		test_cmp marks.out marks.new
+	)
 '
 
 test_expect_success 'R: import marks prefers commandline marks file over the stream' '
-	cat >input <<-EOF &&
-	feature import-marks=nonexistent.marks
-	feature export-marks=marks.new
-	EOF
+	test_when_finished "rm -rf repo" &&
+	git init repo &&
+	(
+		cd repo &&
+		create_marks_file marks.out &&
 
-	git fast-import --import-marks=marks.out --allow-unsafe-features <input &&
-	test_cmp marks.out marks.new
+		cat >input <<-EOF &&
+		feature import-marks=nonexistent.marks
+		feature export-marks=marks.new
+		EOF
+
+		git fast-import --import-marks=marks.out --allow-unsafe-features <input &&
+		test_cmp marks.out marks.new
+	)
 '
 
-
 test_expect_success 'R: multiple --import-marks= should be honoured' '
-	cat >input <<-EOF &&
-	feature import-marks=nonexistent.marks
-	feature export-marks=combined.marks
-	EOF
+	test_when_finished "rm -rf repo" &&
+	git init repo &&
+	(
+		cd repo &&
+		create_marks_file marks.out &&
 
-	head -n2 marks.out > one.marks &&
-	tail -n +3 marks.out > two.marks &&
-	git fast-import --import-marks=one.marks --import-marks=two.marks \
-		--allow-unsafe-features <input &&
-	test_cmp marks.out combined.marks
+		cat >input <<-EOF &&
+		feature import-marks=nonexistent.marks
+		feature export-marks=combined.marks
+		EOF
+
+		head -n2 marks.out >one.marks &&
+		tail -n +3 marks.out >two.marks &&
+		git fast-import --import-marks=one.marks --import-marks=two.marks \
+			--allow-unsafe-features <input &&
+		test_cmp marks.out combined.marks
+	)
 '
 
 test_expect_success 'R: feature relative-marks should be honoured' '
-	cat >input <<-EOF &&
-	feature relative-marks
-	feature import-marks=relative.in
-	feature export-marks=relative.out
-	EOF
+	test_when_finished "rm -rf repo" &&
+	git init repo &&
+	(
+		cd repo &&
+		create_marks_file marks.out &&
 
-	mkdir -p .git/info/fast-import/ &&
-	cp marks.new .git/info/fast-import/relative.in &&
-	git fast-import --allow-unsafe-features <input &&
-	test_cmp marks.new .git/info/fast-import/relative.out
+		cat >input <<-EOF &&
+		feature relative-marks
+		feature import-marks=relative.in
+		feature export-marks=relative.out
+		EOF
+
+		mkdir -p .git/info/fast-import/ &&
+		cp marks.out .git/info/fast-import/relative.in &&
+		git fast-import --allow-unsafe-features <input &&
+		test_cmp marks.out .git/info/fast-import/relative.out
+	)
 '
 
 test_expect_success 'R: feature no-relative-marks should be honoured' '
-	cat >input <<-EOF &&
-	feature relative-marks
-	feature import-marks=relative.in
-	feature no-relative-marks
-	feature export-marks=non-relative.out
-	EOF
+	test_when_finished "rm -rf repo" &&
+	git init repo &&
+	(
+		cd repo &&
+		create_marks_file marks.out &&
 
-	git fast-import --allow-unsafe-features <input &&
-	test_cmp marks.new non-relative.out
+		cat >input <<-EOF &&
+		feature relative-marks
+		feature import-marks=relative.in
+		feature no-relative-marks
+		feature export-marks=non-relative.out
+		EOF
+
+		mkdir -p .git/info/fast-import/ &&
+		cp marks.out .git/info/fast-import/relative.in &&
+		git fast-import --allow-unsafe-features <input &&
+		test_cmp marks.out non-relative.out
+	)
 '
 
+
 test_expect_success 'R: feature ls supported' '
 	echo "feature ls" |
 	git fast-import
@@ -3252,18 +3378,24 @@ test_expect_success 'R: ignore non-git options' '
 '
 
 test_expect_success 'R: corrupt lines do not mess marks file' '
-	rm -f io.marks &&
-	blob=$(echo hi | git hash-object --stdin) &&
-	cat >expect <<-EOF &&
-	:3 $ZERO_OID
-	:1 $blob
-	:2 $blob
-	EOF
-	cp expect io.marks &&
-	test_must_fail git fast-import --import-marks=io.marks --export-marks=io.marks <<-\EOF &&
+	test_when_finished "rm -rf repo" &&
+	git init repo &&
+	(
+		cd repo &&
 
-	EOF
-	test_cmp expect io.marks
+		rm -f io.marks &&
+		blob=$(echo hi | git hash-object --stdin) &&
+		cat >expect <<-EOF &&
+		:3 $ZERO_OID
+		:1 $blob
+		:2 $blob
+		EOF
+		cp expect io.marks &&
+		test_must_fail git fast-import --import-marks=io.marks --export-marks=io.marks <<-\EOF &&
+
+		EOF
+		test_cmp expect io.marks
+	)
 '
 
 ##
-- 
2.56.GIT
Previous: Karthik NayakNext: Karthik Nayak
Message 38 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.