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

[PATCH 1/2] t0003: do not chdir the whole test process

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 6, 2014, 18:40 UTC
Message-ID
<1391712033-9443-1-git-send-email-gitster@pobox.com>
In-Reply-To
<xmqqvbwsyvn8.fsf@gitster.dls.corp.google.com>

Moving to some other directory and letting the remainder of the test pieces to expect that they start there is a bad practice. The test that contains chdir itself may fail (or by mistake skipped via the GIT_SKIP_TESTS mechanism) in which case the remainder may operate on files in unexpected places.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 * This is purely a preparatory clean-up in the test script I'll be
   adding a new test to in the next patch.
 t/t0003-attributes.sh | 52 +++++++++++++++++++++++++++++----------------------
 1 file changed, 30 insertions(+), 22 deletions(-)
diff --git a/t/t0003-attributes.sh b/t/t0003-attributes.sh
index febc45c..0554b13 100755
--- a/t/t0003-attributes.sh
+++ b/t/t0003-attributes.sh
@@ -197,39 +197,47 @@ test_expect_success 'root subdir attribute test' '
 '
 
 test_expect_success 'setup bare' '
-	git clone --bare . bare.git &&
-	cd bare.git
+	git clone --bare . bare.git
 '
 
 test_expect_success 'bare repository: check that .gitattribute is ignored' '
 	(
-		echo "f	test=f"
-		echo "a/i test=a/i"
-	) >.gitattributes &&
-	attr_check f unspecified &&
-	attr_check a/f unspecified &&
-	attr_check a/c/f unspecified &&
-	attr_check a/i unspecified &&
-	attr_check subdir/a/i unspecified
+		cd bare.git &&
+		(
+			echo "f	test=f"
+			echo "a/i test=a/i"
+		) >.gitattributes &&
+		attr_check f unspecified &&
+		attr_check a/f unspecified &&
+		attr_check a/c/f unspecified &&
+		attr_check a/i unspecified &&
+		attr_check subdir/a/i unspecified
+	)
 '
 
 test_expect_success 'bare repository: check that --cached honors index' '
-	GIT_INDEX_FILE=../.git/index \
-	git check-attr --cached --stdin --all <../stdin-all |
-	sort >actual &&
-	test_cmp ../specified-all actual
+	(
+		cd bare.git &&
+		GIT_INDEX_FILE=../.git/index \
+		git check-attr --cached --stdin --all <../stdin-all |
+		sort >actual &&
+		test_cmp ../specified-all actual
+	)
 '
 
 test_expect_success 'bare repository: test info/attributes' '
 	(
-		echo "f	test=f"
-		echo "a/i test=a/i"
-	) >info/attributes &&
-	attr_check f f &&
-	attr_check a/f f &&
-	attr_check a/c/f f &&
-	attr_check a/i a/i &&
-	attr_check subdir/a/i unspecified
+		cd bare.git &&
+		(
+			echo "f	test=f"
+			echo "a/i test=a/i"
+		) >info/attributes &&
+		attr_check f f &&
+		attr_check a/f f &&
+		attr_check a/c/f f &&
+		attr_check a/i a/i &&
+		attr_check subdir/a/i unspecified
+	)
 '
 
 test_done
-- 
1.9-rc2-233-ged4ee9f
Previous: Junio C HamanoNext: Junio C Hamano
Message 3 of 13 in “attr.c doesn't honor --work-tree option”
  1. Lasse MakholmFeb 6, 2014
  2. Junio C HamanoFeb 6, 2014
  3. 1/2 t0003: do not chdir the whole test processJunio C Hamano, Feb 6, 2014
  4. 2/2 check-attr: move to the top of working tree when in non-bare repositoryJunio C Hamano, Feb 6, 2014
  5. Jonathan NiederFeb 6, 2014
  6. Jonathan NiederFeb 6, 2014
  7. Junio C HamanoFeb 6, 2014
  8. Michael HaggertyFeb 16, 2014
  9. Jonathan NiederFeb 6, 2014
  10. Junio C HamanoFeb 6, 2014
  11. Jonathan NiederFeb 6, 2014
  12. Junio C HamanoFeb 6, 2014
  13. Lasse MakholmFeb 10, 2014

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.