DORMANTno replies

[PATCH] t/test-lib.sh: resolve symlinks in working directory, for pathname comparisons

From: Lea Wiemann <hidden>
Date: 2016-06-15 22:44:40
Subsystem: the rest · Maintainer: Linus Torvalds

Without this, some tests will fail because they compare command output
of subprocesses (such as git) with $PWD -- but subprocesses have the
physical path as their working directory, whereas $PWD contains the
symlinked path.  This fixes it.

Signed-off-by: Lea Wiemann <redacted>
---
Here is how to reproduce it:

$ ln -s /path/to/git git-symlink
$ cd git-symlink/t
$ ./t0001-init.sh 
*   ok 1: plain
*   ok 2: plain with GIT_WORK_TREE
*   ok 3: plain bare
*   ok 4: plain bare with GIT_WORK_TREE
*   ok 5: GIT_DIR bare
*   ok 6: GIT_DIR non-bare
* FAIL 7: GIT_DIR & GIT_WORK_TREE (1)
	
	
		(
			unset GIT_CONFIG
			mkdir git-dir-wt-1.git &&
			GIT_WORK_TREE=$(pwd) GIT_DIR=git-dir-wt-1.git git init
		) &&
		check_config git-dir-wt-1.git false "$(pwd)"
	
*   ok 8: GIT_DIR & GIT_WORK_TREE (2)
*   ok 9: reinit
* failed 1 among 9 test(s)

With this patch applied, all tests work fine in symlinked working
directories.

 t/test-lib.sh |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 3bf570b..7a8bd27 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -419,7 +419,9 @@ rm -fr "$test" || {
 }
 
 test_create_repo "$test"
-cd "$test" || exit 1
+# Use -P to resolve symlinks in our working directory so that the cwd
+# in subprocesses like git equals our $PWD (for pathname comparisons).
+cd -P "$test" || exit 1
 
 this_test=$(expr "./$0" : '.*/\(t[0-9]*\)-[^/]*$')
 for skp in $GIT_SKIP_TESTS
-- 
1.5.5.GIT
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help