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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <LeWiemann@xxxxxxxxx>
---
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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux