t9146: replace test -d/-e/-f with appropriate test_path_is_* function

The helper functions test_path_is_* provide better debugging information than test -d/-e/-f. Replace "if ! test -d then <error message>" and "test -d" with "test_path_is_dir" at places where we check for existent directories. Replace "test -f" with "test_path_is_file" at places where we check for existent files. Replace "test ! -e" and "if test -d then <error message>" with "test_path_is_missing" where we check for non-existent directories. Helped-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Chandra Pratap <chandrapratap3519@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Chandra Pratap committed Feb 14, 2024 at 17:50 UTC c431a235e226daef39091940c7db4ab5067d4643
1 file changed +12 -44
t/t9146-git-svn-empty-dirs.sh
+12 -44
@@ -20,11 +20,7 @@ test_expect_success 'empty directories exist' '
20 cd cloned &&
21 for i in a b c d d/e d/e/f "weird file name"
22 do
23 - if ! test -d "$i"
24 - then
25 - echo >&2 "$i does not exist" &&
26 - exit 1
27 - fi
23 + test_path_is_dir "$i" || exit 1
24 done
25 )
26 '
@@ -37,11 +33,7 @@ test_expect_success 'option automkdirs set to false' '
33 git svn fetch &&
34 for i in a b c d d/e d/e/f "weird file name"
35 do
40 - if test -d "$i"
41 - then
42 - echo >&2 "$i exists" &&
43 - exit 1
44 - fi
36 + test_path_is_missing "$i" || exit 1
37 done
38 )
39 '
@@ -52,7 +44,7 @@ test_expect_success 'more emptiness' '
44
45 test_expect_success 'git svn rebase creates empty directory' '
46 ( cd cloned && git svn rebase ) &&
55 - test -d cloned/"! !"
47 + test_path_is_dir cloned/"! !"
48 '
49
50 test_expect_success 'git svn mkdirs recreates empty directories' '
@@ -62,11 +54,7 @@ test_expect_success 'git svn mkdirs recreates empty directories' '
54 git svn mkdirs &&
55 for i in a b c d d/e d/e/f "weird file name" "! !"
56 do
65 - if ! test -d "$i"
66 - then
67 - echo >&2 "$i does not exist" &&
68 - exit 1
69 - fi
57 + test_path_is_dir "$i" || exit 1
58 done
59 )
60 '
@@ -78,25 +66,13 @@ test_expect_success 'git svn mkdirs -r works' '
66 git svn mkdirs -r7 &&
67 for i in a b c d d/e d/e/f "weird file name"
68 do
81 - if ! test -d "$i"
82 - then
83 - echo >&2 "$i does not exist" &&
84 - exit 1
85 - fi
69 + test_path_is_dir "$i" || exit 1
70 done &&
71
88 - if test -d "! !"
89 - then
90 - echo >&2 "$i should not exist" &&
91 - exit 1
92 - fi &&
72 + test_path_is_missing "! !" || exit 1 &&
73
74 git svn mkdirs -r8 &&
95 - if ! test -d "! !"
96 - then
97 - echo >&2 "$i not exist" &&
98 - exit 1
99 - fi
75 + test_path_is_dir "! !" || exit 1
76 )
77 '
78
@@ -114,11 +90,7 @@ test_expect_success 'empty directories in trunk exist' '
90 cd trunk &&
91 for i in a "weird file name"
92 do
117 - if ! test -d "$i"
118 - then
119 - echo >&2 "$i does not exist" &&
120 - exit 1
121 - fi
93 + test_path_is_dir "$i" || exit 1
94 done
95 )
96 '
@@ -129,7 +101,7 @@ test_expect_success 'remove a top-level directory from svn' '
101
102 test_expect_success 'removed top-level directory does not exist' '
103 git svn clone "$svnrepo" removed &&
132 - test ! -e removed/d
104 + test_path_is_missing removed/d
105
106 '
107 unhandled=.git/svn/refs/remotes/git-svn/unhandled.log
@@ -143,15 +115,11 @@ test_expect_success 'git svn gc-ed files work' '
115 svn_cmd mkdir -m gz "$svnrepo"/gz &&
116 git reset --hard $(git rev-list HEAD | tail -1) &&
117 git svn rebase &&
146 - test -f "$unhandled".gz &&
147 - test -f "$unhandled" &&
118 + test_path_is_file "$unhandled".gz &&
119 + test_path_is_file "$unhandled" &&
120 for i in a b c "weird file name" gz "! !"
121 do
150 - if ! test -d "$i"
151 - then
152 - echo >&2 "$i does not exist" &&
153 - exit 1
154 - fi
122 + test_path_is_dir "$i" || exit 1
123 done
124 fi
125 )