@matheusbsbs / matheus-bagliano / commits / 213dabf49d
Fork 0

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 <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

René Scharfe committed Nov 26, 2019 at 20:46 UTC 213dabf49dc53ae5808efbdebf0cd2bfc2c1bfa8
3 files changed +7 -7
t/t1309-early-config.sh
+1 -1
@@ -29,7 +29,7 @@ test_expect_success 'ceiling' '
29 cd sub &&
30 test-tool config read_early_config early.config
31 ) >output &&
32 - test -z "$(cat output)"
32 + test_must_be_empty output
33 '
34
35 test_expect_success 'ceiling #2' '
t/t1506-rev-parse-diagnosis.sh
+4 -4
@@ -138,10 +138,10 @@ test_expect_success 'incorrect file in :path and :N:path' '
138
139 test_expect_success 'invalid @{n} reference' '
140 test_must_fail git rev-parse master@{99999} >output 2>error &&
141 - test -z "$(cat output)" &&
141 + test_must_be_empty output &&
142 grep "fatal: Log for [^ ]* only has [0-9][0-9]* entries." error &&
143 test_must_fail git rev-parse --verify master@{99999} >output 2>error &&
144 - test -z "$(cat output)" &&
144 + test_must_be_empty output &&
145 grep "fatal: Log for [^ ]* only has [0-9][0-9]* entries." error
146 '
147
@@ -155,13 +155,13 @@ test_expect_success 'relative path not found' '
155
156 test_expect_success 'relative path outside worktree' '
157 test_must_fail git rev-parse HEAD:../file.txt >output 2>error &&
158 - test -z "$(cat output)" &&
158 + test_must_be_empty output &&
159 test_i18ngrep "outside repository" error
160 '
161
162 test_expect_success 'relative path when cwd is outside worktree' '
163 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 &&
165 grep "relative path syntax can.t be used outside working tree." error
166 '
167
t/t6019-rev-list-ancestry-path.sh
+2 -2
@@ -143,14 +143,14 @@ test_expect_success 'setup criss-cross' '
143 test_expect_success 'criss-cross: rev-list --ancestry-path cb..bc' '
144 (cd criss-cross &&
145 git rev-list --ancestry-path xcb..xbc > actual &&
146 - test -z "$(cat actual)")
146 + test_must_be_empty actual)
147 '
148
149 # no commits in repository descend from cb
150 test_expect_success 'criss-cross: rev-list --ancestry-path --all ^cb' '
151 (cd criss-cross &&
152 git rev-list --ancestry-path --all ^xcb > actual &&
153 - test -z "$(cat actual)")
153 + test_must_be_empty actual)
154 '
155
156 test_done