8
. ./test-lib.sh
9
10
norm_path() {
11
+ expected=$(test-path-utils mingw_path "$2")
12
test_expect_success $3 "normalize path: $1 => $2" \
12
- "test \"\$(test-path-utils normalize_path_copy '$1')\" = '$2'"
13
+ "test \"\$(test-path-utils normalize_path_copy '$1')\" = '$expected'"
14
}
15
16
relative_path() {
17
+ expected=$(test-path-utils mingw_path "$3")
18
test_expect_success $4 "relative path: $1 $2 => $3" \
17
- "test \"\$(test-path-utils relative_path '$1' '$2')\" = '$3'"
19
+ "test \"\$(test-path-utils relative_path '$1' '$2')\" = '$expected'"
20
}
21
22
# On Windows, we are using MSYS's bash, which mangles the paths.
41
test \"\$actual\" = '$expected'"
42
}
43
42
-# Absolute path tests must be skipped on Windows because due to path mangling
43
-# the test program never sees a POSIX-style absolute path
44
+# Some absolute path tests should be skipped on Windows due to path mangling
45
+# on POSIX-style absolute paths
46
case $(uname -s) in
47
*MINGW*)
48
;;
75
norm_path d1/.../d2 d1/.../d2
76
norm_path d1/..././../d2 d1/d2
77
76
-norm_path / / POSIX
78
+norm_path / /
79
norm_path // / POSIX
80
norm_path /// / POSIX
79
-norm_path /. / POSIX
81
+norm_path /. /
82
norm_path /./ / POSIX
83
norm_path /./.. ++failed++ POSIX
82
-norm_path /../. ++failed++ POSIX
84
+norm_path /../. ++failed++
85
norm_path /./../.// ++failed++ POSIX
86
norm_path /dir/.. / POSIX
87
norm_path /dir/sub/../.. / POSIX
88
norm_path /dir/sub/../../.. ++failed++ POSIX
87
-norm_path /dir /dir POSIX
88
-norm_path /dir// /dir/ POSIX
89
-norm_path /./dir /dir POSIX
90
-norm_path /dir/. /dir/ POSIX
91
-norm_path /dir///./ /dir/ POSIX
92
-norm_path /dir//sub/.. /dir/ POSIX
93
-norm_path /dir/sub/../ /dir/ POSIX
89
+norm_path /dir /dir
90
+norm_path /dir// /dir/
91
+norm_path /./dir /dir
92
+norm_path /dir/. /dir/
93
+norm_path /dir///./ /dir/
94
+norm_path /dir//sub/.. /dir/
95
+norm_path /dir/sub/../ /dir/
96
norm_path //dir/sub/../. /dir/ POSIX
95
-norm_path /dir/s1/../s2/ /dir/s2/ POSIX
96
-norm_path /d1/s1///s2/..//../s3/ /d1/s3/ POSIX
97
-norm_path /d1/s1//../s2/../../d2 /d2 POSIX
98
-norm_path /d1/.../d2 /d1/.../d2 POSIX
99
-norm_path /d1/..././../d2 /d1/d2 POSIX
97
+norm_path /dir/s1/../s2/ /dir/s2/
98
+norm_path /d1/s1///s2/..//../s3/ /d1/s3/
99
+norm_path /d1/s1//../s2/../../d2 /d2
100
+norm_path /d1/.../d2 /d1/.../d2
101
+norm_path /d1/..././../d2 /d1/d2
102
103
ancestor / / -1
104
ancestor /foo / 0
200
relative_path /a/c /a/b/ ../c
201
relative_path /a/c /a/b ../c
202
relative_path /x/y /a/b/ ../../x/y
201
-relative_path /a/b "<empty>" /a/b POSIX
202
-relative_path /a/b "<null>" /a/b POSIX
203
+relative_path /a/b "<empty>" /a/b
204
+relative_path /a/b "<null>" /a/b
205
relative_path a/b/c/ a/b/ c/
206
relative_path a/b/c/ a/b c/
207
relative_path a/b//c a//b c