t3200: clean up checks for file existence

This patch uses test_path_is_file and test_path_is_missing instead of "test -f / ! test -f" checks. The former are more verbose in case of failure and more precise (e.g., is_missing will check that the entry is actually missing, not just not a regular file). As a bonus, this also fixes a few buggy tests that used "test foo" instead of "test -f foo", and consequently always reported success. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Sep 13, 2011 at 12:13 UTC 376eb14a05f693378047eee36a10035c122f0261
1 file changed +25 -25
t/t3200-branch.sh
+25 -25
@@ -23,7 +23,7 @@ test_expect_success \
23 test_expect_success \
24 'git branch --help should not have created a bogus branch' '
25 git branch --help </dev/null >/dev/null 2>/dev/null;
26 - ! test -f .git/refs/heads/--help
26 + test_path_is_missing .git/refs/heads/--help
27 '
28
29 test_expect_success 'branch -h in broken repository' '
@@ -39,11 +39,11 @@ test_expect_success 'branch -h in broken repository' '
39
40 test_expect_success \
41 'git branch abc should create a branch' \
42 - 'git branch abc && test -f .git/refs/heads/abc'
42 + 'git branch abc && test_path_is_file .git/refs/heads/abc'
43
44 test_expect_success \
45 'git branch a/b/c should create a branch' \
46 - 'git branch a/b/c && test -f .git/refs/heads/a/b/c'
46 + 'git branch a/b/c && test_path_is_file .git/refs/heads/a/b/c'
47
48 cat >expect <<EOF
49 $_z40 $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 branch: Created from master
@@ -52,15 +52,15 @@ test_expect_success \
52 'git branch -l d/e/f should create a branch and a log' \
53 'GIT_COMMITTER_DATE="2005-05-26 23:30" \
54 git branch -l d/e/f &&
55 - test -f .git/refs/heads/d/e/f &&
56 - test -f .git/logs/refs/heads/d/e/f &&
55 + test_path_is_file .git/refs/heads/d/e/f &&
56 + test_path_is_file .git/logs/refs/heads/d/e/f &&
57 test_cmp expect .git/logs/refs/heads/d/e/f'
58
59 test_expect_success \
60 'git branch -d d/e/f should delete a branch and a log' \
61 'git branch -d d/e/f &&
62 - test ! -f .git/refs/heads/d/e/f &&
63 - test ! -f .git/logs/refs/heads/d/e/f'
62 + test_path_is_missing .git/refs/heads/d/e/f &&
63 + test_path_is_missing .git/logs/refs/heads/d/e/f'
64
65 test_expect_success \
66 'git branch j/k should work after branch j has been deleted' \
@@ -78,13 +78,13 @@ test_expect_success \
78 'git branch -m m m/m should work' \
79 'git branch -l m &&
80 git branch -m m m/m &&
81 - test -f .git/logs/refs/heads/m/m'
81 + test_path_is_file .git/logs/refs/heads/m/m'
82
83 test_expect_success \
84 'git branch -m n/n n should work' \
85 'git branch -l n/n &&
86 git branch -m n/n n
87 - test -f .git/logs/refs/heads/n'
87 + test_path_is_file .git/logs/refs/heads/n'
88
89 test_expect_success 'git branch -m o/o o should fail when o/p exists' '
90 git branch o/o &&
@@ -100,34 +100,34 @@ test_expect_success 'git branch -m q r/q should fail when r exists' '
100
101 test_expect_success 'git branch -v -d t should work' '
102 git branch t &&
103 - test .git/refs/heads/t &&
103 + test_path_is_file .git/refs/heads/t &&
104 git branch -v -d t &&
105 - test ! -f .git/refs/heads/t
105 + test_path_is_missing .git/refs/heads/t
106 '
107
108 test_expect_success 'git branch -v -m t s should work' '
109 git branch t &&
110 - test .git/refs/heads/t &&
110 + test_path_is_file .git/refs/heads/t &&
111 git branch -v -m t s &&
112 - test ! -f .git/refs/heads/t &&
113 - test -f .git/refs/heads/s &&
112 + test_path_is_missing .git/refs/heads/t &&
113 + test_path_is_file .git/refs/heads/s &&
114 git branch -d s
115 '
116
117 test_expect_success 'git branch -m -d t s should fail' '
118 git branch t &&
119 - test .git/refs/heads/t &&
119 + test_path_is_file .git/refs/heads/t &&
120 test_must_fail git branch -m -d t s &&
121 git branch -d t &&
122 - test ! -f .git/refs/heads/t
122 + test_path_is_missing .git/refs/heads/t
123 '
124
125 test_expect_success 'git branch --list -d t should fail' '
126 git branch t &&
127 - test .git/refs/heads/t &&
127 + test_path_is_file .git/refs/heads/t &&
128 test_must_fail git branch --list -d t &&
129 git branch -d t &&
130 - test ! -f .git/refs/heads/t
130 + test_path_is_missing .git/refs/heads/t
131 '
132
133 mv .git/config .git/config-saved
@@ -144,12 +144,12 @@ git config branch.s/s.dummy Hello
144 test_expect_success \
145 'git branch -m s/s s should work when s/t is deleted' \
146 'git branch -l s/s &&
147 - test -f .git/logs/refs/heads/s/s &&
147 + test_path_is_file .git/logs/refs/heads/s/s &&
148 git branch -l s/t &&
149 - test -f .git/logs/refs/heads/s/t &&
149 + test_path_is_file .git/logs/refs/heads/s/t &&
150 git branch -d s/t &&
151 git branch -m s/s s &&
152 - test -f .git/logs/refs/heads/s'
152 + test_path_is_file .git/logs/refs/heads/s'
153
154 test_expect_success 'config information was renamed, too' \
155 "test $(git config branch.s.dummy) = Hello &&
@@ -160,8 +160,8 @@ test_expect_success 'renaming a symref is not allowed' \
160 git symbolic-ref refs/heads/master2 refs/heads/master &&
161 test_must_fail git branch -m master2 master3 &&
162 git symbolic-ref refs/heads/master2 &&
163 - test -f .git/refs/heads/master &&
164 - ! test -f .git/refs/heads/master3
163 + test_path_is_file .git/refs/heads/master &&
164 + test_path_is_missing .git/refs/heads/master3
165 '
166
167 test_expect_success SYMLINKS \
@@ -270,8 +270,8 @@ test_expect_success \
270 'git checkout -b g/h/i -l should create a branch and a log' \
271 'GIT_COMMITTER_DATE="2005-05-26 23:30" \
272 git checkout -b g/h/i -l master &&
273 - test -f .git/refs/heads/g/h/i &&
274 - test -f .git/logs/refs/heads/g/h/i &&
273 + test_path_is_file .git/refs/heads/g/h/i &&
274 + test_path_is_file .git/logs/refs/heads/g/h/i &&
275 test_cmp expect .git/logs/refs/heads/g/h/i'
276
277 test_expect_success 'checkout -b makes reflog by default' '