mingw: work around pwd issues in the tests

In Git for Windows' SDK, the tests are run using a Bash that relies on
the POSIX emulation layer MSYS2 (itself a friendly fork of Cygwin). As
such, paths in tests can be POSIX paths. As soon as those paths are
passed to git.exe (which does *not* use the POSIX emulation layer),
those paths are converted into Windows paths, though. This happens
for command-line parameters, but not when reading, say, config variables.

To help with that, the `pwd` command is overridden to return the Windows
path of the current working directory when testing Git on Windows.

However, when talking to anything using the POSIX emulation layer, it is
really much better to use POSIX paths because Windows paths contain a
colon after the drive letter that will easily be mistaken for the common
separator in path lists.

So let's just use the $PWD variable when the POSIX path is needed.

This lets t7800-difftool.sh, t9400-git-cvsserver-server.sh,
t9402-git-cvsserver-refs.sh and t9401-git-cvsserver-crlf.sh pass in Git
for Windows' SDK.

Note: the cvsserver tests require not only the `cvs` package (install
it into Git for Windows' SDK via `pacman -S cvs`) but also the Perl
SQLite bindings (install them into Git for Windows' SDK via
`cpan DBD::SQLite`).

This patch is based on earlier work by 마누엘 and Karsten Blees.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Johannes Schindelin 2016-01-27 17:19:59 +01:00 committed by Junio C Hamano
parent d53c2c6738
commit fd318a941d
4 changed files with 16 additions and 16 deletions

View File

@ -430,11 +430,11 @@ EOF
test_expect_success PERL,SYMLINKS 'difftool --dir-diff --symlink without unstaged changes' ' test_expect_success PERL,SYMLINKS 'difftool --dir-diff --symlink without unstaged changes' '
cat >expect <<-EOF && cat >expect <<-EOF &&
file file
$(pwd)/file $PWD/file
file2 file2
$(pwd)/file2 $PWD/file2
sub/sub sub/sub
$(pwd)/sub/sub $PWD/sub/sub
EOF EOF
git difftool --dir-diff --symlink \ git difftool --dir-diff --symlink \
--extcmd "./.git/CHECK_SYMLINKS" branch HEAD && --extcmd "./.git/CHECK_SYMLINKS" branch HEAD &&
@ -448,14 +448,14 @@ EOF
run_dir_diff_test 'difftool --dir-diff syncs worktree with unstaged change' ' run_dir_diff_test 'difftool --dir-diff syncs worktree with unstaged change' '
test_when_finished git reset --hard && test_when_finished git reset --hard &&
echo "orig content" >file && echo "orig content" >file &&
git difftool -d $symlinks --extcmd "$(pwd)/modify-right-file" branch && git difftool -d $symlinks --extcmd "$PWD/modify-right-file" branch &&
echo "new content" >expect && echo "new content" >expect &&
test_cmp expect file test_cmp expect file
' '
run_dir_diff_test 'difftool --dir-diff syncs worktree without unstaged change' ' run_dir_diff_test 'difftool --dir-diff syncs worktree without unstaged change' '
test_when_finished git reset --hard && test_when_finished git reset --hard &&
git difftool -d $symlinks --extcmd "$(pwd)/modify-right-file" branch && git difftool -d $symlinks --extcmd "$PWD/modify-right-file" branch &&
echo "new content" >expect && echo "new content" >expect &&
test_cmp expect file test_cmp expect file
' '
@ -466,7 +466,7 @@ EOF
test_expect_success PERL 'difftool --no-symlinks does not overwrite working tree file ' ' test_expect_success PERL 'difftool --no-symlinks does not overwrite working tree file ' '
echo "orig content" >file && echo "orig content" >file &&
git difftool --dir-diff --no-symlinks --extcmd "$(pwd)/modify-file" branch && git difftool --dir-diff --no-symlinks --extcmd "$PWD/modify-file" branch &&
echo "new content" >expect && echo "new content" >expect &&
test_cmp expect file test_cmp expect file
' '
@ -482,7 +482,7 @@ test_expect_success PERL 'difftool --no-symlinks detects conflict ' '
TMPDIR=$TRASH_DIRECTORY && TMPDIR=$TRASH_DIRECTORY &&
export TMPDIR && export TMPDIR &&
echo "orig content" >file && echo "orig content" >file &&
test_must_fail git difftool --dir-diff --no-symlinks --extcmd "$(pwd)/modify-both-files" branch && test_must_fail git difftool --dir-diff --no-symlinks --extcmd "$PWD/modify-both-files" branch &&
echo "wt content" >expect && echo "wt content" >expect &&
test_cmp expect file && test_cmp expect file &&
echo "tmp content" >expect && echo "tmp content" >expect &&

View File

@ -25,11 +25,11 @@ perl -e 'use DBI; use DBD::SQLite' >/dev/null 2>&1 || {
test_done test_done
} }
WORKDIR=$(pwd) WORKDIR=$PWD
SERVERDIR=$(pwd)/gitcvs.git SERVERDIR=$PWD/gitcvs.git
git_config="$SERVERDIR/config" git_config="$SERVERDIR/config"
CVSROOT=":fork:$SERVERDIR" CVSROOT=":fork:$SERVERDIR"
CVSWORK="$(pwd)/cvswork" CVSWORK="$PWD/cvswork"
CVS_SERVER=git-cvsserver CVS_SERVER=git-cvsserver
export CVSROOT CVS_SERVER export CVSROOT CVS_SERVER

View File

@ -74,11 +74,11 @@ perl -e 'use DBI; use DBD::SQLite' >/dev/null 2>&1 || {
} }
unset GIT_DIR GIT_CONFIG unset GIT_DIR GIT_CONFIG
WORKDIR=$(pwd) WORKDIR=$PWD
SERVERDIR=$(pwd)/gitcvs.git SERVERDIR=$PWD/gitcvs.git
git_config="$SERVERDIR/config" git_config="$SERVERDIR/config"
CVSROOT=":fork:$SERVERDIR" CVSROOT=":fork:$SERVERDIR"
CVSWORK="$(pwd)/cvswork" CVSWORK="$PWD/cvswork"
CVS_SERVER=git-cvsserver CVS_SERVER=git-cvsserver
export CVSROOT CVS_SERVER export CVSROOT CVS_SERVER

View File

@ -82,11 +82,11 @@ perl -e 'use DBI; use DBD::SQLite' >/dev/null 2>&1 || {
} }
unset GIT_DIR GIT_CONFIG unset GIT_DIR GIT_CONFIG
WORKDIR=$(pwd) WORKDIR=$PWD
SERVERDIR=$(pwd)/gitcvs.git SERVERDIR=$PWD/gitcvs.git
git_config="$SERVERDIR/config" git_config="$SERVERDIR/config"
CVSROOT=":fork:$SERVERDIR" CVSROOT=":fork:$SERVERDIR"
CVSWORK="$(pwd)/cvswork" CVSWORK="$PWD/cvswork"
CVS_SERVER=git-cvsserver CVS_SERVER=git-cvsserver
export CVSROOT CVS_SERVER export CVSROOT CVS_SERVER