[PATCH v2 00/19] Let Git's tests pass on Windows

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

 



This is a big milestone. With these modifications, Git's source code
does not only build without warnings in Git for Windows' SDK, but
passes the entire regression test suite.

The patch series contains three different types of patches. First,
there are a couple of real fixes that were triggered by failures in
the regression tests. Then there are a couple of fixes to the
regression tests themselves. And finally, we have to disable a couple
of tests because we simply cannot make them work on Windows.


Johannes Schindelin (16):
  mingw: let's use gettext with MSYS2
  mingw: do not trust MSYS2's MinGW gettext.sh
  Git.pm: stop assuming that absolute paths start with a slash
  mingw: prepare the TMPDIR environment variable for shell scripts
  mingw: let lstat() fail with errno == ENOTDIR when appropriate
  mingw: fix t5601-clone.sh
  mingw: accomodate t0060-path-utils for MSYS2
  mingw: disable mkfifo-based tests
  tests: turn off git-daemon tests if FIFOs are not available
  mingw: skip test in t1508 that fails due to path conversion
  mingw: fix t9700's assumption about directory separators
  mingw: work around pwd issues in the tests
  mingw: mark t9100's test cases with appropriate prereqs
  mingw: avoid illegal filename in t9118
  mingw: handle the missing POSIXPERM prereq in t9124
  mingw: do not bother to test funny file names

Karsten Blees (1):
  mingw: factor out Windows specific environment setup

Pat Thoyts (1):
  Avoid absolute path in t0008

마누엘 (1):
  mingw: try to delete target directory before renaming

 Makefile                              |  1 +
 compat/mingw.c                        | 91 +++++++++++++++++++++++++++++------
 config.mak.uname                      |  3 +-
 perl/Git.pm                           |  3 +-
 t/lib-git-daemon.sh                   |  5 ++
 t/t0008-ignores.sh                    |  2 +-
 t/t0060-path-utils.sh                 |  9 ++++
 t/t1508-at-combinations.sh            |  6 ++-
 t/t3300-funny-names.sh                |  1 +
 t/t3600-rm.sh                         |  3 +-
 t/t3703-add-magic-pathspec.sh         |  2 +-
 t/t3902-quoted.sh                     |  1 +
 t/t4016-diff-quote.sh                 |  1 +
 t/t4135-apply-weird-filenames.sh      |  3 +-
 t/t5601-clone.sh                      | 18 +++----
 t/t7800-difftool.sh                   | 14 +++---
 t/t9100-git-svn-basic.sh              | 18 +++----
 t/t9118-git-svn-funky-branch-names.sh | 12 +++--
 t/t9124-git-svn-dcommit-auto-props.sh | 16 +++---
 t/t9200-git-cvsexportcommit.sh        |  2 +-
 t/t9400-git-cvsserver-server.sh       |  6 +--
 t/t9401-git-cvsserver-crlf.sh         |  6 +--
 t/t9402-git-cvsserver-refs.sh         |  6 +--
 t/t9700/test.pl                       |  2 +-
 t/t9903-bash-prompt.sh                |  2 +-
 t/test-lib.sh                         |  2 +-
 test-fake-ssh.c                       | 30 ++++++++++++
 27 files changed, 196 insertions(+), 69 deletions(-)
 create mode 100644 test-fake-ssh.c

Interdiff vs v1:

 diff --git a/compat/mingw.c b/compat/mingw.c
 index 9e60335..f7acb7f 100644
 --- a/compat/mingw.c
 +++ b/compat/mingw.c
 @@ -2089,7 +2089,7 @@ static void setup_windows_environment()
  	char *tmp = getenv("TMPDIR");
  
  	/* on Windows it is TMP and TEMP */
 -	if (tmp) {
 +	if (!tmp) {
  		if (!(tmp = getenv("TMP")))
  			tmp = getenv("TEMP");
  		if (tmp) {
 diff --git a/t/t0008-ignores.sh b/t/t0008-ignores.sh
 index 68749f5..89544dd 100755
 --- a/t/t0008-ignores.sh
 +++ b/t/t0008-ignores.sh
 @@ -5,13 +5,7 @@ test_description=check-ignore
  . ./test-lib.sh
  
  init_vars () {
 -	# On Windows, avoid using "C:" in the global-excludes paths.
 -	if test_have_prereq MINGW
 -	then
 -		global_excludes="global-excludes"
 -	else
 -		global_excludes="$(pwd)/global-excludes"
 -	fi
 +	global_excludes="global-excludes"
  }
  
  enable_global_excludes () {
 diff --git a/t/t0060-path-utils.sh b/t/t0060-path-utils.sh
 index 89d03e7..8532a02 100755
 --- a/t/t0060-path-utils.sh
 +++ b/t/t0060-path-utils.sh
 @@ -7,13 +7,6 @@ test_description='Test various path utilities'
  
  . ./test-lib.sh
  
 -# On Windows, the root directory "/" is translated into a Windows directory.
 -# As it is not well-defined whether that Windows directory should end in a
 -# slash or not, let's test for that and adjust our expected longest ancestor
 -# length accordingly.
 -root_offset=0
 -case "$(test-path-utils print_path /)" in ?*/) root_offset=-1;; esac
 -
  norm_path() {
  	expected=$(test-path-utils print_path "$2")
  	test_expect_success $3 "normalize path: $1 => $2" \
 @@ -43,12 +36,21 @@ if test $rootoff = 2; then
  	rootoff=	# we are on Unix
  else
  	rootoff=$(($rootoff-1))
 +	# In MSYS2, the root directory "/" is translated into a Windows
 +	# directory *with* trailing slash. Let's test for that and adjust
 +	# our expected longest ancestor length accordingly.
 +	case "$(test-path-utils print_path /)" in
 +	*/) rootslash=1;;
 +	*) rootslash=0;;
 +	esac
  fi
  
  ancestor() {
  	# We do some math with the expected ancestor length.
  	expected=$3
  	if test -n "$rootoff" && test "x$expected" != x-1; then
 +		expected=$(($expected-$rootslash))
 +		test $expected -lt 0 ||
  		expected=$(($expected+$rootoff))
  	fi
  	test_expect_success "longest ancestor: $1 $2 => $expected" \
 @@ -119,30 +121,30 @@ norm_path /d1/.../d2 /d1/.../d2
  norm_path /d1/..././../d2 /d1/d2
  
  ancestor / / -1
 -ancestor /foo / $root_offset
 +ancestor /foo / 0
  ancestor /foo /fo -1
  ancestor /foo /foo -1
  ancestor /foo /bar -1
  ancestor /foo /foo/bar -1
  ancestor /foo /foo:/bar -1
 -ancestor /foo /:/foo:/bar $root_offset
 -ancestor /foo /foo:/:/bar $root_offset
 -ancestor /foo /:/bar:/foo $root_offset
 -ancestor /foo/bar / $root_offset
 +ancestor /foo /:/foo:/bar 0
 +ancestor /foo /foo:/:/bar 0
 +ancestor /foo /:/bar:/foo 0
 +ancestor /foo/bar / 0
  ancestor /foo/bar /fo -1
 -ancestor /foo/bar /foo $((4+$root_offset))
 +ancestor /foo/bar /foo 4
  ancestor /foo/bar /foo/ba -1
 -ancestor /foo/bar /:/fo $root_offset
 -ancestor /foo/bar /foo:/foo/ba $((4+$root_offset))
 +ancestor /foo/bar /:/fo 0
 +ancestor /foo/bar /foo:/foo/ba 4
  ancestor /foo/bar /bar -1
  ancestor /foo/bar /fo -1
 -ancestor /foo/bar /foo:/bar $((4+$root_offset))
 -ancestor /foo/bar /:/foo:/bar $((4+$root_offset))
 -ancestor /foo/bar /foo:/:/bar $((4+$root_offset))
 -ancestor /foo/bar /:/bar:/fo $root_offset
 -ancestor /foo/bar /:/bar $root_offset
 -ancestor /foo/bar /foo $((4+$root_offset))
 -ancestor /foo/bar /foo:/bar $((4+$root_offset))
 +ancestor /foo/bar /foo:/bar 4
 +ancestor /foo/bar /:/foo:/bar 4
 +ancestor /foo/bar /foo:/:/bar 4
 +ancestor /foo/bar /:/bar:/fo 0
 +ancestor /foo/bar /:/bar 0
 +ancestor /foo/bar /foo 4
 +ancestor /foo/bar /foo:/bar 4
  ancestor /foo/bar /bar -1
  
  test_expect_success 'strip_path_suffix' '
 diff --git a/t/t1508-at-combinations.sh b/t/t1508-at-combinations.sh
 index 1d9fd7b..c59d554 100755
 --- a/t/t1508-at-combinations.sh
 +++ b/t/t1508-at-combinations.sh
 @@ -29,22 +29,16 @@ fail() {
  	"$@" failure
  }
  
 -if test_have_prereq MINGW
 -then
 -	# MSYS2 interprets `@/abc` to be a file list, and wants to substitute
 -	# the Unix-y path with a Windows one (e.g. @C:\msys64\abc)
 -	AT_SLASH=@//at-test
 -else
 -	AT_SLASH=@/at-test
 -fi
 -
  test_expect_success 'setup' '
  	test_commit master-one &&
  	test_commit master-two &&
  	git checkout -b upstream-branch &&
  	test_commit upstream-one &&
  	test_commit upstream-two &&
 -	git checkout -b $AT_SLASH &&
 +	if ! test_have_prereq MINGW
 +	then
 +		git checkout -b @/at-slash
 +	fi &&
  	git checkout -b @@/at-test &&
  	git checkout -b @at-test &&
  	git checkout -b old-branch &&
 @@ -73,7 +67,8 @@ check "@{-1}@{u}@{1}" commit master-one
  check "@" commit new-two
  check "@@{u}" ref refs/heads/upstream-branch
  check "@@/at-test" ref refs/heads/@@/at-test
 -check "$AT_SLASH" ref refs/heads/@/at-test
 +test_have_prereq MINGW ||
 +check "@/at-test" ref refs/heads/@/at-test
  check "@at-test" ref refs/heads/@at-test
  nonsense "@{u}@{-1}"
  nonsense "@{0}@{0}"
 diff --git a/t/t9100-git-svn-basic.sh b/t/t9100-git-svn-basic.sh
 index 8c74ffa..5b32a3b 100755
 --- a/t/t9100-git-svn-basic.sh
 +++ b/t/t9100-git-svn-basic.sh
 @@ -25,23 +25,12 @@ test_expect_success \
  	(
  		cd import &&
  		echo foo >foo &&
 -		if test_have_prereq !MINGW
 -		then
 -			ln -s foo foo.link
 -		else
 -			# MSYS libsvn does not support symlinks, so always use cp, even if
 -			# ln -s actually works
 -			cp foo foo.link
 -		fi
 +		ln -s foo foo.link
  		mkdir -p dir/a/b/c/d/e &&
  		echo "deep dir" >dir/a/b/c/d/e/file &&
  		mkdir bar &&
  		echo "zzz" >bar/zzz &&
 -		echo "#!/bin/sh" >exec.sh &&
 -		{
 -			test_have_prereq !POSIXPERM ||
 -			chmod +x exec.sh
 -		} &&
 +		printf "" | write_script exec.sh &&
  		svn_cmd import -m "import for git svn" . "$svnrepo" >/dev/null
  	) &&
  	rm -rf import &&
 @@ -127,7 +116,7 @@ test_expect_success "$name" '
  
  
  name='remove executable bit from a file'
 -test_expect_success !MINGW "$name" '
 +test_expect_success POSIXPERM "$name" '
  	rm -f "$GIT_DIR"/index &&
  	git checkout -f -b mybranch5 ${remotes_git_svn} &&
  	chmod -x exec.sh &&
 @@ -140,7 +129,7 @@ test_expect_success !MINGW "$name" '
  
  
  name='add executable bit back file'
 -test_expect_success !MINGW "$name" '
 +test_expect_success POSIXPERM "$name" '
  	chmod +x exec.sh &&
  	git update-index exec.sh &&
  	git commit -m "$name" &&
 @@ -151,7 +140,7 @@ test_expect_success !MINGW "$name" '
  
  
  name='executable file becomes a symlink to file'
 -test_expect_success !MINGW "$name" '
 +test_expect_success SYMLINKS "$name" '
  	rm exec.sh &&
  	ln -s file exec.sh &&
  	git update-index exec.sh &&
 @@ -163,7 +152,8 @@ test_expect_success !MINGW "$name" '
  
  name='new symlink is added to a file that was also just made executable'
  
 -test_expect_success !MINGW "$name" '
 +test_expect_success POSIXPERM,SYMLINKS "$name" '
 +	chmod +x file &&
  	ln -s file exec-2.sh &&
  	git update-index --add file exec-2.sh &&
  	git commit -m "$name" &&
 @@ -174,7 +164,7 @@ test_expect_success !MINGW "$name" '
  	test -h "$SVN_TREE"/exec-2.sh'
  
  name='modify a symlink to become a file'
 -test_expect_success !MINGW "$name" '
 +test_expect_success POSIXPERM,SYMLINKS "$name" '
  	echo git help >help &&
  	rm exec-2.sh &&
  	cp help exec-2.sh &&
 @@ -190,7 +180,8 @@ test_expect_success !MINGW "$name" '
  name="commit with UTF-8 message: locale: $GIT_SVN_LC_ALL"
  LC_ALL="$GIT_SVN_LC_ALL"
  export LC_ALL
 -test_expect_success !MINGW,UTF8 "$name" "
 +# This test relies on the previous test, hence requires POSIXPERM,SYMLINKS
 +test_expect_success UTF8,POSIXPERM,SYMLINKS "$name" "
  	echo '# hello' >> exec-2.sh &&
  	git update-index exec-2.sh &&
  	git commit -m 'éï∏' &&
 @@ -223,7 +214,7 @@ tree d667270a1f7b109f5eb3aaea21ede14b56bfdd6e
  tree 8f51f74cf0163afc9ad68a4b1537288c4558b5a4
  EOF
  
 -test_expect_success !MINGW "$name" "test_cmp a expected"
 +test_expect_success POSIXPERM,SYMLINKS "$name" "test_cmp a expected"
  
  test_expect_success 'exit if remote refs are ambigious' "
          git config --add svn-remote.svn.fetch \
 diff --git a/t/t9118-git-svn-funky-branch-names.sh b/t/t9118-git-svn-funky-branch-names.sh
 index 49775a5..ecb1fed 100755
 --- a/t/t9118-git-svn-funky-branch-names.sh
 +++ b/t/t9118-git-svn-funky-branch-names.sh
 @@ -23,11 +23,11 @@ test_expect_success 'setup svnrepo' '
  	              "$svnrepo/pr ject/branches/$scary_uri" &&
  	svn_cmd cp -m "leading dot" "$svnrepo/pr ject/trunk" \
  			"$svnrepo/pr ject/branches/.leading_dot" &&
 -	{
 -		test_have_prereq MINGW ||
 +	if test_have_prereq !MINGW
 +	then
  		svn_cmd cp -m "trailing dot" "$svnrepo/pr ject/trunk" \
  			"$svnrepo/pr ject/branches/trailing_dot."
 -	} &&
 +	fi &&
  	svn_cmd cp -m "trailing .lock" "$svnrepo/pr ject/trunk" \
  			"$svnrepo/pr ject/branches/trailing_dotlock.lock" &&
  	svn_cmd cp -m "reflog" "$svnrepo/pr ject/trunk" \
 @@ -48,10 +48,10 @@ test_expect_success 'test clone with funky branch names' '
  		git rev-parse "refs/remotes/origin/more%20fun%20plugin!" &&
  		git rev-parse "refs/remotes/origin/$scary_ref" &&
  		git rev-parse "refs/remotes/origin/%2Eleading_dot" &&
 -		{
 -			test_have_prereq MINGW ||
 +		if test_have_prereq !MINGW
 +		then
  			git rev-parse "refs/remotes/origin/trailing_dot%2E"
 -		} &&
 +		fi &&
  		git rev-parse "refs/remotes/origin/trailing_dotlock%2Elock" &&
  		git rev-parse "refs/remotes/origin/$non_reflog"
  	)
 diff --git a/t/t9124-git-svn-dcommit-auto-props.sh b/t/t9124-git-svn-dcommit-auto-props.sh
 index c851121..2be0805 100755
 --- a/t/t9124-git-svn-dcommit-auto-props.sh
 +++ b/t/t9124-git-svn-dcommit-auto-props.sh
 @@ -34,11 +34,7 @@ test_expect_success 'enable auto-props config' '
  '
  
  test_expect_success 'add files matching auto-props' '
 -	echo "#!$SHELL_PATH" >exec1.sh &&
 -	{
 -		test_have_prereq !POSIXPERM ||
 -		chmod +x exec1.sh
 -	} &&
 +	printf "" | write_script exec1.sh &&
  	echo "hello" >hello.txt &&
  	echo bar >bar &&
  	git add exec1.sh hello.txt bar &&
 @@ -51,11 +47,7 @@ test_expect_success 'disable auto-props config' '
  '
  
  test_expect_success 'add files matching disabled auto-props' '
 -	echo "#$SHELL_PATH" >exec2.sh &&
 -	{
 -		test_have_prereq !POSIXPERM ||
 -		chmod +x exec2.sh
 -	} &&
 +	printf "" | write_script exec2.sh &&
  	echo "world" >world.txt &&
  	echo zot >zot &&
  	git add exec2.sh world.txt zot &&
 @@ -71,10 +63,10 @@ test_expect_success 'check resulting svn repository' '
  	cd svnrepo &&
  
  	# Check properties from first commit.
 -	{
 -		test_have_prereq !POSIXPERM ||
 -		test "x$(svn_cmd propget svn:executable exec1.sh)" = "x*"
 -	} &&
 +	if test_have_prereq POSIXPERM
 +	then
 +		test -z "$(svn_cmd propget svn:executable exec1.sh)"
 +	fi &&
  	test "x$(svn_cmd propget svn:mime-type exec1.sh)" = \
  	     "xapplication/x-shellscript" &&
  	test "x$(svn_cmd propget svn:mime-type hello.txt)" = "xtext/plain" &&
 @@ -82,10 +74,10 @@ test_expect_success 'check resulting svn repository' '
  	test "x$(svn_cmd propget svn:mime-type bar)" = "x" &&
  
  	# Check properties from second commit.
 -	{
 -		test_have_prereq !POSIXPERM ||
 -		test "x$(svn_cmd propget svn:executable exec2.sh)" = "x*"
 -	} &&
 +	if test_have_prereq POSIXPERM
 +	then
 +		test -z "$(svn_cmd propget svn:executable exec2.sh)"
 +	fi &&
  	test "x$(svn_cmd propget svn:mime-type exec2.sh)" = "x" &&
  	test "x$(svn_cmd propget svn:mime-type world.txt)" = "x" &&
  	test "x$(svn_cmd propget svn:eol-style world.txt)" = "x" &&
 diff --git a/t/t9130-git-svn-authors-file.sh b/t/t9130-git-svn-authors-file.sh
 index 4126481..d306b77 100755
 --- a/t/t9130-git-svn-authors-file.sh
 +++ b/t/t9130-git-svn-authors-file.sh
 @@ -91,7 +91,7 @@ test_expect_success 'fetch continues after authors-file is fixed' '
  	)
  	'
  
 -test_expect_success !MINGW 'fresh clone with svn.authors-file in config' '
 +test_expect_success 'fresh clone with svn.authors-file in config' '
  	(
  		rm -r "$GIT_DIR" &&
  		test x = x"$(git config svn.authorsfile)" &&

-- 
2.7.0.windows.1.7.g55a05c8

[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]