Skip to content

Commit 381e8e9

Browse files
committed
Merge branch 'dl/test-must-fail-fixes'
Test clean-up. * dl/test-must-fail-fixes: t1507: inline full_name() t1507: run commands within test_expect_success t1507: stop losing return codes of git commands t1501: remove use of `test_might_fail cp` t1409: use test_path_is_missing() t1409: let sed open its own input file t1307: reorder `nongit test_must_fail` t1306: convert `test_might_fail rm` to `rm -f` t0020: use ! check_packed_refs_marked t0020: don't use `test_must_fail has_cr` t0003: don't use `test_must_fail attr_check` t0003: use test_must_be_empty() t0003: use named parameters in attr_check() t0000: replace test_must_fail with run_sub_test_lib_test_err() t/lib-git-p4: use test_path_is_missing()
2 parents 5b0ca87 + b441717 commit 381e8e9

9 files changed

+112
-101
lines changed

t/lib-git-p4.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ stop_and_cleanup_p4d () {
175175

176176
cleanup_git () {
177177
retry_until_success rm -r "$git"
178-
test_must_fail test -d "$git" &&
178+
test_path_is_missing "$git" &&
179179
retry_until_success mkdir "$git"
180180
}
181181

t/t0000-basic.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ test_expect_success 'pretend we have a fully passing test suite' "
155155
"
156156

157157
test_expect_success 'pretend we have a partially passing test suite' "
158-
test_must_fail run_sub_test_lib_test \
158+
run_sub_test_lib_test_err \
159159
partial-pass '2/3 tests passing' <<-\\EOF &&
160160
test_expect_success 'passing test #1' 'true'
161161
test_expect_success 'failing test #2' 'false'
@@ -219,7 +219,7 @@ test_expect_success 'pretend we have fixed one of two known breakages (run in su
219219
"
220220

221221
test_expect_success 'pretend we have a pass, fail, and known breakage' "
222-
test_must_fail run_sub_test_lib_test \
222+
run_sub_test_lib_test_err \
223223
mixed-results1 'mixed results #1' <<-\\EOF &&
224224
test_expect_success 'passing test' 'true'
225225
test_expect_success 'failing test' 'false'
@@ -238,7 +238,7 @@ test_expect_success 'pretend we have a pass, fail, and known breakage' "
238238
"
239239

240240
test_expect_success 'pretend we have a mix of all possible results' "
241-
test_must_fail run_sub_test_lib_test \
241+
run_sub_test_lib_test_err \
242242
mixed-results2 'mixed results #2' <<-\\EOF &&
243243
test_expect_success 'passing test' 'true'
244244
test_expect_success 'passing test' 'true'
@@ -274,7 +274,7 @@ test_expect_success 'pretend we have a mix of all possible results' "
274274
"
275275

276276
test_expect_success C_LOCALE_OUTPUT 'test --verbose' '
277-
test_must_fail run_sub_test_lib_test \
277+
run_sub_test_lib_test_err \
278278
t1234-verbose "test verbose" --verbose <<-\EOF &&
279279
test_expect_success "passing test" true
280280
test_expect_success "test with output" "echo foo"
@@ -301,7 +301,7 @@ test_expect_success C_LOCALE_OUTPUT 'test --verbose' '
301301
'
302302

303303
test_expect_success 'test --verbose-only' '
304-
test_must_fail run_sub_test_lib_test \
304+
run_sub_test_lib_test_err \
305305
t2345-verbose-only-2 "test verbose-only=2" \
306306
--verbose-only=2 <<-\EOF &&
307307
test_expect_success "passing test" true
@@ -834,7 +834,7 @@ then
834834
fi
835835

836836
test_expect_success 'tests clean up even on failures' "
837-
test_must_fail run_sub_test_lib_test \
837+
run_sub_test_lib_test_err \
838838
failing-cleanup 'Failing tests with cleanup commands' <<-\\EOF &&
839839
test_expect_success 'tests clean up even after a failure' '
840840
touch clean-after-failure &&
@@ -863,7 +863,7 @@ test_expect_success 'tests clean up even on failures' "
863863
"
864864

865865
test_expect_success 'test_atexit is run' "
866-
test_must_fail run_sub_test_lib_test \
866+
run_sub_test_lib_test_err \
867867
atexit-cleanup 'Run atexit commands' -i <<-\\EOF &&
868868
test_expect_success 'tests clean up even after a failure' '
869869
> ../../clean-atexit &&

t/t0003-attributes.sh

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,16 @@ test_description=gitattributes
55
. ./test-lib.sh
66

77
attr_check () {
8-
path="$1" expect="$2"
8+
path="$1" expect="$2" git_opts="$3" &&
99

10-
git $3 check-attr test -- "$path" >actual 2>err &&
11-
echo "$path: test: $2" >expect &&
10+
git $git_opts check-attr test -- "$path" >actual 2>err &&
11+
echo "$path: test: $expect" >expect &&
1212
test_cmp expect actual &&
13-
test_line_count = 0 err
13+
test_must_be_empty err
1414
}
1515

1616
attr_check_quote () {
17-
18-
path="$1"
19-
quoted_path="$2"
20-
expect="$3"
17+
path="$1" quoted_path="$2" expect="$3" &&
2118

2219
git check-attr test -- "$path" >actual &&
2320
echo "\"$quoted_path\": test: $expect" >expect &&
@@ -27,7 +24,7 @@ attr_check_quote () {
2724

2825
test_expect_success 'open-quoted pathname' '
2926
echo "\"a test=a" >.gitattributes &&
30-
test_must_fail attr_check a a
27+
attr_check a unspecified
3128
'
3229

3330

@@ -112,20 +109,20 @@ test_expect_success 'attribute test' '
112109

113110
test_expect_success 'attribute matching is case sensitive when core.ignorecase=0' '
114111
115-
test_must_fail attr_check F f "-c core.ignorecase=0" &&
116-
test_must_fail attr_check a/F f "-c core.ignorecase=0" &&
117-
test_must_fail attr_check a/c/F f "-c core.ignorecase=0" &&
118-
test_must_fail attr_check a/G a/g "-c core.ignorecase=0" &&
119-
test_must_fail attr_check a/B/g a/b/g "-c core.ignorecase=0" &&
120-
test_must_fail attr_check a/b/G a/b/g "-c core.ignorecase=0" &&
121-
test_must_fail attr_check a/b/H a/b/h "-c core.ignorecase=0" &&
122-
test_must_fail attr_check a/b/D/g "a/b/d/*" "-c core.ignorecase=0" &&
123-
test_must_fail attr_check oNoFf unset "-c core.ignorecase=0" &&
124-
test_must_fail attr_check oFfOn set "-c core.ignorecase=0" &&
112+
attr_check F unspecified "-c core.ignorecase=0" &&
113+
attr_check a/F unspecified "-c core.ignorecase=0" &&
114+
attr_check a/c/F unspecified "-c core.ignorecase=0" &&
115+
attr_check a/G unspecified "-c core.ignorecase=0" &&
116+
attr_check a/B/g a/g "-c core.ignorecase=0" &&
117+
attr_check a/b/G unspecified "-c core.ignorecase=0" &&
118+
attr_check a/b/H unspecified "-c core.ignorecase=0" &&
119+
attr_check a/b/D/g a/g "-c core.ignorecase=0" &&
120+
attr_check oNoFf unspecified "-c core.ignorecase=0" &&
121+
attr_check oFfOn unspecified "-c core.ignorecase=0" &&
125122
attr_check NO unspecified "-c core.ignorecase=0" &&
126-
test_must_fail attr_check a/b/D/NO "a/b/d/*" "-c core.ignorecase=0" &&
123+
attr_check a/b/D/NO unspecified "-c core.ignorecase=0" &&
127124
attr_check a/b/d/YES a/b/d/* "-c core.ignorecase=0" &&
128-
test_must_fail attr_check a/E/f "A/e/F" "-c core.ignorecase=0"
125+
attr_check a/E/f f "-c core.ignorecase=0"
129126
130127
'
131128

@@ -149,8 +146,8 @@ test_expect_success 'attribute matching is case insensitive when core.ignorecase
149146
'
150147

151148
test_expect_success CASE_INSENSITIVE_FS 'additional case insensitivity tests' '
152-
test_must_fail attr_check a/B/D/g "a/b/d/*" "-c core.ignorecase=0" &&
153-
test_must_fail attr_check A/B/D/NO "a/b/d/*" "-c core.ignorecase=0" &&
149+
attr_check a/B/D/g a/g "-c core.ignorecase=0" &&
150+
attr_check A/B/D/NO unspecified "-c core.ignorecase=0" &&
154151
attr_check A/b/h a/b/h "-c core.ignorecase=1" &&
155152
attr_check a/B/D/g "a/b/d/*" "-c core.ignorecase=1" &&
156153
attr_check A/B/D/NO "a/b/d/*" "-c core.ignorecase=1"
@@ -244,7 +241,7 @@ EOF
244241
git check-attr foo -- "a/b/f" >>actual 2>>err &&
245242
git check-attr foo -- "a/b/c/f" >>actual 2>>err &&
246243
test_cmp expect actual &&
247-
test_line_count = 0 err
244+
test_must_be_empty err
248245
'
249246

250247
test_expect_success '"**" with no slashes test' '
@@ -265,7 +262,7 @@ EOF
265262
git check-attr foo -- "a/b/f" >>actual 2>>err &&
266263
git check-attr foo -- "a/b/c/f" >>actual 2>>err &&
267264
test_cmp expect actual &&
268-
test_line_count = 0 err
265+
test_must_be_empty err
269266
'
270267

271268
test_expect_success 'using --git-dir and --work-tree' '

t/t0020-crlf.sh

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,8 @@ test_expect_success 'checkout with autocrlf=input' '
159159
rm -f tmp one dir/two three &&
160160
git config core.autocrlf input &&
161161
git read-tree --reset -u HEAD &&
162-
test_must_fail has_cr one &&
163-
test_must_fail has_cr dir/two &&
162+
! has_cr one &&
163+
! has_cr dir/two &&
164164
git update-index -- one dir/two &&
165165
test "$one" = $(git hash-object --stdin <one) &&
166166
test "$two" = $(git hash-object --stdin <dir/two) &&
@@ -237,9 +237,9 @@ test_expect_success '.gitattributes says two is binary' '
237237
git config core.autocrlf true &&
238238
git read-tree --reset -u HEAD &&
239239
240-
test_must_fail has_cr dir/two &&
240+
! has_cr dir/two &&
241241
verbose has_cr one &&
242-
test_must_fail has_cr three
242+
! has_cr three
243243
'
244244

245245
test_expect_success '.gitattributes says two is input' '
@@ -248,7 +248,7 @@ test_expect_success '.gitattributes says two is input' '
248248
echo "two crlf=input" >.gitattributes &&
249249
git read-tree --reset -u HEAD &&
250250
251-
test_must_fail has_cr dir/two
251+
! has_cr dir/two
252252
'
253253

254254
test_expect_success '.gitattributes says two and three are text' '
@@ -270,7 +270,7 @@ test_expect_success 'in-tree .gitattributes (1)' '
270270
rm -rf tmp one dir .gitattributes patch.file three &&
271271
git read-tree --reset -u HEAD &&
272272
273-
test_must_fail has_cr one &&
273+
! has_cr one &&
274274
verbose has_cr three
275275
'
276276

@@ -280,7 +280,7 @@ test_expect_success 'in-tree .gitattributes (2)' '
280280
git read-tree --reset HEAD &&
281281
git checkout-index -f -q -u -a &&
282282
283-
test_must_fail has_cr one &&
283+
! has_cr one &&
284284
verbose has_cr three
285285
'
286286

@@ -291,7 +291,7 @@ test_expect_success 'in-tree .gitattributes (3)' '
291291
git checkout-index -u .gitattributes &&
292292
git checkout-index -u one dir/two three &&
293293
294-
test_must_fail has_cr one &&
294+
! has_cr one &&
295295
verbose has_cr three
296296
'
297297

@@ -302,7 +302,7 @@ test_expect_success 'in-tree .gitattributes (4)' '
302302
git checkout-index -u one dir/two three &&
303303
git checkout-index -u .gitattributes &&
304304
305-
test_must_fail has_cr one &&
305+
! has_cr one &&
306306
verbose has_cr three
307307
'
308308

t/t1306-xdg-files.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ test_expect_success 'Checking attributes in both XDG and local attributes files'
153153

154154

155155
test_expect_success 'Checking attributes in a non-XDG global attributes file' '
156-
test_might_fail rm .gitattributes &&
156+
rm -f .gitattributes &&
157157
echo "f attr_f=test" >"$HOME"/my_gitattributes &&
158158
git config core.attributesfile "$HOME"/my_gitattributes &&
159159
echo "f: attr_f: test" >expected &&
@@ -165,7 +165,7 @@ test_expect_success 'Checking attributes in a non-XDG global attributes file' '
165165
test_expect_success 'write: xdg file exists and ~/.gitconfig doesn'\''t' '
166166
mkdir -p "$HOME"/.config/git &&
167167
>"$HOME"/.config/git/config &&
168-
test_might_fail rm "$HOME"/.gitconfig &&
168+
rm -f "$HOME"/.gitconfig &&
169169
git config --global user.name "write_config" &&
170170
echo "[user]" >expected &&
171171
echo " name = write_config" >>expected &&
@@ -183,8 +183,8 @@ test_expect_success 'write: xdg file exists and ~/.gitconfig exists' '
183183

184184

185185
test_expect_success 'write: ~/.config/git/ exists and config file doesn'\''t' '
186-
test_might_fail rm "$HOME"/.gitconfig &&
187-
test_might_fail rm "$HOME"/.config/git/config &&
186+
rm -f "$HOME"/.gitconfig &&
187+
rm -f "$HOME"/.config/git/config &&
188188
git config --global user.name "write_gitconfig" &&
189189
echo "[user]" >expected &&
190190
echo " name = write_gitconfig" >>expected &&

t/t1307-config-blob.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ test_expect_success 'can parse blob ending with CR' '
7474
'
7575

7676
test_expect_success 'config --blob outside of a repository is an error' '
77-
test_must_fail nongit git config --blob=foo --list
77+
nongit test_must_fail git config --blob=foo --list
7878
'
7979

8080
test_done

t/t1409-avoid-packing-refs.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ test_description='avoid rewriting packed-refs unnecessarily'
88
# shouldn't upset readers, and it should be omitted if the file is
99
# ever rewritten.
1010
mark_packed_refs () {
11-
sed -e "s/^\(#.*\)/\1 t1409 /" <.git/packed-refs >.git/packed-refs.new &&
11+
sed -e "s/^\(#.*\)/\1 t1409 /" .git/packed-refs >.git/packed-refs.new &&
1212
mv .git/packed-refs.new .git/packed-refs
1313
}
1414

@@ -27,15 +27,15 @@ test_expect_success 'setup' '
2727
'
2828

2929
test_expect_success 'do not create packed-refs file gratuitously' '
30-
test_must_fail test -f .git/packed-refs &&
30+
test_path_is_missing .git/packed-refs &&
3131
git update-ref refs/heads/foo $A &&
32-
test_must_fail test -f .git/packed-refs &&
32+
test_path_is_missing .git/packed-refs &&
3333
git update-ref refs/heads/foo $B &&
34-
test_must_fail test -f .git/packed-refs &&
34+
test_path_is_missing .git/packed-refs &&
3535
git update-ref refs/heads/foo $C $B &&
36-
test_must_fail test -f .git/packed-refs &&
36+
test_path_is_missing .git/packed-refs &&
3737
git update-ref -d refs/heads/foo &&
38-
test_must_fail test -f .git/packed-refs
38+
test_path_is_missing .git/packed-refs
3939
'
4040

4141
test_expect_success 'check that marking the packed-refs file works' '
@@ -46,7 +46,7 @@ test_expect_success 'check that marking the packed-refs file works' '
4646
git for-each-ref >actual &&
4747
test_cmp expected actual &&
4848
git pack-refs --all &&
49-
test_must_fail check_packed_refs_marked &&
49+
! check_packed_refs_marked &&
5050
git for-each-ref >actual2 &&
5151
test_cmp expected actual2
5252
'
@@ -80,7 +80,7 @@ test_expect_success 'touch packed-refs on delete of packed' '
8080
git pack-refs --all &&
8181
mark_packed_refs &&
8282
git update-ref -d refs/heads/packed-delete &&
83-
test_must_fail check_packed_refs_marked
83+
! check_packed_refs_marked
8484
'
8585

8686
test_expect_success 'leave packed-refs untouched on update of loose' '

t/t1501-work-tree.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ test_expect_success 'Multi-worktree setup' '
350350
mkdir work &&
351351
mkdir -p repo.git/repos/foo &&
352352
cp repo.git/HEAD repo.git/index repo.git/repos/foo &&
353-
test_might_fail cp repo.git/sharedindex.* repo.git/repos/foo &&
353+
{ cp repo.git/sharedindex.* repo.git/repos/foo || :; } &&
354354
sane_unset GIT_DIR GIT_CONFIG GIT_WORK_TREE
355355
'
356356

0 commit comments

Comments
 (0)