@@ -8,15 +8,15 @@ test_description='Test various path utilities'
8
8
. ./test-lib.sh
9
9
10
10
norm_path () {
11
- expected=$( test-path-utils print_path " $2 " )
11
+ expected=$( test-tool path-utils print_path " $2 " )
12
12
test_expect_success $3 " normalize path: $1 => $2 " \
13
- " test \"\$ (test-path-utils normalize_path_copy '$1 ')\" = '$expected '"
13
+ " test \"\$ (test-tool path-utils normalize_path_copy '$1 ')\" = '$expected '"
14
14
}
15
15
16
16
relative_path () {
17
- expected=$( test-path-utils print_path " $3 " )
17
+ expected=$( test-tool path-utils print_path " $3 " )
18
18
test_expect_success $4 " relative path: $1 $2 => $3 " \
19
- " test \"\$ (test-path-utils relative_path '$1 ' '$2 ')\" = '$expected '"
19
+ " test \"\$ (test-tool path-utils relative_path '$1 ' '$2 ')\" = '$expected '"
20
20
}
21
21
22
22
test_submodule_relative_url () {
@@ -37,7 +37,7 @@ test_git_path() {
37
37
# On Windows, we are using MSYS's bash, which mangles the paths.
38
38
# Absolute paths are anchored at the MSYS installation directory,
39
39
# which means that the path / accounts for this many characters:
40
- rootoff=$( test-path-utils normalize_path_copy / | wc -c)
40
+ rootoff=$( test-tool path-utils normalize_path_copy / | wc -c)
41
41
# Account for the trailing LF:
42
42
if test $rootoff = 2; then
43
43
rootoff= # we are on Unix
46
46
# In MSYS2, the root directory "/" is translated into a Windows
47
47
# directory *with* trailing slash. Let's test for that and adjust
48
48
# our expected longest ancestor length accordingly.
49
- case " $( test-path-utils print_path /) " in
49
+ case " $( test-tool path-utils print_path /) " in
50
50
* /) rootslash=1;;
51
51
* ) rootslash=0;;
52
52
esac
@@ -61,7 +61,7 @@ ancestor() {
61
61
expected=$(( $expected + $rootoff ))
62
62
fi
63
63
test_expect_success " longest ancestor: $1 $2 => $expected " \
64
- " actual=\$ (test-path-utils longest_ancestor_length '$1 ' '$2 ') &&
64
+ " actual=\$ (test-tool path-utils longest_ancestor_length '$1 ' '$2 ') &&
65
65
test \"\$ actual\" = '$expected '"
66
66
}
67
67
@@ -77,8 +77,8 @@ case $(uname -s) in
77
77
;;
78
78
esac
79
79
80
- test_expect_success basename ' test-path-utils basename'
81
- test_expect_success dirname ' test-path-utils dirname'
80
+ test_expect_success basename ' test-tool path-utils basename'
81
+ test_expect_success dirname ' test-tool path-utils dirname'
82
82
83
83
norm_path " " " "
84
84
norm_path . " "
@@ -157,48 +157,48 @@ ancestor /foo/bar /foo:/bar 4
157
157
ancestor /foo/bar /bar -1
158
158
159
159
test_expect_success ' strip_path_suffix' '
160
- test c:/msysgit = $(test-path-utils strip_path_suffix \
160
+ test c:/msysgit = $(test-tool path-utils strip_path_suffix \
161
161
c:/msysgit/libexec//git-core libexec/git-core)
162
162
'
163
163
164
164
test_expect_success ' absolute path rejects the empty string' '
165
- test_must_fail test-path-utils absolute_path ""
165
+ test_must_fail test-tool path-utils absolute_path ""
166
166
'
167
167
168
168
test_expect_success ' real path rejects the empty string' '
169
- test_must_fail test-path-utils real_path ""
169
+ test_must_fail test-tool path-utils real_path ""
170
170
'
171
171
172
172
test_expect_success POSIX ' real path works on absolute paths 1' '
173
173
nopath="hopefully-absent-path" &&
174
- test "/" = "$(test-path-utils real_path "/")" &&
175
- test "/$nopath" = "$(test-path-utils real_path "/$nopath")"
174
+ test "/" = "$(test-tool path-utils real_path "/")" &&
175
+ test "/$nopath" = "$(test-tool path-utils real_path "/$nopath")"
176
176
'
177
177
178
178
test_expect_success ' real path works on absolute paths 2' '
179
179
nopath="hopefully-absent-path" &&
180
180
# Find an existing top-level directory for the remaining tests:
181
181
d=$(pwd -P | sed -e "s|^\([^/]*/[^/]*\)/.*|\1|") &&
182
- test "$d" = "$(test-path-utils real_path "$d")" &&
183
- test "$d/$nopath" = "$(test-path-utils real_path "$d/$nopath")"
182
+ test "$d" = "$(test-tool path-utils real_path "$d")" &&
183
+ test "$d/$nopath" = "$(test-tool path-utils real_path "$d/$nopath")"
184
184
'
185
185
186
186
test_expect_success POSIX ' real path removes extra leading slashes' '
187
187
nopath="hopefully-absent-path" &&
188
- test "/" = "$(test-path-utils real_path "///")" &&
189
- test "/$nopath" = "$(test-path-utils real_path "///$nopath")" &&
188
+ test "/" = "$(test-tool path-utils real_path "///")" &&
189
+ test "/$nopath" = "$(test-tool path-utils real_path "///$nopath")" &&
190
190
# Find an existing top-level directory for the remaining tests:
191
191
d=$(pwd -P | sed -e "s|^\([^/]*/[^/]*\)/.*|\1|") &&
192
- test "$d" = "$(test-path-utils real_path "//$d")" &&
193
- test "$d/$nopath" = "$(test-path-utils real_path "//$d/$nopath")"
192
+ test "$d" = "$(test-tool path-utils real_path "//$d")" &&
193
+ test "$d/$nopath" = "$(test-tool path-utils real_path "//$d/$nopath")"
194
194
'
195
195
196
196
test_expect_success ' real path removes other extra slashes' '
197
197
nopath="hopefully-absent-path" &&
198
198
# Find an existing top-level directory for the remaining tests:
199
199
d=$(pwd -P | sed -e "s|^\([^/]*/[^/]*\)/.*|\1|") &&
200
- test "$d" = "$(test-path-utils real_path "$d///")" &&
201
- test "$d/$nopath" = "$(test-path-utils real_path "$d///$nopath")"
200
+ test "$d" = "$(test-tool path-utils real_path "$d///")" &&
201
+ test "$d/$nopath" = "$(test-tool path-utils real_path "$d///$nopath")"
202
202
'
203
203
204
204
test_expect_success SYMLINKS ' real path works on symlinks' '
@@ -209,35 +209,35 @@ test_expect_success SYMLINKS 'real path works on symlinks' '
209
209
mkdir third &&
210
210
dir="$(cd .git; pwd -P)" &&
211
211
dir2=third/../second/other/.git &&
212
- test "$dir" = "$(test-path-utils real_path $dir2)" &&
212
+ test "$dir" = "$(test-tool path-utils real_path $dir2)" &&
213
213
file="$dir"/index &&
214
- test "$file" = "$(test-path-utils real_path $dir2/index)" &&
214
+ test "$file" = "$(test-tool path-utils real_path $dir2/index)" &&
215
215
basename=blub &&
216
- test "$dir/$basename" = "$(cd .git && test-path-utils real_path "$basename")" &&
216
+ test "$dir/$basename" = "$(cd .git && test-tool path-utils real_path "$basename")" &&
217
217
ln -s ../first/file .git/syml &&
218
218
sym="$(cd first; pwd -P)"/file &&
219
- test "$sym" = "$(test-path-utils real_path "$dir2/syml")"
219
+ test "$sym" = "$(test-tool path-utils real_path "$dir2/syml")"
220
220
'
221
221
222
222
test_expect_success SYMLINKS ' prefix_path works with absolute paths to work tree symlinks' '
223
223
ln -s target symlink &&
224
- test "$(test-path-utils prefix_path prefix "$(pwd)/symlink")" = "symlink"
224
+ test "$(test-tool path-utils prefix_path prefix "$(pwd)/symlink")" = "symlink"
225
225
'
226
226
227
227
test_expect_success ' prefix_path works with only absolute path to work tree' '
228
228
echo "" >expected &&
229
- test-path-utils prefix_path prefix "$(pwd)" >actual &&
229
+ test-tool path-utils prefix_path prefix "$(pwd)" >actual &&
230
230
test_cmp expected actual
231
231
'
232
232
233
233
test_expect_success ' prefix_path rejects absolute path to dir with same beginning as work tree' '
234
- test_must_fail test-path-utils prefix_path prefix "$(pwd)a"
234
+ test_must_fail test-tool path-utils prefix_path prefix "$(pwd)a"
235
235
'
236
236
237
237
test_expect_success SYMLINKS ' prefix_path works with absolute path to a symlink to work tree having same beginning as work tree' '
238
238
git init repo &&
239
239
ln -s repo repolink &&
240
- test "a" = "$(cd repo && test-path-utils prefix_path prefix "$(pwd)/../repolink/a")"
240
+ test "a" = "$(cd repo && test-tool path-utils prefix_path prefix "$(pwd)/../repolink/a")"
241
241
'
242
242
243
243
relative_path /foo/a/b/c/ /foo/a/b/ c/
0 commit comments