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

Re: [PATCH] tests: use $TEST_DIRECTORY to refer to the t/ directory

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 10, 2008, 07:33 UTC
Message-ID
<7vvdy92ukh.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<489E1FDB.5070700@free.fr>
> OK, I read the diff and found some trivial quoting issues that will break the
> following tests if $TEST_DIRECTORY contain a space:

Thanks. I think this should catch all of them. I've run the tests in a clone that has SP in it.

 t/t4101-apply-nonl.sh |    7 ++++---
 t/t5100-mailinfo.sh   |   17 +++++++++--------
 t/t7500-commit.sh     |   39 +++++++++++++++++++++++++++++----------
 3 files changed, 42 insertions(+), 21 deletions(-)
diff --git a/t/t4101-apply-nonl.sh b/t/t4101-apply-nonl.sh
index 1391d20..e3443d0 100755
--- a/t/t4101-apply-nonl.sh
+++ b/t/t4101-apply-nonl.sh
@@ -21,9 +21,10 @@ do
   do
     test $i -eq $j && continue
     cat frotz.$i >frotz
-    test_expect_success \
-        "apply diff between $i and $j" \
-	"git apply <"$TEST_DIRECTORY"/t4101/diff.$i-$j && diff frotz.$j frotz"
+    test_expect_success "apply diff between $i and $j" '
+	git apply <"$TEST_DIRECTORY"/t4101/diff.$i-$j &&
+	test_cmp frotz.$j frotz
+    '
   done
 done
 
diff --git a/t/t5100-mailinfo.sh b/t/t5100-mailinfo.sh
index a40d48b..c3ab881 100755
--- a/t/t5100-mailinfo.sh
+++ b/t/t5100-mailinfo.sh
@@ -15,20 +15,21 @@ test_expect_success 'split sample box' \
 
 for mail in `echo 00*`
 do
-	test_expect_success "mailinfo $mail" \
-		"git mailinfo -u msg$mail patch$mail <$mail >info$mail &&
+	test_expect_success "mailinfo $mail" '
+		git mailinfo -u msg$mail patch$mail <$mail >info$mail &&
 		echo msg &&
-		diff "$TEST_DIRECTORY"/t5100/msg$mail msg$mail &&
+		test_cmp "$TEST_DIRECTORY"/t5100/msg$mail msg$mail &&
 		echo patch &&
-		diff "$TEST_DIRECTORY"/t5100/patch$mail patch$mail &&
+		test_cmp "$TEST_DIRECTORY"/t5100/patch$mail patch$mail &&
 		echo info &&
-		diff "$TEST_DIRECTORY"/t5100/info$mail info$mail"
+		test_cmp "$TEST_DIRECTORY"/t5100/info$mail info$mail
+	'
 done
 
 test_expect_success 'respect NULs' '
 
 	git mailsplit -d3 -o. "$TEST_DIRECTORY"/t5100/nul-plain &&
-	cmp "$TEST_DIRECTORY"/t5100/nul-plain 001 &&
+	test_cmp "$TEST_DIRECTORY"/t5100/nul-plain 001 &&
 	(cat 001 | git mailinfo msg patch) &&
 	test 4 = $(wc -l < patch)
 
@@ -37,9 +38,9 @@ test_expect_success 'respect NULs' '
 test_expect_success 'Preserve NULs out of MIME encoded message' '
 
 	git mailsplit -d5 -o. "$TEST_DIRECTORY"/t5100/nul-b64.in &&
-	cmp "$TEST_DIRECTORY"/t5100/nul-b64.in 00001 &&
+	test_cmp "$TEST_DIRECTORY"/t5100/nul-b64.in 00001 &&
 	git mailinfo msg patch <00001 &&
-	cmp "$TEST_DIRECTORY"/t5100/nul-b64.expect patch
+	test_cmp "$TEST_DIRECTORY"/t5100/nul-b64.expect patch
 
 '
 
diff --git a/t/t7500-commit.sh b/t/t7500-commit.sh
index 86c1647..7ae0bd0 100755
--- a/t/t7500-commit.sh
+++ b/t/t7500-commit.sh
@@ -46,15 +46,24 @@ test_expect_success 'unedited template with comments should not commit' '
 '
 
 test_expect_success 'a Signed-off-by line by itself should not commit' '
-	! GIT_EDITOR="$TEST_DIRECTORY"/t7500/add-signed-off git commit --template "$TEMPLATE"
+	(
+		test_set_editor "$TEST_DIRECTORY"/t7500/add-signed-off &&
+		test_must_fail git commit --template "$TEMPLATE"
+	)
 '
 
 test_expect_success 'adding comments to a template should not commit' '
-	! GIT_EDITOR="$TEST_DIRECTORY"/t7500/add-comments git commit --template "$TEMPLATE"
+	(
+		test_set_editor "$TEST_DIRECTORY"/t7500/add-comments &&
+		test_must_fail git commit --template "$TEMPLATE"
+	)
 '
 
 test_expect_success 'adding real content to a template should commit' '
-	GIT_EDITOR="$TEST_DIRECTORY"/t7500/add-content git commit --template "$TEMPLATE" &&
+	(
+		test_set_editor "$TEST_DIRECTORY"/t7500/add-content &&
+		git commit --template "$TEMPLATE"
+	) &&
 	commit_msg_is "template linecommit message"
 '
 
@@ -62,7 +71,10 @@ test_expect_success '-t option should be short for --template' '
 	echo "short template" > "$TEMPLATE" &&
 	echo "new content" >> foo &&
 	git add foo &&
-	GIT_EDITOR="$TEST_DIRECTORY"/t7500/add-content git commit -t "$TEMPLATE" &&
+	(
+		test_set_editor "$TEST_DIRECTORY"/t7500/add-content &&
+		git commit -t "$TEMPLATE"
+	) &&
 	commit_msg_is "short templatecommit message"
 '
 
@@ -71,7 +83,10 @@ test_expect_success 'config-specified template should commit' '
 	git config commit.template "$TEMPLATE" &&
 	echo "more content" >> foo &&
 	git add foo &&
-	GIT_EDITOR="$TEST_DIRECTORY"/t7500/add-content git commit &&
+	(
+		test_set_editor "$TEST_DIRECTORY"/t7500/add-content &&
+		git commit
+	) &&
 	git config --unset commit.template &&
 	commit_msg_is "new templatecommit message"
 '
@@ -88,8 +103,10 @@ test_expect_success 'commit message from file should override template' '
 	echo "content galore" >> foo &&
 	git add foo &&
 	echo "standard input msg" |
-		GIT_EDITOR="$TEST_DIRECTORY"/t7500/add-content git commit \
-			--template "$TEMPLATE" --file - &&
+	(
+		test_set_editor "$TEST_DIRECTORY"/t7500/add-content &&
+		git commit --template "$TEMPLATE" --file -
+	) &&
 	commit_msg_is "standard input msg"
 '
 
@@ -132,10 +149,12 @@ EOF
 
 test_expect_success '--signoff' '
 	echo "yet another content *narf*" >> foo &&
-	echo "zort" |
-		GIT_EDITOR="$TEST_DIRECTORY"/t7500/add-content git commit -s -F - foo &&
+	echo "zort" | (
+		test_set_editor "$TEST_DIRECTORY"/t7500/add-content &&
+		git commit -s -F - foo
+	) &&
 	git cat-file commit HEAD | sed "1,/^$/d" > output &&
-	diff expect output
+	test_cmp expect output
 '
 
 test_expect_success 'commit message from file (1)' '
-- 
1.6.0.rc2.22.g71b99
Previous: Junio C HamanoNext: Johannes Schindelin
Message 16 of 26 in “Enable parallelized tests”
  1. 0/3 Enable parallelized testsJohannes Schindelin, Aug 8, 2008
  2. 1/3 t9700: remove useless checkJohannes Schindelin, Aug 8, 2008
  3. 2/3 tests: Clarify dependencies between tests, 'aggregate-results' and 'clean'Johannes Schindelin, Aug 8, 2008
  4. 3/3 Enable parallel testsJohannes Schindelin, Aug 8, 2008
  5. Junio C HamanoAug 8, 2008
  6. Johannes SchindelinAug 8, 2008
  7. Junio C HamanoAug 8, 2008
  8. René ScharfeAug 8, 2008
  9. Junio C HamanoAug 8, 2008
  10. tests: use $TEST_DIRECTORY to refer to the t/ directoryJunio C Hamano, Aug 8, 2008
  11. Johannes SchindelinAug 8, 2008
  12. Junio C HamanoAug 8, 2008
  13. Stephan BeyerAug 8, 2008
  14. Olivier MarinAug 9, 2008
  15. Junio C HamanoAug 9, 2008
  16. Junio C HamanoAug 10, 2008
  17. Johannes SchindelinAug 8, 2008
  18. 3/3 Enable parallel testsJohannes Schindelin, Aug 8, 2008
  19. Stephan BeyerAug 8, 2008
  20. Johannes SchindelinAug 8, 2008
  21. SZEDER GáborAug 8, 2008
  22. Stephan BeyerAug 8, 2008
  23. Johannes SchindelinAug 8, 2008
  24. Stephan BeyerAug 8, 2008
  25. Johannes SchindelinAug 8, 2008
  26. Stephan BeyerAug 8, 2008

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.