git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] test: some testcases failed if cwd is on a symlink
@ 2012-07-24  8:00 Jiang Xin
  2012-07-24  8:24 ` Stefano Lattarini
                   ` (2 more replies)
  0 siblings, 3 replies; 38+ messages in thread
From: Jiang Xin @ 2012-07-24  8:00 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Git List, Jiang Xin

Run command 'git rev-parse --git-dir' under subdir will return realpath
of '.git' directory. Some test scripts compare this realpath against
"$TRASH_DIRECTORY", they are not equal if current working directory is
on a symlink.

In this fix, get realpath of "$TRASH_DIRECTORY", store it in
"$TRASH_REALPATH" variable, and use it when necessary.

Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
---
 t/t4035-diff-quiet.sh  |  8 +++++---
 t/t9903-bash-prompt.sh | 13 +++++++------
 2 个文件被修改,插入 12 行(+),删除 9 行(-)

diff --git a/t/t4035-diff-quiet.sh b/t/t4035-diff-quiet.sh
index 23141..5855 100755
--- a/t/t4035-diff-quiet.sh
+++ b/t/t4035-diff-quiet.sh
@@ -4,6 +4,8 @@ test_description='Return value of diffs'
 
 . ./test-lib.sh
 
+TRASH_REALPATH="$(cd "$TRASH_DIRECTORY"; pwd -P)"
+
 test_expect_success 'setup' '
 	echo 1 >a &&
 	git add . &&
@@ -102,7 +104,7 @@ test_expect_success 'git diff, one file outside repo' '
 
 test_expect_success 'git diff, both files outside repo' '
 	(
-		GIT_CEILING_DIRECTORIES="$TRASH_DIRECTORY/test-outside" &&
+		GIT_CEILING_DIRECTORIES="$TRASH_REALPATH/test-outside" &&
 		export GIT_CEILING_DIRECTORIES &&
 		cd test-outside/non/git &&
 		test_expect_code 0 git diff --quiet a matching-file &&
@@ -120,7 +122,7 @@ test_expect_success 'git diff --ignore-space-at-eol, one file outside repo' '
 
 test_expect_success 'git diff --ignore-space-at-eol, both files outside repo' '
 	(
-		GIT_CEILING_DIRECTORIES="$TRASH_DIRECTORY/test-outside" &&
+		GIT_CEILING_DIRECTORIES="$TRASH_REALPATH/test-outside" &&
 		export GIT_CEILING_DIRECTORIES &&
 		cd test-outside/non/git &&
 		test_expect_code 0 git diff --quiet --ignore-space-at-eol a trailing-space &&
@@ -139,7 +141,7 @@ test_expect_success 'git diff --ignore-all-space, one file outside repo' '
 
 test_expect_success 'git diff --ignore-all-space, both files outside repo' '
 	(
-		GIT_CEILING_DIRECTORIES="$TRASH_DIRECTORY/test-outside" &&
+		GIT_CEILING_DIRECTORIES="$TRASH_REALPATH/test-outside" &&
 		export GIT_CEILING_DIRECTORIES &&
 		cd test-outside/non/git &&
 		test_expect_code 0 git diff --quiet --ignore-all-space a trailing-space &&
diff --git a/t/t9903-bash-prompt.sh b/t/t9903-bash-prompt.sh
index f17c1f..275bc 100755
--- a/t/t9903-bash-prompt.sh
+++ b/t/t9903-bash-prompt.sh
@@ -10,6 +10,7 @@ test_description='test git-specific bash prompt functions'
 . "$GIT_BUILD_DIR/contrib/completion/git-prompt.sh"
 
 actual="$TRASH_DIRECTORY/actual"
+TRASH_REALPATH="$(cd "$TRASH_DIRECTORY"; pwd -P)"
 
 test_expect_success 'setup for prompt tests' '
 	mkdir -p subdir/subsubdir &&
@@ -59,7 +60,7 @@ test_expect_success 'gitdir - .git directory in cwd' '
 '
 
 test_expect_success 'gitdir - .git directory in parent' '
-	echo "$TRASH_DIRECTORY/.git" > expected &&
+	echo "$TRASH_REALPATH/.git" > expected &&
 	(
 		cd subdir/subsubdir &&
 		__gitdir > "$actual"
@@ -77,7 +78,7 @@ test_expect_success 'gitdir - cwd is a .git directory' '
 '
 
 test_expect_success 'gitdir - parent is a .git directory' '
-	echo "$TRASH_DIRECTORY/.git" > expected &&
+	echo "$TRASH_REALPATH/.git" > expected &&
 	(
 		cd .git/refs/heads &&
 		__gitdir > "$actual"
@@ -115,7 +116,7 @@ test_expect_success 'gitdir - non-existing $GIT_DIR' '
 '
 
 test_expect_success 'gitdir - gitfile in cwd' '
-	echo "$TRASH_DIRECTORY/otherrepo/.git" > expected &&
+	echo "$TRASH_REALPATH/otherrepo/.git" > expected &&
 	echo "gitdir: $TRASH_DIRECTORY/otherrepo/.git" > subdir/.git &&
 	test_when_finished "rm -f subdir/.git" &&
 	(
@@ -126,7 +127,7 @@ test_expect_success 'gitdir - gitfile in cwd' '
 '
 
 test_expect_success 'gitdir - gitfile in parent' '
-	echo "$TRASH_DIRECTORY/otherrepo/.git" > expected &&
+	echo "$TRASH_REALPATH/otherrepo/.git" > expected &&
 	echo "gitdir: $TRASH_DIRECTORY/otherrepo/.git" > subdir/.git &&
 	test_when_finished "rm -f subdir/.git" &&
 	(
@@ -137,7 +138,7 @@ test_expect_success 'gitdir - gitfile in parent' '
 '
 
 test_expect_success SYMLINKS 'gitdir - resulting path avoids symlinks' '
-	echo "$TRASH_DIRECTORY/otherrepo/.git" > expected &&
+	echo "$TRASH_REALPATH/otherrepo/.git" > expected &&
 	mkdir otherrepo/dir &&
 	test_when_finished "rm -rf otherrepo/dir" &&
 	ln -s otherrepo/dir link &&
@@ -152,7 +153,7 @@ test_expect_success SYMLINKS 'gitdir - resulting path avoids symlinks' '
 test_expect_success 'gitdir - not a git repository' '
 	(
 		cd subdir/subsubdir &&
-		GIT_CEILING_DIRECTORIES="$TRASH_DIRECTORY" &&
+		GIT_CEILING_DIRECTORIES="$TRASH_REALPATH" &&
 		export GIT_CEILING_DIRECTORIES &&
 		test_must_fail __gitdir
 	)
-- 
1.7.12.rc0.16.gf4916ac

^ permalink raw reply	[flat|nested] 38+ messages in thread

end of thread, other threads:[~2012-09-29  5:46 UTC | newest]

Thread overview: 38+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-24  8:00 [PATCH] test: some testcases failed if cwd is on a symlink Jiang Xin
2012-07-24  8:24 ` Stefano Lattarini
2012-07-24 10:59 ` Pete Wyckoff
2012-07-24 14:47 ` Junio C Hamano
2012-07-24 22:06   ` Jiang Xin
2012-08-18 14:41   ` Michael Haggerty
2012-08-18 20:36     ` Junio C Hamano
2012-08-19 13:57       ` Michael Haggerty
2012-08-19 16:43         ` Junio C Hamano
2012-08-21  5:59           ` Michael Haggerty
2012-08-27  5:13         ` [PATCH v2] test: set the realpath of CWD as TRASH_DIRECTORY Jiang Xin
2012-08-27 16:15           ` Junio C Hamano
2012-08-29  4:14             ` Michael Haggerty
2012-08-29  6:06               ` Junio C Hamano
2012-08-29  8:15                 ` Michael Haggerty
2012-08-29 16:33                   ` Junio C Hamano
2012-08-30  4:37                     ` Michael Haggerty
2012-08-30  5:26                       ` Junio C Hamano
2012-08-31  7:49                         ` Michael Haggerty
2012-09-26 19:34                           ` [PATCH 0/8] Fix GIT_CEILING_DIRECTORIES that contain symlinks Michael Haggerty
2012-09-26 19:34                             ` [PATCH 1/8] Introduce new static function real_path_internal() Michael Haggerty
2012-09-27 21:27                               ` Junio C Hamano
2012-09-29  4:56                                 ` Michael Haggerty
2012-09-29  5:40                                   ` Junio C Hamano
2012-09-26 19:34                             ` [PATCH 2/8] Introduce new function real_path_if_valid() Michael Haggerty
2012-09-26 19:34                             ` [PATCH 3/8] longest_ancestor_length(): use string_list_split() Michael Haggerty
2012-09-27 22:48                               ` Junio C Hamano
2012-09-29  5:25                                 ` Michael Haggerty
2012-09-29  5:43                                   ` Junio C Hamano
2012-09-26 19:34                             ` [PATCH 4/8] longest_ancestor_length(): explicitly filter list before loop Michael Haggerty
2012-09-27 22:48                               ` Junio C Hamano
2012-09-26 19:34                             ` [PATCH 5/8] longest_ancestor_length(): always add a slash to the end of prefixes Michael Haggerty
2012-09-26 19:34                             ` [PATCH 6/8] longest_ancestor_length(): use string_list_longest_prefix() Michael Haggerty
2012-09-26 19:34                             ` [PATCH 7/8] longest_ancestor_length(): resolve symlinks before comparing paths Michael Haggerty
2012-09-27 22:51                               ` Junio C Hamano
2012-09-29  5:46                                 ` Michael Haggerty
2012-09-26 19:34                             ` [PATCH 8/8] t1504: stop resolving symlinks in GIT_CEILING_DIRECTORIES Michael Haggerty
2012-09-27 19:42                             ` [PATCH 0/8] Fix GIT_CEILING_DIRECTORIES that contain symlinks Junio C Hamano

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).