From: Johannes Sixt <j6t@kdbg.org>
To: Johannes Schindelin <johannes.schindelin@gmx.de>
Cc: Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org
Subject: Re: [PATCH 09/19] mingw: accomodate t0060-path-utils for MSYS2
Date: Sun, 24 Jan 2016 20:51:04 +0100 [thread overview]
Message-ID: <56A52B28.8010304@kdbg.org> (raw)
In-Reply-To: <12c030323940de4a0845eda9bdd7b67c4e90864a.1453650173.git.johannes.schindelin@gmx.de>
Am 24.01.2016 um 16:44 schrieb Johannes Schindelin:
> On Windows, there are no POSIX paths, only Windows ones (an absolute
> Windows path looks like "C:\Program Files\Git\ReleaseNotes.html", under
> most circumstances, forward slashes are also allowed and synonymous to
> backslashes).
>
> So when a POSIX shell (such as MSYS2's Bash, which is used by Git for
> Windows to execute all those shell scripts that are part of Git) passes
> a POSIX path to test-path-utils.exe (which is not POSIX-aware), the path
> is translated into a Windows path. For example, /etc/profile becomes
> C:/Program Files/Git/etc/profile.
>
> This path translation poses a problem when passing the root directory as
> parameter to test-path-utils.exe, as it is not well defined whether the
> translated root directory should end in a slash or not. MSys1 stripped
> the trailing slash, but MSYS2 does not.
>
> To work with both behaviors, we simply test what the current system does
> in the beginning of t0060-path-utils.sh and then adjust the expected
> longest ancestor length accordingly.
>
> Originally, the Git for Windows project patched MSYS2's runtime to
> accomodate Git's regression test, but we really should do it the other
> way round.
>
> Thanks to Ray Donnelly for his patient help with this issue.
>
> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> ---
> t/t0060-path-utils.sh | 37 ++++++++++++++++++++++---------------
> 1 file changed, 22 insertions(+), 15 deletions(-)
>
> diff --git a/t/t0060-path-utils.sh b/t/t0060-path-utils.sh
> index f0152a7..89d03e7 100755
> --- a/t/t0060-path-utils.sh
> +++ b/t/t0060-path-utils.sh
> @@ -7,6 +7,13 @@ 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" \
In t0060-path-utils.sh, I currently find this:
# On Windows, we are using MSYS's bash, which mangles the paths.
# Absolute paths are anchored at the MSYS installation directory,
# which means that the path / accounts for this many characters:
rootoff=$(test-path-utils normalize_path_copy / | wc -c)
# Account for the trailing LF:
if test $rootoff = 2; then
rootoff= # we are on Unix
else
rootoff=$(($rootoff-1))
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+$rootoff))
fi
test_expect_success "longest ancestor: $1 $2 => $expected" \
"actual=\$(test-path-utils longest_ancestor_length '$1' '$2') &&
test \"\$actual\" = '$expected'"
}
Furthermore, since you are modifying only cases where the expected
value is not -1 and we already have a check for this case in the
helper function, wouldn't it be simpler to merge the offset that your
case needs with the one that we already have?
> @@ -112,30 +119,30 @@ norm_path /d1/.../d2 /d1/.../d2
> norm_path /d1/..././../d2 /d1/d2
>
> ancestor / / -1
> -ancestor /foo / 0
> +ancestor /foo / $root_offset
> 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 0
> -ancestor /foo /foo:/:/bar 0
> -ancestor /foo /:/bar:/foo 0
> -ancestor /foo/bar / 0
> +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/bar /fo -1
> -ancestor /foo/bar /foo 4
> +ancestor /foo/bar /foo $((4+$root_offset))
> ancestor /foo/bar /foo/ba -1
> -ancestor /foo/bar /:/fo 0
> -ancestor /foo/bar /foo:/foo/ba 4
> +ancestor /foo/bar /:/fo $root_offset
> +ancestor /foo/bar /foo:/foo/ba $((4+$root_offset))
> ancestor /foo/bar /bar -1
> ancestor /foo/bar /fo -1
> -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 /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 /bar -1
>
> test_expect_success 'strip_path_suffix' '
>
next prev parent reply other threads:[~2016-01-24 19:51 UTC|newest]
Thread overview: 113+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-24 15:43 [PATCH 00/19] Let Git's tests pass on Windows Johannes Schindelin
2016-01-24 15:43 ` [PATCH 01/19] mingw: let's use gettext with MSYS2 Johannes Schindelin
2016-01-25 1:42 ` Junio C Hamano
2016-01-25 16:16 ` Johannes Schindelin
2016-01-25 18:53 ` Junio C Hamano
2016-01-24 15:43 ` [PATCH 02/19] mingw: do not trust MSYS2's MinGW gettext.sh Johannes Schindelin
2016-01-24 15:43 ` [PATCH 03/19] Git.pm: stop assuming that absolute paths start with a slash Johannes Schindelin
2016-01-24 15:43 ` [PATCH 04/19] mingw: factor out Windows specific environment setup Johannes Schindelin
2016-01-24 15:43 ` [PATCH 05/19] mingw: prepare the TMPDIR environment variable for shell scripts Johannes Schindelin
2016-01-25 2:11 ` Eric Sunshine
2016-01-26 8:38 ` Johannes Schindelin
2016-01-24 15:44 ` [PATCH 06/19] mingw: try to delete target directory before renaming Johannes Schindelin
2016-01-24 17:42 ` Philip Oakley
2016-01-25 6:59 ` Johannes Schindelin
2016-01-25 18:55 ` Junio C Hamano
2016-01-26 8:14 ` Johannes Schindelin
2016-01-24 15:44 ` [PATCH 07/19] mingw: let lstat() fail with errno == ENOTDIR when appropriate Johannes Schindelin
2016-01-24 15:44 ` [PATCH 08/19] mingw: fix t5601-clone.sh Johannes Schindelin
2016-01-24 15:44 ` [PATCH 09/19] mingw: accomodate t0060-path-utils for MSYS2 Johannes Schindelin
2016-01-24 19:51 ` Johannes Sixt [this message]
2016-01-25 15:39 ` Johannes Schindelin
2016-01-24 15:44 ` [PATCH 10/19] mingw: disable mkfifo-based tests Johannes Schindelin
2016-01-24 15:44 ` [PATCH 11/19] tests: turn off git-daemon tests if FIFOs are not available Johannes Schindelin
2016-01-24 15:45 ` [PATCH 12/19] mingw: do not use symlinks with SVN in t9100 Johannes Schindelin
2016-01-25 1:51 ` Junio C Hamano
2016-01-25 16:53 ` Johannes Schindelin
2016-01-24 15:45 ` [PATCH 13/19] mingw: outsmart MSYS2's path substitution in t1508 Johannes Schindelin
2016-01-25 2:03 ` Junio C Hamano
2016-01-25 6:22 ` Eric Sunshine
2016-01-25 18:50 ` Junio C Hamano
2016-01-26 6:53 ` Johannes Schindelin
2016-01-25 16:30 ` Johannes Schindelin
2016-01-25 17:04 ` Johannes Schindelin
2016-01-24 15:45 ` [PATCH 14/19] mingw: fix t9700's assumption about directory separators Johannes Schindelin
2016-01-24 15:45 ` [PATCH 15/19] mingw: work around pwd issues in the tests Johannes Schindelin
2016-01-24 15:45 ` [PATCH 16/19] mingw: avoid absolute path in t0008 Johannes Schindelin
2016-01-25 2:11 ` Junio C Hamano
2016-01-25 16:48 ` Johannes Schindelin
2016-01-25 19:31 ` Ray Donnelly
2016-01-25 22:20 ` Junio C Hamano
2016-01-26 8:00 ` Johannes Schindelin
2016-01-24 15:45 ` [PATCH 17/19] mingw: fix git-svn tests that expect chmod to work Johannes Schindelin
2016-01-25 2:14 ` Junio C Hamano
2016-01-26 6:31 ` Johannes Schindelin
2016-01-26 17:42 ` Junio C Hamano
2016-01-24 15:45 ` [PATCH 18/19] mingw: skip a couple of git-svn tests that cannot pass on Windows Johannes Schindelin
2016-01-25 2:16 ` Junio C Hamano
2016-01-26 6:45 ` Johannes Schindelin
2016-01-24 15:45 ` [PATCH 19/19] mingw: do not bother to test funny file names Johannes Schindelin
2016-01-25 1:34 ` [PATCH 00/19] Let Git's tests pass on Windows Junio C Hamano
2016-01-25 15:45 ` Johannes Schindelin
2016-01-26 14:34 ` [PATCH v2 " Johannes Schindelin
2016-01-26 14:34 ` [PATCH v2 01/19] mingw: let's use gettext with MSYS2 Johannes Schindelin
2016-01-26 14:34 ` [PATCH v2 02/19] mingw: do not trust MSYS2's MinGW gettext.sh Johannes Schindelin
2016-01-26 14:34 ` [PATCH v2 03/19] Git.pm: stop assuming that absolute paths start with a slash Johannes Schindelin
2016-01-26 14:34 ` [PATCH v2 04/19] mingw: factor out Windows specific environment setup Johannes Schindelin
2016-01-26 14:34 ` [PATCH v2 05/19] mingw: prepare the TMPDIR environment variable for shell scripts Johannes Schindelin
2016-01-26 14:34 ` [PATCH v2 06/19] mingw: try to delete target directory before renaming Johannes Schindelin
2016-01-26 14:34 ` [PATCH v2 07/19] mingw: let lstat() fail with errno == ENOTDIR when appropriate Johannes Schindelin
2016-01-26 14:34 ` [PATCH v2 08/19] mingw: fix t5601-clone.sh Johannes Schindelin
2016-01-26 14:35 ` [PATCH v2 09/19] mingw: accomodate t0060-path-utils for MSYS2 Johannes Schindelin
2016-01-26 14:35 ` [PATCH v2 10/19] mingw: disable mkfifo-based tests Johannes Schindelin
2016-01-26 14:35 ` [PATCH v2 11/19] tests: turn off git-daemon tests if FIFOs are not available Johannes Schindelin
2016-01-26 14:35 ` [PATCH v2 12/19] mingw: skip test in t1508 that fails due to path conversion Johannes Schindelin
2016-01-26 22:02 ` Junio C Hamano
2016-01-27 8:50 ` Johannes Schindelin
2016-01-27 20:23 ` Junio C Hamano
2016-01-28 7:58 ` Johannes Schindelin
2016-01-26 14:35 ` [PATCH v2 13/19] mingw: fix t9700's assumption about directory separators Johannes Schindelin
2016-01-26 14:35 ` [PATCH v2 14/19] mingw: work around pwd issues in the tests Johannes Schindelin
2016-01-26 14:35 ` [PATCH v2 15/19] Avoid absolute path in t0008 Johannes Schindelin
2016-01-26 14:35 ` [PATCH v2 16/19] mingw: mark t9100's test cases with appropriate prereqs Johannes Schindelin
2016-01-26 21:50 ` Junio C Hamano
2016-01-27 16:02 ` Johannes Schindelin
2016-01-26 14:35 ` [PATCH v2 17/19] mingw: avoid illegal filename in t9118 Johannes Schindelin
2016-01-26 14:35 ` [PATCH v2 18/19] mingw: handle the missing POSIXPERM prereq in t9124 Johannes Schindelin
2016-01-26 22:05 ` Junio C Hamano
2016-01-27 9:20 ` Johannes Schindelin
2016-01-26 14:35 ` [PATCH v2 19/19] mingw: do not bother to test funny file names Johannes Schindelin
2016-01-26 20:03 ` Eric Sunshine
2016-01-26 20:24 ` Junio C Hamano
2016-01-27 8:33 ` Johannes Schindelin
2016-01-26 22:12 ` [PATCH v2 00/19] Let Git's tests pass on Windows Junio C Hamano
2016-01-27 8:38 ` Johannes Schindelin
2016-01-27 20:24 ` Junio C Hamano
2016-01-27 16:19 ` [PATCH v3 00/20] " Johannes Schindelin
2016-01-27 16:19 ` [PATCH v3 01/20] mingw: let's use gettext with MSYS2 Johannes Schindelin
2016-01-27 16:19 ` [PATCH v3 02/20] mingw: do not trust MSYS2's MinGW gettext.sh Johannes Schindelin
2016-01-27 16:19 ` [PATCH v3 03/20] Git.pm: stop assuming that absolute paths start with a slash Johannes Schindelin
2016-01-27 16:19 ` [PATCH v3 04/20] mingw: factor out Windows specific environment setup Johannes Schindelin
2016-01-27 16:19 ` [PATCH v3 05/20] mingw: prepare the TMPDIR environment variable for shell scripts Johannes Schindelin
2016-01-27 16:19 ` [PATCH v3 06/20] mingw: try to delete target directory before renaming Johannes Schindelin
2016-01-27 16:19 ` [PATCH v3 07/20] mingw: let lstat() fail with errno == ENOTDIR when appropriate Johannes Schindelin
2016-01-27 16:19 ` [PATCH v3 08/20] mingw: fix t5601-clone.sh Johannes Schindelin
2016-01-27 16:19 ` [PATCH v3 09/20] mingw: accomodate t0060-path-utils for MSYS2 Johannes Schindelin
2016-01-27 16:19 ` [PATCH v3 10/20] mingw: disable mkfifo-based tests Johannes Schindelin
2016-01-27 16:19 ` [PATCH v3 11/20] tests: turn off git-daemon tests if FIFOs are not available Johannes Schindelin
2016-01-28 8:21 ` Eric Sunshine
2016-01-28 8:40 ` Johannes Schindelin
2016-01-28 21:35 ` Junio C Hamano
2016-01-27 16:19 ` [PATCH v3 12/20] mingw: skip test in t1508 that fails due to path conversion Johannes Schindelin
2016-01-27 16:19 ` [PATCH v3 13/20] mingw: fix t9700's assumption about directory separators Johannes Schindelin
2016-01-27 16:19 ` [PATCH v3 14/20] mingw: work around pwd issues in the tests Johannes Schindelin
2016-01-27 16:20 ` [PATCH v3 15/20] Avoid absolute path in t0008 Johannes Schindelin
2016-01-27 16:20 ` [PATCH v3 16/20] mingw: mark t9100's test cases with appropriate prereqs Johannes Schindelin
2016-01-27 16:33 ` Johannes Schindelin
2016-01-27 16:20 ` [PATCH v3 17/20] mingw: avoid illegal filename in t9118 Johannes Schindelin
2016-01-27 16:20 ` [PATCH v3 18/20] mingw: handle the missing POSIXPERM prereq in t9124 Johannes Schindelin
2016-01-27 16:20 ` [PATCH v3 19/20] mingw: skip a test in t9130 that cannot pass on Windows Johannes Schindelin
2016-01-27 16:20 ` [PATCH v3 20/20] mingw: do not bother to test funny file names Johannes Schindelin
2016-01-28 8:42 ` [PATCH v3 00/20] Let Git's tests pass on Windows Eric Sunshine
2016-01-28 8:57 ` Johannes Schindelin
2016-01-28 21:37 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=56A52B28.8010304@kdbg.org \
--to=j6t@kdbg.org \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=johannes.schindelin@gmx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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 NNTP newsgroup(s).