path: root/t/
diff options
authorJiang Xin <>2013-06-25 15:53:57 (GMT)
committerJunio C Hamano <>2013-06-26 18:25:12 (GMT)
commitabd4284bc62127a2db69c8c81501a56bb29284c8 (patch)
tree1c21a7699b9267454c944f1c6fedca0c25d4a0d8 /t/
parentdb627fd568410499c47d764937c3d7a10bbadffa (diff)
test: run testcases with POSIX absolute paths on Windows
Some test cases are skipped on Windows by marking with POSIX prereq. This is because arguments look like absolute paths (such as /a/b) for regular Windows programs (*.exe executables, no bash scripts) are changed to Windows paths (like C:/msysgit/a/b). There is no cygpath nor equivalent on msysGit, but it is easy to write one. New subcommand "mingw_path" is added in test-path-utils, so that we can get the expected absolute paths on Windows. E.g. COMMAND LINE Linux output Windows output ================================== ============ =============== test-path-utils mingw_path / / C:/msysgit test-path-utils mingw_path /a/b/ /a/b/ C:/msysgit/a/b/ With this utility, most skipped test cases in t0060 can be turned on to be tested correctly on Windows. Signed-off-by: Jiang Xin <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 't/')
1 files changed, 23 insertions, 21 deletions
diff --git a/t/ b/t/
index 76c7792..3a48de2 100755
--- a/t/
+++ b/t/
@@ -8,13 +8,15 @@ test_description='Test various path utilities'
. ./
norm_path() {
+ expected=$(test-path-utils mingw_path "$2")
test_expect_success $3 "normalize path: $1 => $2" \
- "test \"\$(test-path-utils normalize_path_copy '$1')\" = '$2'"
+ "test \"\$(test-path-utils normalize_path_copy '$1')\" = '$expected'"
relative_path() {
+ expected=$(test-path-utils mingw_path "$3")
test_expect_success $4 "relative path: $1 $2 => $3" \
- "test \"\$(test-path-utils relative_path '$1' '$2')\" = '$3'"
+ "test \"\$(test-path-utils relative_path '$1' '$2')\" = '$expected'"
# On Windows, we are using MSYS's bash, which mangles the paths.
@@ -39,8 +41,8 @@ ancestor() {
test \"\$actual\" = '$expected'"
-# Absolute path tests must be skipped on Windows because due to path mangling
-# the test program never sees a POSIX-style absolute path
+# Some absolute path tests should be skipped on Windows due to path mangling
+# on POSIX-style absolute paths
case $(uname -s) in
@@ -73,30 +75,30 @@ norm_path d1/s1//../s2/../../d2 d2
norm_path d1/.../d2 d1/.../d2
norm_path d1/..././../d2 d1/d2
-norm_path / / POSIX
+norm_path / /
norm_path // / POSIX
norm_path /// / POSIX
-norm_path /. / POSIX
+norm_path /. /
norm_path /./ / POSIX
norm_path /./.. ++failed++ POSIX
-norm_path /../. ++failed++ POSIX
+norm_path /../. ++failed++
norm_path /./../.// ++failed++ POSIX
norm_path /dir/.. / POSIX
norm_path /dir/sub/../.. / POSIX
norm_path /dir/sub/../../.. ++failed++ POSIX
-norm_path /dir /dir POSIX
-norm_path /dir// /dir/ POSIX
-norm_path /./dir /dir POSIX
-norm_path /dir/. /dir/ POSIX
-norm_path /dir///./ /dir/ POSIX
-norm_path /dir//sub/.. /dir/ POSIX
-norm_path /dir/sub/../ /dir/ POSIX
+norm_path /dir /dir
+norm_path /dir// /dir/
+norm_path /./dir /dir
+norm_path /dir/. /dir/
+norm_path /dir///./ /dir/
+norm_path /dir//sub/.. /dir/
+norm_path /dir/sub/../ /dir/
norm_path //dir/sub/../. /dir/ POSIX
-norm_path /dir/s1/../s2/ /dir/s2/ POSIX
-norm_path /d1/s1///s2/..//../s3/ /d1/s3/ POSIX
-norm_path /d1/s1//../s2/../../d2 /d2 POSIX
-norm_path /d1/.../d2 /d1/.../d2 POSIX
-norm_path /d1/..././../d2 /d1/d2 POSIX
+norm_path /dir/s1/../s2/ /dir/s2/
+norm_path /d1/s1///s2/..//../s3/ /d1/s3/
+norm_path /d1/s1//../s2/../../d2 /d2
+norm_path /d1/.../d2 /d1/.../d2
+norm_path /d1/..././../d2 /d1/d2
ancestor / / -1
ancestor /foo / 0
@@ -198,8 +200,8 @@ relative_path / /a/b/ ../../
relative_path /a/c /a/b/ ../c
relative_path /a/c /a/b ../c
relative_path /x/y /a/b/ ../../x/y
-relative_path /a/b "<empty>" /a/b POSIX
-relative_path /a/b "<null>" /a/b POSIX
+relative_path /a/b "<empty>" /a/b
+relative_path /a/b "<null>" /a/b
relative_path a/b/c/ a/b/ c/
relative_path a/b/c/ a/b c/
relative_path a/b//c a//b c