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

[PATCH 18/20] t9300: make the get-mark and encoding tests self-contained

From
Karthik Nayak <karthik.188@gmail.com>
Date
Nov 10, 2026, 11:50 UTC
Message-ID
<20261110-kn-fast-import-tests-1-v1-18-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 W' and 'X: handling encoding' to make them independent of state from previous tests.

The 'W' tests read the 'W-input' file written at the top level of the script, which is not in the new repository. Turn it into a 'w_input()' function which prints the stream.

'X: replace ref that becomes useless is removed' changes its working directory and doesn't change back, so the tests after it, run in that repository. Move the 'cd' into the subshell, and cleanup when the test completes.

Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
---
 t/t9300-fast-import.sh | 81 +++++++++++++++++++++++++++++++++++---------------
 1 file changed, 57 insertions(+), 24 deletions(-)
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index c719b2115e..09cd2c5bf3 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -4503,7 +4503,8 @@ test_expect_success PIPE 'V: checkpoint updates tags after tag' '
 ### series W (get-mark and empty orphan commits)
 ###
 
-cat >>W-input <<-W_INPUT_END
+w_input () {
+	cat <<-W_INPUT_END
 	commit refs/heads/W-branch
 	mark :1
 	author Full Name <user@company.tld> 1000000000 +0100
@@ -4512,28 +4513,53 @@ cat >>W-input <<-W_INPUT_END
 	Intentionally empty commit
 	LFsget-mark :1
 	W_INPUT_END
+}
 
 test_expect_success !MINGW 'W: get-mark & empty orphan commit with no newlines' '
-	sed -e s/LFs// W-input | tr L "\n" | git fast-import
+	test_when_finished "rm -rf repo" &&
+	git init repo &&
+	(
+		cd repo &&
+
+		w_input | sed -e s/LFs// | tr L "\n" | git fast-import
+	)
 '
 
 test_expect_success !MINGW 'W: get-mark & empty orphan commit with one newline' '
-	sed -e s/LFs/L/ W-input | tr L "\n" | git fast-import
+	test_when_finished "rm -rf repo" &&
+	git init repo &&
+	(
+		cd repo &&
+
+		w_input | sed -e s/LFs/L/ | tr L "\n" | git fast-import
+	)
 '
 
 test_expect_success !MINGW 'W: get-mark & empty orphan commit with ugly second newline' '
-	# Technically, this should fail as it has too many linefeeds
-	# according to the grammar in fast-import.txt.  But, for whatever
-	# reason, it works.  Since using the correct number of newlines
-	# does not work with older (pre-2.22) versions of git, allow apps
-	# that used this second-newline workaround to keep working by
-	# checking it with this test...
-	sed -e s/LFs/LL/ W-input | tr L "\n" | git fast-import
+	test_when_finished "rm -rf repo" &&
+	git init repo &&
+	(
+		cd repo &&
+
+		# Technically, this should fail as it has too many linefeeds
+		# according to the grammar in fast-import.txt.  But, for whatever
+		# reason, it works.  Since using the correct number of newlines
+		# does not work with older (pre-2.22) versions of git, allow apps
+		# that used this second-newline workaround to keep working by
+		# checking it with this test...
+		w_input | sed -e s/LFs/LL/ | tr L "\n" | git fast-import
+	)
 '
 
 test_expect_success !MINGW 'W: get-mark & empty orphan commit with erroneous third newline' '
-	# ...but do NOT allow more empty lines than that (see previous test).
-	sed -e s/LFs/LLL/ W-input | tr L "\n" | test_must_fail git fast-import
+	test_when_finished "rm -rf repo" &&
+	git init repo &&
+	(
+		cd repo &&
+
+		# ...but do NOT allow more empty lines than that (see previous test).
+		w_input | sed -e s/LFs/LLL/ | tr L "\n" | test_must_fail git fast-import
+	)
 '
 
 ###
@@ -4541,25 +4567,32 @@ test_expect_success !MINGW 'W: get-mark & empty orphan commit with erroneous thi
 ###
 
 test_expect_success ICONV 'X: handling encoding' '
-	test_tick &&
-	cat >input <<-INPUT_END &&
-	commit refs/heads/encoding
-	committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
-	encoding iso-8859-7
-	data <<COMMIT
-	INPUT_END
+	test_when_finished "rm -rf repo" &&
+	git init repo &&
+	(
+		cd repo &&
 
-	printf "Pi: \360\nCOMMIT\n" >>input &&
+		test_tick &&
+		cat >input <<-INPUT_END &&
+		commit refs/heads/encoding
+		committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+		encoding iso-8859-7
+		data <<COMMIT
+		INPUT_END
 
-	git fast-import <input &&
-	git cat-file -p encoding | grep $(printf "\360") &&
-	git log -1 --format=%B encoding | grep $(printf "\317\200")
+		printf "Pi: \360\nCOMMIT\n" >>input &&
+
+		git fast-import <input &&
+		git cat-file -p encoding | grep $(printf "\360") &&
+		git log -1 --format=%B encoding | grep $(printf "\317\200")
+	)
 '
 
 test_expect_success 'X: replace ref that becomes useless is removed' '
+	test_when_finished "rm -rf testrepo" &&
 	git init -qb main testrepo &&
-	cd testrepo &&
 	(
+		cd testrepo &&
 		test_commit test &&
 
 		test_commit msg somename content &&
-- 
2.56.GIT
Previous: Karthik NayakNext: Karthik Nayak
Message 19 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.