Skip to content

Commit 168d575

Browse files
bkkaracaygitster
authored andcommitted
t2003: modernize path existence checks using test helpers
The old style 'test -f' and 'test -d' checks are silent on failure, which makes debugging difficult. Replace them with the 'test_path_is_*' helpers which provide verbose error messages when a test fails. Signed-off-by: Burak Kaan Karaçay <bkkaracay@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 67ad421 commit 168d575

1 file changed

Lines changed: 25 additions & 25 deletions

File tree

t/t2003-checkout-cache-mkdir.sh

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -24,70 +24,70 @@ test_expect_success SYMLINKS 'have symlink in place where dir is expected.' '
2424
mkdir path2 &&
2525
ln -s path2 path1 &&
2626
git checkout-index -f -a &&
27-
test ! -h path1 && test -d path1 &&
28-
test -f path1/file1 && test ! -f path2/file1
27+
test_path_is_dir_not_symlink path1 &&
28+
test_path_is_file path1/file1 &&
29+
test_path_is_missing path2/file1
2930
'
3031

3132
test_expect_success 'use --prefix=path2/' '
3233
rm -fr path0 path1 path2 &&
3334
mkdir path2 &&
3435
git checkout-index --prefix=path2/ -f -a &&
35-
test -f path2/path0 &&
36-
test -f path2/path1/file1 &&
37-
test ! -f path0 &&
38-
test ! -f path1/file1
36+
test_path_is_file path2/path0 &&
37+
test_path_is_file path2/path1/file1 &&
38+
test_path_is_missing path0 &&
39+
test_path_is_missing path1/file1
3940
'
4041

4142
test_expect_success 'use --prefix=tmp-' '
4243
rm -fr path0 path1 path2 tmp* &&
4344
git checkout-index --prefix=tmp- -f -a &&
44-
test -f tmp-path0 &&
45-
test -f tmp-path1/file1 &&
46-
test ! -f path0 &&
47-
test ! -f path1/file1
45+
test_path_is_file tmp-path0 &&
46+
test_path_is_file tmp-path1/file1 &&
47+
test_path_is_missing path0 &&
48+
test_path_is_missing path1/file1
4849
'
4950

5051
test_expect_success 'use --prefix=tmp- but with a conflicting file and dir' '
5152
rm -fr path0 path1 path2 tmp* &&
5253
echo nitfol >tmp-path1 &&
5354
mkdir tmp-path0 &&
5455
git checkout-index --prefix=tmp- -f -a &&
55-
test -f tmp-path0 &&
56-
test -f tmp-path1/file1 &&
57-
test ! -f path0 &&
58-
test ! -f path1/file1
56+
test_path_is_file tmp-path0 &&
57+
test_path_is_file tmp-path1/file1 &&
58+
test_path_is_missing path0 &&
59+
test_path_is_missing path1/file1
5960
'
6061

6162
test_expect_success SYMLINKS 'use --prefix=tmp/orary/ where tmp is a symlink' '
6263
rm -fr path0 path1 path2 tmp* &&
6364
mkdir tmp1 tmp1/orary &&
6465
ln -s tmp1 tmp &&
6566
git checkout-index --prefix=tmp/orary/ -f -a &&
66-
test -d tmp1/orary &&
67-
test -f tmp1/orary/path0 &&
68-
test -f tmp1/orary/path1/file1 &&
69-
test -h tmp
67+
test_path_is_dir tmp1/orary &&
68+
test_path_is_file tmp1/orary/path0 &&
69+
test_path_is_file tmp1/orary/path1/file1 &&
70+
test_path_is_symlink tmp
7071
'
7172

7273
test_expect_success SYMLINKS 'use --prefix=tmp/orary- where tmp is a symlink' '
7374
rm -fr path0 path1 path2 tmp* &&
7475
mkdir tmp1 &&
7576
ln -s tmp1 tmp &&
7677
git checkout-index --prefix=tmp/orary- -f -a &&
77-
test -f tmp1/orary-path0 &&
78-
test -f tmp1/orary-path1/file1 &&
79-
test -h tmp
78+
test_path_is_file tmp1/orary-path0 &&
79+
test_path_is_file tmp1/orary-path1/file1 &&
80+
test_path_is_symlink tmp
8081
'
8182

8283
test_expect_success SYMLINKS 'use --prefix=tmp- where tmp-path1 is a symlink' '
8384
rm -fr path0 path1 path2 tmp* &&
8485
mkdir tmp1 &&
8586
ln -s tmp1 tmp-path1 &&
8687
git checkout-index --prefix=tmp- -f -a &&
87-
test -f tmp-path0 &&
88-
test ! -h tmp-path1 &&
89-
test -d tmp-path1 &&
90-
test -f tmp-path1/file1
88+
test_path_is_file tmp-path0 &&
89+
test_path_is_dir_not_symlink tmp-path1 &&
90+
test_path_is_file tmp-path1/file1
9191
'
9292

9393
test_expect_success 'apply filter from working tree .gitattributes with --prefix' '

0 commit comments

Comments
 (0)