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

Re: [PATCH] Several tests: cd inside subshell instead of around

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Sep 7, 2010, 02:37 UTC
Message-ID
<20100907023713.GJ1182@burratino>
In-Reply-To
<7vhbi2tqd0.fsf@alter.siamese.dyndns.org>
Junio C Hamano wrote:
> If we were to insist that no matter how an individual test fail, the test
> that follows it must start in a known location (namely, $TRASH), then we
> might want to use something like the attached patch.
I like it.  Affected test scripts:
  t0003-attributes.sh		t0050-filesystem.sh
  t1007-hash-object.sh		t1020-subdirectory.sh
  t1301-shared-repo.sh		t1500-rev-parse.sh
  t1501-worktree.sh		t1504-ceiling-dirs.sh
  t2050-git-dir-relative.sh	t2300-cd-to-toplevel.sh
  t3407-rebase-abort.sh		t4119-apply-config.sh
  t5300-pack-object.sh		t5404-tracking-branches.sh
  t5406-remote-rejects.sh	t5510-fetch.sh
  t5515-fetch-merge-logic.sh	t5520-pull.sh
  t5530-upload-pack-error.sh	t5600-clone-fail-cleanup.sh
  t5700-clone-reference.sh	t5701-clone-local.sh
  t5710-info-alternate.sh	t6029-merge-subtree.sh
  t7001-mv.sh			t7103-reset-bare.sh
  t7400-submodule-basic.sh	t7401-submodule-summary.sh
  t7408-submodule-reference.sh	t7610-mergetool.sh
  t9101-git-svn-props.sh	t9103-git-svn-tracked-directory-removed.sh
  t9113-git-svn-dcommit-new-file.sh
  t9115-git-svn-dcommit-funky-renames.sh
  t9117-git-svn-init-clone.sh
  t9137-git-svn-dcommit-clobber-series.sh
  t9400-git-cvsserver-server.sh
and probably some others.
What is the ",$(pwd)" for?
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 29fd720..90ed4d9 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -370,6 +370,11 @@ test_debug () {
 }
 
 test_run_ () {
+	if test ",$(pwd)" != ",$TRASH_DIRECTORY"
+	then
+		error "bug in test script: starting from a different directory"
+	fi
+
 	test_cleanup=:
 	eval >&3 2>&4 "$1"
 	eval_ret=$?
@@ -377,6 +382,11 @@ test_run_ () {
 	if test "$verbose" = "t" && test -n "$HARNESS_ACTIVE"; then
 		echo ""
 	fi
+
+	if test ",$(pwd)" != ",$TRASH_DIRECTORY"
+	then
+		error "bug in test script: moved to a different directory"
+	fi
 	return 0
 }
 
Previous: Junio C HamanoNext: Junio C Hamano
Message 24 of 27 in “Several tests: cd inside subshell instead of around”
  1. Several tests: cd inside subshell instead of aroundJens Lehmann, Sep 6, 2010
  2. Jonathan NiederSep 6, 2010
  3. Jens LehmannSep 6, 2010
  4. 0/7 Re: [PATCH] Several tests: cd inside subshell instead of aroundJonathan Nieder, Sep 7, 2010
  5. 1/7 tests: subshell indentation stylefixJonathan Nieder, Sep 7, 2010
  6. Jonathan NiederSep 7, 2010
  7. 2/7 t1450 (fsck): remove dangling objectsJonathan Nieder, Sep 7, 2010
  8. 3/7 t2105 (gitfile): add missing &&Jonathan Nieder, Sep 7, 2010
  9. Brad KingSep 7, 2010
  10. 4/7 t0004 (unwritable files): simplify error handlingJonathan Nieder, Sep 7, 2010
  11. 5/7 t1302 (core.repositoryversion): style tweaksJonathan Nieder, Sep 7, 2010
  12. Nguyen Thai Ngoc DuySep 7, 2010
  13. 6/7 t1303 (config): style tweaksJonathan Nieder, Sep 7, 2010
  14. Jeff KingSep 7, 2010
  15. Junio C HamanoSep 7, 2010
  16. Jonathan NiederSep 7, 2010
  17. guarding everything with test_expect_success (Re: [PATCH 6/7] t1303 (config): style tweaks)Jonathan Nieder, Sep 7, 2010
  18. Jeff KingSep 7, 2010
  19. Jonathan NiederSep 7, 2010
  20. 7/7 t2016 (checkout -p): use printf for multiline y/n inputJonathan Nieder, Sep 7, 2010
  21. Thomas RastSep 7, 2010
  22. Jonathan NiederSep 7, 2010
  23. Junio C HamanoSep 6, 2010
  24. Jonathan NiederSep 7, 2010
  25. Junio C HamanoSep 7, 2010
  26. Jonathan NiederSep 7, 2010
  27. t1020: Get rid of 'cd "$HERE"' at the start of each testJens Lehmann, Sep 7, 2010

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.