[minor] two tests broken when run with a --root directory that's a symlink

3 messages, 3 authors, 2016-06-15 · open the first message on its own page

[minor] two tests broken when run with a --root directory that's a symlink

From: Ævar Arnfjörð Bjarmason <hidden>
Date: 2016-06-15 22:55:00

These issues are minor, I noticed it because I test with /dev/shm/git
as the --root, which on Debian is symlinked to /run/..

    $ rm -rf /tmp/{foo,bar}
    $ mkdir /tmp/target; ln -s /tmp/target /tmp/link
    $ prove ./t4035-diff-quiet.sh ./t9903-bash-prompt.sh :: --root=/tmp/target
    ./t4035-diff-quiet.sh ... ok
    ./t9903-bash-prompt.sh .. ok
    All tests successful.
    Files=2, Tests=64,  1 wallclock secs ( 0.04 usr  0.00 sys +  0.07
cusr  0.06 csys =  0.17 CPU)
    Result: PASS
    $ prove ./t4035-diff-quiet.sh ./t9903-bash-prompt.sh :: --root=/tmp/link
    ./t4035-diff-quiet.sh ... Dubious, test returned 1 (wstat 256, 0x100)
    Failed 3/20 subtests
    ./t9903-bash-prompt.sh .. Dubious, test returned 1 (wstat 256, 0x100)
    Failed 6/44 subtests

Everything else in the test suite passes with a --root that's a symlink.

[PATCH] bash prompt: fix tests when run with a symlink --root

From: SZEDER Gábor <hidden>
Date: 2016-06-15 22:55:00

Some __gitdir() tests fail when they're run with a --root directory
which is a symlink, because they use $TRASH_DIRECTORY to construct the
expected absolute paths.  Use the path got from 'pwd -P' instead
throughout the test script.

Signed-off-by: SZEDER Gábor <redacted>
---
 t/t9903-bash-prompt.sh | 34 ++++++++++++++++++----------------
 1 file changed, 18 insertions(+), 16 deletions(-)
diff --git a/t/t9903-bash-prompt.sh b/t/t9903-bash-prompt.sh
index f17c1f8b..7a7b198f 100755
--- a/t/t9903-bash-prompt.sh
+++ b/t/t9903-bash-prompt.sh
@@ -11,6 +11,8 @@ test_description='test git-specific bash prompt functions'
 
 actual="$TRASH_DIRECTORY/actual"
 
+TRASH_ROOT="$(pwd -P)"
+
 test_expect_success 'setup for prompt tests' '
 	mkdir -p subdir/subsubdir &&
 	git init otherrepo &&
@@ -32,9 +34,9 @@ test_expect_success 'setup for prompt tests' '
 '
 
 test_expect_success 'gitdir - from command line (through $__git_dir)' '
-	echo "$TRASH_DIRECTORY/otherrepo/.git" > expected &&
+	echo "$TRASH_ROOT/otherrepo/.git" > expected &&
 	(
-		__git_dir="$TRASH_DIRECTORY/otherrepo/.git" &&
+		__git_dir="$TRASH_ROOT/otherrepo/.git" &&
 		__gitdir > "$actual"
 	) &&
 	test_cmp expected "$actual"
@@ -59,7 +61,7 @@ test_expect_success 'gitdir - .git directory in cwd' '
 '
 
 test_expect_success 'gitdir - .git directory in parent' '
-	echo "$TRASH_DIRECTORY/.git" > expected &&
+	echo "$TRASH_ROOT/.git" > expected &&
 	(
 		cd subdir/subsubdir &&
 		__gitdir > "$actual"
@@ -77,7 +79,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_ROOT/.git" > expected &&
 	(
 		cd .git/refs/heads &&
 		__gitdir > "$actual"
@@ -86,9 +88,9 @@ test_expect_success 'gitdir - parent is a .git directory' '
 '
 
 test_expect_success 'gitdir - $GIT_DIR set while .git directory in cwd' '
-	echo "$TRASH_DIRECTORY/otherrepo/.git" > expected &&
+	echo "$TRASH_ROOT/otherrepo/.git" > expected &&
 	(
-		GIT_DIR="$TRASH_DIRECTORY/otherrepo/.git" &&
+		GIT_DIR="$TRASH_ROOT/otherrepo/.git" &&
 		export GIT_DIR &&
 		__gitdir > "$actual"
 	) &&
@@ -96,9 +98,9 @@ test_expect_success 'gitdir - $GIT_DIR set while .git directory in cwd' '
 '
 
 test_expect_success 'gitdir - $GIT_DIR set while .git directory in parent' '
-	echo "$TRASH_DIRECTORY/otherrepo/.git" > expected &&
+	echo "$TRASH_ROOT/otherrepo/.git" > expected &&
 	(
-		GIT_DIR="$TRASH_DIRECTORY/otherrepo/.git" &&
+		GIT_DIR="$TRASH_ROOT/otherrepo/.git" &&
 		export GIT_DIR &&
 		cd subdir &&
 		__gitdir > "$actual"
@@ -108,15 +110,15 @@ test_expect_success 'gitdir - $GIT_DIR set while .git directory in parent' '
 
 test_expect_success 'gitdir - non-existing $GIT_DIR' '
 	(
-		GIT_DIR="$TRASH_DIRECTORY/non-existing" &&
+		GIT_DIR="$TRASH_ROOT/non-existing" &&
 		export GIT_DIR &&
 		test_must_fail __gitdir
 	)
 '
 
 test_expect_success 'gitdir - gitfile in cwd' '
-	echo "$TRASH_DIRECTORY/otherrepo/.git" > expected &&
-	echo "gitdir: $TRASH_DIRECTORY/otherrepo/.git" > subdir/.git &&
+	echo "$TRASH_ROOT/otherrepo/.git" > expected &&
+	echo "gitdir: $TRASH_ROOT/otherrepo/.git" > subdir/.git &&
 	test_when_finished "rm -f subdir/.git" &&
 	(
 		cd subdir &&
@@ -126,8 +128,8 @@ test_expect_success 'gitdir - gitfile in cwd' '
 '
 
 test_expect_success 'gitdir - gitfile in parent' '
-	echo "$TRASH_DIRECTORY/otherrepo/.git" > expected &&
-	echo "gitdir: $TRASH_DIRECTORY/otherrepo/.git" > subdir/.git &&
+	echo "$TRASH_ROOT/otherrepo/.git" > expected &&
+	echo "gitdir: $TRASH_ROOT/otherrepo/.git" > subdir/.git &&
 	test_when_finished "rm -f subdir/.git" &&
 	(
 		cd subdir/subsubdir &&
@@ -137,7 +139,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_ROOT/otherrepo/.git" > expected &&
 	mkdir otherrepo/dir &&
 	test_when_finished "rm -rf otherrepo/dir" &&
 	ln -s otherrepo/dir link &&
@@ -152,7 +154,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_ROOT" &&
 		export GIT_CEILING_DIRECTORIES &&
 		test_must_fail __gitdir
 	)
@@ -250,7 +252,7 @@ echo "edit $(git log -1 --format="%h")" > "$1"
 EOF
 	test_when_finished "rm -f fake_editor.sh" &&
 	chmod a+x fake_editor.sh &&
-	test_set_editor "$TRASH_DIRECTORY/fake_editor.sh" &&
+	test_set_editor "$TRASH_ROOT/fake_editor.sh" &&
 	git checkout b1 &&
 	test_when_finished "git checkout master" &&
 	git rebase -i HEAD^ &&
-- 
1.8.0.rc0.83.gc8e1777

Re: [minor] two tests broken when run with a --root directory that's a symlink

From: Michael Haggerty <hidden>
Date: 2016-06-15 22:55:00

On 10/11/2012 11:55 PM, Ævar Arnfjörð Bjarmason wrote:
These issues are minor, I noticed it because I test with /dev/shm/git
as the --root, which on Debian is symlinked to /run/..

    $ rm -rf /tmp/{foo,bar}
    $ mkdir /tmp/target; ln -s /tmp/target /tmp/link
    $ prove ./t4035-diff-quiet.sh ./t9903-bash-prompt.sh :: --root=/tmp/target
    ./t4035-diff-quiet.sh ... ok
    ./t9903-bash-prompt.sh .. ok
    All tests successful.
    Files=2, Tests=64,  1 wallclock secs ( 0.04 usr  0.00 sys +  0.07
cusr  0.06 csys =  0.17 CPU)
    Result: PASS
    $ prove ./t4035-diff-quiet.sh ./t9903-bash-prompt.sh :: --root=/tmp/link
    ./t4035-diff-quiet.sh ... Dubious, test returned 1 (wstat 256, 0x100)
    Failed 3/20 subtests
    ./t9903-bash-prompt.sh .. Dubious, test returned 1 (wstat 256, 0x100)
    Failed 6/44 subtests

Everything else in the test suite passes with a --root that's a symlink.
I ran into the same problem a while ago, and submitted a patch series
that fixes t4035 (whose problems are related to GIT_CEILING_DIRECTORIES):

    http://thread.gmane.org/gmane.comp.version-control.git/206633

Junio didn't like the approach so much and I haven't yet had time to
submit a revised version.

Michael

-- 
Michael Haggerty
mhagger@alum.mit.edu
http://softwareswirl.blogspot.com/
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help