Skip to content

Commit 213dabf

Browse files
rscharfegitster
authored andcommitted
test: use test_must_be_empty F instead of test -z $(cat F)
Use test_must_be_empty instead of reading the file and comparing its contents to an empty string. That's more efficient, as the function only needs built-in meta-data only check in the usual case, and provides nicer debug output otherwise. Signed-off-by: René Scharfe <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c93a5aa commit 213dabf

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

t/t1309-early-config.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ test_expect_success 'ceiling' '
2929
cd sub &&
3030
test-tool config read_early_config early.config
3131
) >output &&
32-
test -z "$(cat output)"
32+
test_must_be_empty output
3333
'
3434

3535
test_expect_success 'ceiling #2' '

t/t1506-rev-parse-diagnosis.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,10 @@ test_expect_success 'incorrect file in :path and :N:path' '
138138

139139
test_expect_success 'invalid @{n} reference' '
140140
test_must_fail git rev-parse master@{99999} >output 2>error &&
141-
test -z "$(cat output)" &&
141+
test_must_be_empty output &&
142142
grep "fatal: Log for [^ ]* only has [0-9][0-9]* entries." error &&
143143
test_must_fail git rev-parse --verify master@{99999} >output 2>error &&
144-
test -z "$(cat output)" &&
144+
test_must_be_empty output &&
145145
grep "fatal: Log for [^ ]* only has [0-9][0-9]* entries." error
146146
'
147147

@@ -155,13 +155,13 @@ test_expect_success 'relative path not found' '
155155

156156
test_expect_success 'relative path outside worktree' '
157157
test_must_fail git rev-parse HEAD:../file.txt >output 2>error &&
158-
test -z "$(cat output)" &&
158+
test_must_be_empty output &&
159159
test_i18ngrep "outside repository" error
160160
'
161161

162162
test_expect_success 'relative path when cwd is outside worktree' '
163163
test_must_fail git --git-dir=.git --work-tree=subdir rev-parse HEAD:./file.txt >output 2>error &&
164-
test -z "$(cat output)" &&
164+
test_must_be_empty output &&
165165
grep "relative path syntax can.t be used outside working tree." error
166166
'
167167

t/t6019-rev-list-ancestry-path.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,14 @@ test_expect_success 'setup criss-cross' '
143143
test_expect_success 'criss-cross: rev-list --ancestry-path cb..bc' '
144144
(cd criss-cross &&
145145
git rev-list --ancestry-path xcb..xbc > actual &&
146-
test -z "$(cat actual)")
146+
test_must_be_empty actual)
147147
'
148148

149149
# no commits in repository descend from cb
150150
test_expect_success 'criss-cross: rev-list --ancestry-path --all ^cb' '
151151
(cd criss-cross &&
152152
git rev-list --ancestry-path --all ^xcb > actual &&
153-
test -z "$(cat actual)")
153+
test_must_be_empty actual)
154154
'
155155

156156
test_done

0 commit comments

Comments
 (0)