Skip to content

Commit 432dbe6

Browse files
committed
[GSoC Patch] Modernize Test Path Checking in Git’s Test Suite
test -(e|f|d) does not provide a proper error message when hit test failures. So test_path_exists, test_path_is_dir, test_parh_is_file used. Added changes for files from t/t0007-git-var.sh to t/t1700-split-index.sh. Signed-off-by: Sampriyo Guin <[email protected]>
1 parent 683c54c commit 432dbe6

12 files changed

+35
-35
lines changed

t/t0007-git-var.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ test_expect_success POSIXPERM 'GIT_SHELL_PATH points to a valid executable' '
156156
test_expect_success MINGW 'GIT_SHELL_PATH points to a suitable shell' '
157157
shellpath=$(git var GIT_SHELL_PATH) &&
158158
case "$shellpath" in
159-
[A-Z]:/*/sh.exe) test -f "$shellpath";;
159+
[A-Z]:/*/sh.exe) test_path_is_file "$shellpath";;
160160
*) return 1;;
161161
esac
162162
'

t/t0081-find-pack.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ test_expect_success 'repack everything into a single packfile' '
3232
".git/objects/pack/pack-"*".pack") true ;;
3333
*) false ;;
3434
esac &&
35-
test -f "$head_commit_pack" &&
35+
test_path_is_file "$head_commit_pack" &&
3636
3737
# Everything is in the same pack
3838
test "$head_commit_pack" = "$head_tree_pack" &&

t/t0200-gettext-basic.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ test_expect_success 'xgettext sanity: Comment extraction with --add-comments sto
3131
'
3232

3333
test_expect_success GETTEXT 'sanity: $TEXTDOMAINDIR exists without NO_GETTEXT=YesPlease' '
34-
test -d "$TEXTDOMAINDIR" &&
34+
test_path_is_dir "$TEXTDOMAINDIR" &&
3535
test "$TEXTDOMAINDIR" = "$GIT_TEXTDOMAINDIR"
3636
'
3737

3838
test_expect_success GETTEXT 'sanity: Icelandic locale was compiled' '
39-
test -f "$TEXTDOMAINDIR/is/LC_MESSAGES/git.mo"
39+
test_path_is_file "$TEXTDOMAINDIR/is/LC_MESSAGES/git.mo"
4040
'
4141

4242
# TODO: When we have more locales, generalize this to test them

t/t0410-partial-clone.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ test_expect_success 'gc stops traversal when a missing but promised object is re
606606
git -C repo gc &&
607607
608608
# Ensure that the promisor packfile still exists, and remove it
609-
test -e repo/.git/objects/pack/pack-$HASH.pack &&
609+
test_path_exists repo/.git/objects/pack/pack-$HASH.pack &&
610610
rm repo/.git/objects/pack/pack-$HASH.* &&
611611
612612
# Ensure that the single other pack contains the commit, but not the tree

t/t0601-reffiles-pack-refs.sh

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,13 @@ test_expect_success 'see if a branch still exists after git pack-refs --prune' '
7878
test_expect_success 'see if git pack-refs --prune remove ref files' '
7979
git branch f &&
8080
git pack-refs --all --prune &&
81-
! test -f .git/refs/heads/f
81+
! test_path_is_file .git/refs/heads/f
8282
'
8383

8484
test_expect_success 'see if git pack-refs --prune removes empty dirs' '
8585
git branch r/s/t &&
8686
git pack-refs --all --prune &&
87-
! test -e .git/refs/heads/r
87+
! test_path_exists .git/refs/heads/r
8888
'
8989

9090
test_expect_success 'git branch g should work when git branch g/h has been deleted' '
@@ -128,43 +128,43 @@ test_expect_success 'test excluded refs are not packed' '
128128
git branch dont_pack2 &&
129129
git branch pack_this &&
130130
git pack-refs --all --exclude "refs/heads/dont_pack*" &&
131-
test -f .git/refs/heads/dont_pack1 &&
132-
test -f .git/refs/heads/dont_pack2 &&
133-
! test -f .git/refs/heads/pack_this'
131+
test_path_is_file .git/refs/heads/dont_pack1 &&
132+
test_path_is_file .git/refs/heads/dont_pack2 &&
133+
! test_path_is_file .git/refs/heads/pack_this'
134134

135135
test_expect_success 'test --no-exclude refs clears excluded refs' '
136136
git branch dont_pack3 &&
137137
git branch dont_pack4 &&
138138
git pack-refs --all --exclude "refs/heads/dont_pack*" --no-exclude &&
139-
! test -f .git/refs/heads/dont_pack3 &&
140-
! test -f .git/refs/heads/dont_pack4'
139+
! test_path_is_file .git/refs/heads/dont_pack3 &&
140+
! test_path_is_file .git/refs/heads/dont_pack4'
141141

142142
test_expect_success 'test only included refs are packed' '
143143
git branch pack_this1 &&
144144
git branch pack_this2 &&
145145
git tag dont_pack5 &&
146146
git pack-refs --include "refs/heads/pack_this*" &&
147-
test -f .git/refs/tags/dont_pack5 &&
148-
! test -f .git/refs/heads/pack_this1 &&
149-
! test -f .git/refs/heads/pack_this2'
147+
test_path_is_file .git/refs/tags/dont_pack5 &&
148+
! test_path_is_file .git/refs/heads/pack_this1 &&
149+
! test_path_is_file .git/refs/heads/pack_this2'
150150

151151
test_expect_success 'test --no-include refs clears included refs' '
152152
git branch pack1 &&
153153
git branch pack2 &&
154154
git pack-refs --include "refs/heads/pack*" --no-include &&
155-
test -f .git/refs/heads/pack1 &&
156-
test -f .git/refs/heads/pack2'
155+
test_path_is_file .git/refs/heads/pack1 &&
156+
test_path_is_file .git/refs/heads/pack2'
157157

158158
test_expect_success 'test --exclude takes precedence over --include' '
159159
git branch dont_pack5 &&
160160
git pack-refs --include "refs/heads/pack*" --exclude "refs/heads/pack*" &&
161-
test -f .git/refs/heads/dont_pack5'
161+
test_path_is_file .git/refs/heads/dont_pack5'
162162

163163
test_expect_success 'see if up-to-date packed refs are preserved' '
164164
git branch q &&
165165
git pack-refs --all --prune &&
166166
git update-ref refs/heads/q refs/heads/q &&
167-
! test -f .git/refs/heads/q
167+
! test_path_is_file .git/refs/heads/q
168168
'
169169

170170
test_expect_success 'pack, prune and repack' '

t/t1001-read-tree-m-2way.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ test_expect_success 'a/b (untracked) vs a case setup.' '
362362
test_expect_success 'a/b (untracked) vs a, plus c/d case test.' '
363363
read_tree_u_must_fail -u -m "$treeH" "$treeM" &&
364364
git ls-files --stage &&
365-
test -f a/b
365+
test_path_is_file a/b
366366
'
367367

368368
test_expect_success 'read-tree supports the super-prefix' '

t/t1005-read-tree-reset.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ test_expect_success 'reset should remove remnants from a failed merge' '
4040
git ls-files -s &&
4141
read_tree_u_must_succeed --reset -u HEAD &&
4242
git ls-files -s >actual &&
43-
! test -f old &&
43+
! test_path_is_file old &&
4444
test_cmp expect actual
4545
'
4646

@@ -56,7 +56,7 @@ test_expect_success 'two-way reset should remove remnants too' '
5656
git ls-files -s &&
5757
read_tree_u_must_succeed --reset -u HEAD HEAD &&
5858
git ls-files -s >actual &&
59-
! test -f old &&
59+
! test_path_is_file old &&
6060
test_cmp expect actual
6161
'
6262

@@ -72,7 +72,7 @@ test_expect_success 'Porcelain reset should remove remnants too' '
7272
git ls-files -s &&
7373
git reset --hard &&
7474
git ls-files -s >actual &&
75-
! test -f old &&
75+
! test_path_is_file old &&
7676
test_cmp expect actual
7777
'
7878

@@ -88,7 +88,7 @@ test_expect_success 'Porcelain checkout -f should remove remnants too' '
8888
git ls-files -s &&
8989
git checkout -f &&
9090
git ls-files -s >actual &&
91-
! test -f old &&
91+
! test_path_is_file old &&
9292
test_cmp expect actual
9393
'
9494

@@ -104,7 +104,7 @@ test_expect_success 'Porcelain checkout -f HEAD should remove remnants too' '
104104
git ls-files -s &&
105105
git checkout -f HEAD &&
106106
git ls-files -s >actual &&
107-
! test -f old &&
107+
! test_path_is_file old &&
108108
test_cmp expect actual
109109
'
110110

t/t1300-config.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,11 +1236,11 @@ test_expect_success SYMLINKS 'symlinked configuration' '
12361236
ln -s notyet myconfig &&
12371237
git config --file=myconfig test.frotz nitfol &&
12381238
test -h myconfig &&
1239-
test -f notyet &&
1239+
test_path_is_file notyet &&
12401240
test "z$(git config --file=notyet test.frotz)" = znitfol &&
12411241
git config --file=myconfig test.xyzzy rezrov &&
12421242
test -h myconfig &&
1243-
test -f notyet &&
1243+
test_path_is_file notyet &&
12441244
cat >expect <<-\EOF &&
12451245
nitfol
12461246
rezrov

t/t1403-show-ref.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ test_expect_success 'show-ref --verify with dangling ref' '
196196
197197
remove_object() {
198198
file=$(sha1_file "$*") &&
199-
test -e "$file" &&
199+
test_path_exists "$file" &&
200200
rm -f "$file"
201201
} &&
202202

t/t1410-reflog.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,10 @@ test_expect_success 'pass through -- to sub-command' '
130130

131131
test_expect_success rewind '
132132
test_tick && git reset --hard HEAD~2 &&
133-
test -f C &&
134-
test -f A/B/E &&
135-
! test -f F &&
136-
! test -f A/G &&
133+
test_path_is_file C &&
134+
test_path_is_file A/B/E &&
135+
! test_path_is_file F &&
136+
! test_path_is_file A/G &&
137137
138138
check_have A B C D E F G H I J K L &&
139139

0 commit comments

Comments
 (0)