@@ -10,20 +10,27 @@ TEST_PASSES_SANITIZE_LEAK=true
10
10
11
11
norm_path () {
12
12
expected=$( test-tool path-utils print_path " $2 " )
13
- test_expect_success $3 " normalize path: $1 => $2 " \
14
- " test \"\$ (test-tool path-utils normalize_path_copy '$1 ')\" = '$expected '"
13
+ test_expect_success $3 " normalize path: $1 => $2 " "
14
+ echo '$expected ' >expect &&
15
+ test-tool path-utils normalize_path_copy '$1 ' >actual &&
16
+ test_cmp expect actual
17
+ "
15
18
}
16
19
17
20
relative_path () {
18
21
expected=$( test-tool path-utils print_path " $3 " )
19
- test_expect_success $4 " relative path: $1 $2 => $3 " \
20
- " test \"\$ (test-tool path-utils relative_path '$1 ' '$2 ')\" = '$expected '"
22
+ test_expect_success $4 " relative path: $1 $2 => $3 " "
23
+ echo '$expected ' >expect &&
24
+ test-tool path-utils relative_path '$1 ' '$2 ' >actual &&
25
+ test_cmp expect actual
26
+ "
21
27
}
22
28
23
29
test_submodule_relative_url () {
24
30
test_expect_success " test_submodule_relative_url: $1 $2 $3 => $4 " "
25
- actual=\$ (test-tool submodule resolve-relative-url '$1 ' '$2 ' '$3 ') &&
26
- test \"\$ actual\" = '$4 '
31
+ echo '$4 ' >expect &&
32
+ test-tool submodule resolve-relative-url '$1 ' '$2 ' '$3 ' >actual &&
33
+ test_cmp expect actual
27
34
"
28
35
}
29
36
@@ -64,9 +71,11 @@ ancestor() {
64
71
expected=$(( $expected - $rootslash + $rootoff ))
65
72
;;
66
73
esac
67
- test_expect_success $4 " longest ancestor: $1 $2 => $expected " \
68
- " actual=\$ (test-tool path-utils longest_ancestor_length '$1 ' '$2 ') &&
69
- test \"\$ actual\" = '$expected '"
74
+ test_expect_success $4 " longest ancestor: $1 $2 => $expected " "
75
+ echo '$expected ' >expect &&
76
+ test-tool path-utils longest_ancestor_length '$1 ' '$2 ' >actual &&
77
+ test_cmp expect actual
78
+ "
70
79
}
71
80
72
81
# Some absolute path tests should be skipped on Windows due to path mangling
@@ -166,8 +175,10 @@ ancestor D:/Users/me C:/ -1 MINGW
166
175
ancestor //server/share/my-directory //server/share/ 14 MINGW
167
176
168
177
test_expect_success ' strip_path_suffix' '
169
- test c:/msysgit = $(test-tool path-utils strip_path_suffix \
170
- c:/msysgit/libexec//git-core libexec/git-core)
178
+ echo c:/msysgit >expect &&
179
+ test-tool path-utils strip_path_suffix \
180
+ c:/msysgit/libexec//git-core libexec/git-core >actual &&
181
+ test_cmp expect actual
171
182
'
172
183
173
184
test_expect_success ' absolute path rejects the empty string' '
@@ -188,35 +199,61 @@ test_expect_success 'real path rejects the empty string' '
188
199
'
189
200
190
201
test_expect_success POSIX ' real path works on absolute paths 1' '
202
+ echo / >expect &&
203
+ test-tool path-utils real_path "/" >actual &&
204
+ test_cmp expect actual &&
205
+
191
206
nopath="hopefully-absent-path" &&
192
- test "/" = "$(test-tool path-utils real_path "/")" &&
193
- test "/$nopath" = "$(test-tool path-utils real_path "/$nopath")"
207
+ echo "/$nopath" >expect &&
208
+ test-tool path-utils real_path "/$nopath" >actual &&
209
+ test_cmp expect actual
194
210
'
195
211
196
212
test_expect_success ' real path works on absolute paths 2' '
197
- nopath="hopefully-absent-path" &&
198
213
# Find an existing top-level directory for the remaining tests:
199
214
d=$(pwd -P | sed -e "s|^\([^/]*/[^/]*\)/.*|\1|") &&
200
- test "$d" = "$(test-tool path-utils real_path "$d")" &&
201
- test "$d/$nopath" = "$(test-tool path-utils real_path "$d/$nopath")"
215
+ echo "$d" >expect &&
216
+ test-tool path-utils real_path "$d" >actual &&
217
+ test_cmp expect actual &&
218
+
219
+ nopath="hopefully-absent-path" &&
220
+ echo "$d/$nopath" >expect &&
221
+ test-tool path-utils real_path "$d/$nopath" >actual &&
222
+ test_cmp expect actual
202
223
'
203
224
204
225
test_expect_success POSIX ' real path removes extra leading slashes' '
226
+ echo "/" >expect &&
227
+ test-tool path-utils real_path "///" >actual &&
228
+ test_cmp expect actual &&
229
+
205
230
nopath="hopefully-absent-path" &&
206
- test "/" = "$(test-tool path-utils real_path "///")" &&
207
- test "/$nopath" = "$(test-tool path-utils real_path "///$nopath")" &&
231
+ echo "/$nopath" >expect &&
232
+ test-tool path-utils real_path "///$nopath" >actual &&
233
+ test_cmp expect actual &&
234
+
208
235
# Find an existing top-level directory for the remaining tests:
209
236
d=$(pwd -P | sed -e "s|^\([^/]*/[^/]*\)/.*|\1|") &&
210
- test "$d" = "$(test-tool path-utils real_path "//$d")" &&
211
- test "$d/$nopath" = "$(test-tool path-utils real_path "//$d/$nopath")"
237
+ echo "$d" >expect &&
238
+ test-tool path-utils real_path "//$d" >actual &&
239
+ test_cmp expect actual &&
240
+
241
+ echo "$d/$nopath" >expect &&
242
+ test-tool path-utils real_path "//$d/$nopath" >actual &&
243
+ test_cmp expect actual
212
244
'
213
245
214
246
test_expect_success ' real path removes other extra slashes' '
215
- nopath="hopefully-absent-path" &&
216
247
# Find an existing top-level directory for the remaining tests:
217
248
d=$(pwd -P | sed -e "s|^\([^/]*/[^/]*\)/.*|\1|") &&
218
- test "$d" = "$(test-tool path-utils real_path "$d///")" &&
219
- test "$d/$nopath" = "$(test-tool path-utils real_path "$d///$nopath")"
249
+ echo "$d" >expect &&
250
+ test-tool path-utils real_path "$d///" >actual &&
251
+ test_cmp expect actual &&
252
+
253
+ nopath="hopefully-absent-path" &&
254
+ echo "$d/$nopath" >expect &&
255
+ test-tool path-utils real_path "$d///$nopath" >actual &&
256
+ test_cmp expect actual
220
257
'
221
258
222
259
test_expect_success SYMLINKS ' real path works on symlinks' '
@@ -227,19 +264,29 @@ test_expect_success SYMLINKS 'real path works on symlinks' '
227
264
mkdir third &&
228
265
dir="$(cd .git && pwd -P)" &&
229
266
dir2=third/../second/other/.git &&
230
- test "$dir" = "$(test-tool path-utils real_path $dir2)" &&
267
+ echo "$dir" >expect &&
268
+ test-tool path-utils real_path $dir2 >actual &&
269
+ test_cmp expect actual &&
231
270
file="$dir"/index &&
232
- test "$file" = "$(test-tool path-utils real_path $dir2/index)" &&
271
+ echo "$file" >expect &&
272
+ test-tool path-utils real_path $dir2/index >actual &&
273
+ test_cmp expect actual &&
233
274
basename=blub &&
234
- test "$dir/$basename" = "$(cd .git && test-tool path-utils real_path "$basename")" &&
275
+ echo "$dir/$basename" >expect &&
276
+ test-tool -C .git path-utils real_path "$basename" >actual &&
277
+ test_cmp expect actual &&
235
278
ln -s ../first/file .git/syml &&
236
279
sym="$(cd first && pwd -P)"/file &&
237
- test "$sym" = "$(test-tool path-utils real_path "$dir2/syml")"
280
+ echo "$sym" >expect &&
281
+ test-tool path-utils real_path "$dir2/syml" >actual &&
282
+ test_cmp expect actual
238
283
'
239
284
240
285
test_expect_success SYMLINKS ' prefix_path works with absolute paths to work tree symlinks' '
241
286
ln -s target symlink &&
242
- test "$(test-tool path-utils prefix_path prefix "$(pwd)/symlink")" = "symlink"
287
+ echo "symlink" >expect &&
288
+ test-tool path-utils prefix_path prefix "$(pwd)/symlink" >actual &&
289
+ test_cmp expect actual
243
290
'
244
291
245
292
test_expect_success ' prefix_path works with only absolute path to work tree' '
0 commit comments