]> git.ipfire.org Git - thirdparty/git.git/commitdiff
test: use test_must_be_empty F instead of test -z $(cat F)
authorRené Scharfe <l.s.r@web.de>
Tue, 26 Nov 2019 19:46:07 +0000 (20:46 +0100)
committerJunio C Hamano <gitster@pobox.com>
Wed, 27 Nov 2019 02:32:07 +0000 (11:32 +0900)
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>
t/t1309-early-config.sh
t/t1506-rev-parse-diagnosis.sh
t/t6019-rev-list-ancestry-path.sh

index 3a0de0ddaa553e82b7db8594f4c45489237fb7db..ebb8e1aecbf424e1ec2d522bd7806c78992bedb6 100755 (executable)
@@ -29,7 +29,7 @@ test_expect_success 'ceiling' '
                cd sub &&
                test-tool config read_early_config early.config
        ) >output &&
-       test -z "$(cat output)"
+       test_must_be_empty output
 '
 
 test_expect_success 'ceiling #2' '
index 624d0a588fe6dda03b929cd4239f62e765efa04a..6d951ca015912062fba4a938fdb560c10641ca6d 100755 (executable)
@@ -138,10 +138,10 @@ test_expect_success 'incorrect file in :path and :N:path' '
 
 test_expect_success 'invalid @{n} reference' '
        test_must_fail git rev-parse master@{99999} >output 2>error &&
-       test -z "$(cat output)" &&
+       test_must_be_empty output &&
        grep "fatal: Log for [^ ]* only has [0-9][0-9]* entries." error  &&
        test_must_fail git rev-parse --verify master@{99999} >output 2>error &&
-       test -z "$(cat output)" &&
+       test_must_be_empty output &&
        grep "fatal: Log for [^ ]* only has [0-9][0-9]* entries." error
 '
 
@@ -155,13 +155,13 @@ test_expect_success 'relative path not found' '
 
 test_expect_success 'relative path outside worktree' '
        test_must_fail git rev-parse HEAD:../file.txt >output 2>error &&
-       test -z "$(cat output)" &&
+       test_must_be_empty output &&
        test_i18ngrep "outside repository" error
 '
 
 test_expect_success 'relative path when cwd is outside worktree' '
        test_must_fail git --git-dir=.git --work-tree=subdir rev-parse HEAD:./file.txt >output 2>error &&
-       test -z "$(cat output)" &&
+       test_must_be_empty output &&
        grep "relative path syntax can.t be used outside working tree." error
 '
 
index beadaf6cca054bc2d821be19b4358286c6107165..353f84313f33b61c2f06d688cb9dfb75d8d4adf9 100755 (executable)
@@ -143,14 +143,14 @@ test_expect_success 'setup criss-cross' '
 test_expect_success 'criss-cross: rev-list --ancestry-path cb..bc' '
        (cd criss-cross &&
         git rev-list --ancestry-path xcb..xbc > actual &&
-        test -z "$(cat actual)")
+        test_must_be_empty actual)
 '
 
 # no commits in repository descend from cb
 test_expect_success 'criss-cross: rev-list --ancestry-path --all ^cb' '
        (cd criss-cross &&
         git rev-list --ancestry-path --all ^xcb > actual &&
-        test -z "$(cat actual)")
+        test_must_be_empty actual)
 '
 
 test_done