tests: use 'test_must_be_empty' instead of '! test -s'
authorSZEDER Gábor <szeder.dev@gmail.com>
Sun, 19 Aug 2018 21:57:22 +0000 (23:57 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 21 Aug 2018 18:48:29 +0000 (11:48 -0700)
Using 'test_must_be_empty' is preferable to '! test -s', because it
gives a helpful error message if the given file is unexpectedly not
empty, while the latter remains completely silent. Furthermore, it
also catches cases when the given file unexpectedly does not exist at
all.

This patch was basically created by:

sed -i -e 's/! test -s/test_must_be_empty/' t[0-9]*.sh

with the following notable exceptions:

- The '! test -s' check in '.gitmodules ignore=dirty suppresses
submodules with untracked content' in 't7508-status.sh' is left
as-is, because it's bogus and, therefore, it's subject of a
dedicated patch.

- The '! test -s' checks in 't9131-git-svn-empty-symlink.sh' and
't9135-git-svn-moved-branch-empty-file.sh' are immediately
preceeded by a 'test -f' to ensure that the files exist in the
first place. 'test_must_be_empty' ensures that as well, so those
'test -f' commands are removed as well.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
25 files changed:
t/t0000-basic.sh
t/t0090-cache-tree.sh
t/t0203-gettext-setlocale-sanity.sh
t/t1501-work-tree.sh
t/t1510-repo-setup.sh
t/t2013-checkout-submodule.sh
t/t2204-add-ignored.sh
t/t3600-rm.sh
t/t4011-diff-symlink.sh
t/t4019-diff-wserror.sh
t/t4027-diff-submodule.sh
t/t4041-diff-submodule-option.sh
t/t4060-diff-submodule-option-diff-format.sh
t/t4124-apply-ws-rule.sh
t/t4150-am.sh
t/t5401-update-hooks.sh
t/t5500-fetch-pack.sh
t/t5526-fetch-submodules.sh
t/t5570-git-daemon.sh
t/t7001-mv.sh
t/t7201-co.sh
t/t7406-submodule-update.sh
t/t7810-grep.sh
t/t9131-git-svn-empty-symlink.sh
t/t9135-git-svn-moved-branch-empty-file.sh
index af61d083b452c7973a2a703ef35fb57b76af84da..4e588eda092546c0898de5cb372efee2326341be 100755 (executable)
@@ -116,7 +116,7 @@ check_sub_test_lib_test () {
        name="$1" # stdin is the expected output from the test
        (
                cd "$name" &&
-               ! test -s err &&
+               test_must_be_empty err &&
                sed -e 's/^> //' -e 's/Z$//' >expect &&
                test_cmp expect out
        )
index 0c61268fd22ade66c6cbd91ad743986b33af0d5d..9e88a56d619ca33a24089ec1208e6726d76f6256 100755 (executable)
@@ -239,7 +239,7 @@ test_expect_success 'no phantom error when switching trees' '
        >newdir/one &&
        git add newdir/one &&
        git checkout 2>errors &&
-       ! test -s errors
+       test_must_be_empty errors
 '
 
 test_expect_success 'switching trees does not invalidate shared index' '
index 71b0d74b4ddef584e3f8af711df6b5c5678034c5..0ce1f22eff66285ee0da9b1830de961555fbad2b 100755 (executable)
@@ -11,7 +11,7 @@ test_expect_success 'git show a ISO-8859-1 commit under C locale' '
        . "$TEST_DIRECTORY"/t3901/8859-1.txt &&
        test_commit "iso-c-commit" iso-under-c &&
        git show >out 2>err &&
-       ! test -s err &&
+       test_must_be_empty err &&
        grep -q "iso-c-commit" out
 '
 
@@ -19,7 +19,7 @@ test_expect_success GETTEXT_LOCALE 'git show a ISO-8859-1 commit under a UTF-8 l
        . "$TEST_DIRECTORY"/t3901/8859-1.txt &&
        test_commit "iso-utf8-commit" iso-under-utf8 &&
        LANGUAGE=is LC_ALL="$is_IS_locale" git show >out 2>err &&
-       ! test -s err &&
+       test_must_be_empty err &&
        grep -q "iso-utf8-commit" out
 '
 
index afcdfafe45521872b0e2f1648da782c61d0cc1d5..3498d3d55e9e18d19c9a9accaa1637f338c1c4bc 100755 (executable)
@@ -41,7 +41,7 @@ test_expect_success 'setup: helper for testing rev-parse' '
                        # rev-parse --show-prefix should output
                        # a single newline when at the top of the work tree,
                        # but we test for that separately.
-                       test -z "$4" && ! test -s actual.prefix ||
+                       test -z "$4" && test_must_be_empty actual.prefix ||
                        test_cmp expected.prefix actual.prefix
                fi
        }
index 972bd9c7859f52ac043b0a45500590fe182d4b6a..9974457f5615c9c9204ebfaff6d42c621836fdec 100755 (executable)
@@ -234,14 +234,14 @@ test_expect_success '#0: nonbare repo, no explicit configuration' '
        try_repo 0 unset unset unset "" unset \
                .git "$here/0" "$here/0" "(null)" \
                .git "$here/0" "$here/0" sub/ 2>message &&
-       ! test -s message
+       test_must_be_empty message
 '
 
 test_expect_success '#1: GIT_WORK_TREE without explicit GIT_DIR is accepted' '
        try_repo 1 "$here" unset unset "" unset \
                "$here/1/.git" "$here" "$here" 1/ \
                "$here/1/.git" "$here" "$here" 1/sub/ 2>message &&
-       ! test -s message
+       test_must_be_empty message
 '
 
 test_expect_success '#2: worktree defaults to cwd with explicit GIT_DIR' '
@@ -268,7 +268,7 @@ test_expect_success '#4: core.worktree without GIT_DIR set is accepted' '
        try_case 4 unset unset \
                .git "$here/4/sub" "$here/4" "(null)" \
                "$here/4/.git" "$here/4/sub" "$here/4/sub" "(null)" 2>message &&
-       ! test -s message
+       test_must_be_empty message
 '
 
 test_expect_success '#5: core.worktree + GIT_WORK_TREE is accepted' '
@@ -279,7 +279,7 @@ test_expect_success '#5: core.worktree + GIT_WORK_TREE is accepted' '
        try_repo 5a .. unset "$here/5a" "" unset \
                "$here/5a/.git" "$here" "$here" 5a/ \
                "$here/5a/.git" "$here/5a" "$here/5a" sub/ &&
-       ! test -s message
+       test_must_be_empty message
 '
 
 test_expect_success '#6: setting GIT_DIR brings core.worktree to life' '
@@ -376,7 +376,7 @@ test_expect_success '#9: GIT_WORK_TREE accepted with gitfile' '
        try_repo 9 wt unset unset gitfile unset \
                "$here/9.git" "$here/9/wt" "$here/9" "(null)" \
                "$here/9.git" "$here/9/sub/wt" "$here/9/sub" "(null)" 2>message &&
-       ! test -s message
+       test_must_be_empty message
 '
 
 test_expect_success '#10: GIT_DIR can point to gitfile' '
@@ -402,7 +402,7 @@ test_expect_success '#12: core.worktree with gitfile is accepted' '
        try_repo 12 unset unset "$here/12" gitfile unset \
                "$here/12.git" "$here/12" "$here/12" "(null)" \
                "$here/12.git" "$here/12" "$here/12" sub/ 2>message &&
-       ! test -s message
+       test_must_be_empty message
 '
 
 test_expect_success '#13: core.worktree+GIT_WORK_TREE accepted (with gitfile)' '
@@ -410,7 +410,7 @@ test_expect_success '#13: core.worktree+GIT_WORK_TREE accepted (with gitfile)' '
        try_repo 13 non-existent-too unset non-existent gitfile unset \
                "$here/13.git" "$here/13/non-existent-too" "$here/13" "(null)" \
                "$here/13.git" "$here/13/sub/non-existent-too" "$here/13/sub" "(null)" 2>message &&
-       ! test -s message
+       test_must_be_empty message
 '
 
 # case #14.
@@ -565,7 +565,7 @@ test_expect_success '#17: GIT_WORK_TREE without explicit GIT_DIR is accepted (ba
        try_repo 17c "$here/17c" unset unset "" true \
                .git "$here/17c" "$here/17c" "(null)" \
                "$here/17c/.git" "$here/17c" "$here/17c" sub/ 2>message &&
-       ! test -s message
+       test_must_be_empty message
 '
 
 test_expect_success '#18: bare .git named by GIT_DIR has no worktree' '
@@ -594,7 +594,7 @@ test_expect_success '#20a: core.worktree without GIT_DIR accepted (inside .git)'
                "$here/20a/.git" "$here/20a" "$here/20a" .git/wt/ &&
        try_case 20a/.git/wt/sub unset unset \
                "$here/20a/.git" "$here/20a" "$here/20a" .git/wt/sub/ &&
-       ! test -s message
+       test_must_be_empty message
 '
 
 test_expect_success '#20b/c: core.worktree and core.bare conflict' '
@@ -626,7 +626,7 @@ test_expect_success '#21: setup, core.worktree warns before overriding core.bare
                export GIT_WORK_TREE &&
                git status >/dev/null
        ) 2>message &&
-       ! test -s message
+       test_must_be_empty message
 
 '
 run_wt_tests 21
@@ -742,7 +742,7 @@ test_expect_success '#25: GIT_WORK_TREE accepted if GIT_DIR unset (bare gitfile
        try_repo 25 "$here/25" unset unset gitfile true \
                "$here/25.git" "$here/25" "$here/25" "(null)"  \
                "$here/25.git" "$here/25" "$here/25" "sub/" 2>message &&
-       ! test -s message
+       test_must_be_empty message
 '
 
 test_expect_success '#26: bare repo has no worktree (GIT_DIR -> gitfile case)' '
@@ -780,7 +780,7 @@ test_expect_success '#29: setup' '
                export GIT_WORK_TREE &&
                git status
        ) 2>message &&
-       ! test -s message
+       test_must_be_empty message
 '
 run_wt_tests 29 gitfile
 
index 6ef15738e44ed8ad82960c042b3212fce266ec93..8f86b5f4b298f8297d68030f6ff1e51eb0311bf1 100755 (executable)
@@ -44,7 +44,7 @@ test_expect_success '"checkout <submodule>" honors diff.ignoreSubmodules' '
        git config diff.ignoreSubmodules dirty &&
        echo x> submodule/untracked &&
        git checkout HEAD >actual 2>&1 &&
-       ! test -s actual
+       test_must_be_empty actual
 '
 
 test_expect_success '"checkout <submodule>" honors submodule.*.ignore from .gitmodules' '
@@ -52,7 +52,7 @@ test_expect_success '"checkout <submodule>" honors submodule.*.ignore from .gitm
        git config -f .gitmodules submodule.submodule.path submodule &&
        git config -f .gitmodules submodule.submodule.ignore untracked &&
        git checkout HEAD >actual 2>&1 &&
-       ! test -s actual
+       test_must_be_empty actual
 '
 
 test_expect_success '"checkout <submodule>" honors submodule.*.ignore from .git/config' '
@@ -60,7 +60,7 @@ test_expect_success '"checkout <submodule>" honors submodule.*.ignore from .git/
        git config submodule.submodule.path submodule &&
        git config submodule.submodule.ignore all &&
        git checkout HEAD >actual 2>&1 &&
-       ! test -s actual
+       test_must_be_empty actual
 '
 
 KNOWN_FAILURE_DIRECTORY_SUBMODULE_CONFLICTS=1
index 8340ac2f073446963f7f5dab39ac87771264da54..2e07365bbb055d27f558c78d26f657e314397398 100755 (executable)
@@ -31,7 +31,7 @@ do
                rm -f .git/index &&
                test_must_fail git add "$i" 2>err &&
                git ls-files "$i" >out &&
-               ! test -s out
+               test_must_be_empty out
        '
 
        test_expect_success "complaints for ignored $i output" '
@@ -42,7 +42,7 @@ do
                rm -f .git/index &&
                test_must_fail git add "$i" file 2>err &&
                git ls-files "$i" >out &&
-               ! test -s out
+               test_must_be_empty out
        '
        test_expect_success "complaints for ignored $i with unignored file output" '
                test_i18ngrep -e "Use -f if" err
@@ -57,7 +57,7 @@ do
                        cd dir &&
                        test_must_fail git add "$i" 2>err &&
                        git ls-files "$i" >out &&
-                       ! test -s out
+                       test_must_be_empty out
                )
        '
 
@@ -77,7 +77,7 @@ do
                        cd sub &&
                        test_must_fail git add "$i" 2>err &&
                        git ls-files "$i" >out &&
-                       ! test -s out
+                       test_must_be_empty out
                )
        '
 
index b8fbdefcdc34ffa6fb54fc1ad375a583a194fb38..b178a376c47de2dc2e8783fdbb34da628510b8b7 100755 (executable)
@@ -382,7 +382,7 @@ test_expect_success 'rm does not complain when no .gitmodules file is found' '
        git submodule update &&
        git rm .gitmodules &&
        git rm submod >actual 2>actual.err &&
-       ! test -s actual.err &&
+       test_must_be_empty actual.err &&
        ! test -d submod &&
        ! test -f submod/.git &&
        git status -s -uno >actual &&
@@ -400,7 +400,7 @@ test_expect_success 'rm will error out on a modified .gitmodules file unless sta
        git diff-files --quiet -- submod &&
        git add .gitmodules &&
        git rm submod >actual 2>actual.err &&
-       ! test -s actual.err &&
+       test_must_be_empty actual.err &&
        ! test -d submod &&
        ! test -f submod/.git &&
        git status -s -uno >actual &&
@@ -694,7 +694,7 @@ test_expect_success 'checking out a commit after submodule removal needs manual
        test_cmp expected actual &&
        rm -rf submod &&
        git status -s -uno --ignore-submodules=none >actual &&
-       ! test -s actual
+       test_must_be_empty actual
 '
 
 test_expect_success 'rm of d/f when d has become a non-directory' '
index 108c012a3a66d900cbbfcda04ac2dfe5ffeb6362..5ae19b987d65d081b78c10f5eefd8aaf930c97a8 100755 (executable)
@@ -126,7 +126,7 @@ test_expect_success SYMLINKS 'diff symlinks with non-existing targets' '
        ln -s take\ over brain &&
        test_must_fail git diff --no-index pinky brain >output 2>output.err &&
        grep narf output &&
-       ! test -s output.err
+       test_must_be_empty output.err
 '
 
 test_expect_success SYMLINKS 'setup symlinks with attributes' '
index a5019759bc7593cf8affd8625f61bbd7ab1b9655..c6135c75488ff01797a98e43163e0b0c5e6be169 100755 (executable)
@@ -260,7 +260,7 @@ test_expect_success 'trailing empty lines (2)' '
 
        echo "F -whitespace" >.gitattributes &&
        git diff --check >output &&
-       ! test -s output
+       test_must_be_empty output
 
 '
 
index 6304130ad4737bfac1e2cf06fd8c600bb7b42f76..e5f9eb7a11f0e5bba35b024bfffc4f175e889433 100755 (executable)
@@ -104,19 +104,19 @@ test_expect_success 'git diff HEAD with dirty submodule (work tree, refs match)'
        expect_from_to >expect.body $subprev $subprev-dirty &&
        test_cmp expect.body actual.body &&
        git diff --ignore-submodules HEAD >actual2 &&
-       ! test -s actual2 &&
+       test_must_be_empty actual2 &&
        git diff --ignore-submodules=untracked HEAD >actual3 &&
        sed -e "1,/^@@/d" actual3 >actual3.body &&
        expect_from_to >expect.body $subprev $subprev-dirty &&
        test_cmp expect.body actual3.body &&
        git diff --ignore-submodules=dirty HEAD >actual4 &&
-       ! test -s actual4
+       test_must_be_empty actual4
 '
 
 test_expect_success 'git diff HEAD with dirty submodule (work tree, refs match) [.gitmodules]' '
        git config diff.ignoreSubmodules dirty &&
        git diff HEAD >actual &&
-       ! test -s actual &&
+       test_must_be_empty actual &&
        git config --add -f .gitmodules submodule.subname.ignore none &&
        git config --add -f .gitmodules submodule.subname.path sub &&
        git diff HEAD >actual &&
@@ -126,7 +126,7 @@ test_expect_success 'git diff HEAD with dirty submodule (work tree, refs match)
        git config -f .gitmodules submodule.subname.ignore all &&
        git config -f .gitmodules submodule.subname.path sub &&
        git diff HEAD >actual2 &&
-       ! test -s actual2 &&
+       test_must_be_empty actual2 &&
        git config -f .gitmodules submodule.subname.ignore untracked &&
        git diff HEAD >actual3 &&
        sed -e "1,/^@@/d" actual3 >actual3.body &&
@@ -134,7 +134,7 @@ test_expect_success 'git diff HEAD with dirty submodule (work tree, refs match)
        test_cmp expect.body actual3.body &&
        git config -f .gitmodules submodule.subname.ignore dirty &&
        git diff HEAD >actual4 &&
-       ! test -s actual4 &&
+       test_must_be_empty actual4 &&
        git config submodule.subname.ignore none &&
        git config submodule.subname.path sub &&
        git diff HEAD >actual &&
@@ -172,24 +172,24 @@ test_expect_success 'git diff HEAD with dirty submodule (untracked, refs match)'
        expect_from_to >expect.body $subprev $subprev-dirty &&
        test_cmp expect.body actual.body &&
        git diff --ignore-submodules=all HEAD >actual2 &&
-       ! test -s actual2 &&
+       test_must_be_empty actual2 &&
        git diff --ignore-submodules=untracked HEAD >actual3 &&
-       ! test -s actual3 &&
+       test_must_be_empty actual3 &&
        git diff --ignore-submodules=dirty HEAD >actual4 &&
-       ! test -s actual4
+       test_must_be_empty actual4
 '
 
 test_expect_success 'git diff HEAD with dirty submodule (untracked, refs match) [.gitmodules]' '
        git config --add -f .gitmodules submodule.subname.ignore all &&
        git config --add -f .gitmodules submodule.subname.path sub &&
        git diff HEAD >actual2 &&
-       ! test -s actual2 &&
+       test_must_be_empty actual2 &&
        git config -f .gitmodules submodule.subname.ignore untracked &&
        git diff HEAD >actual3 &&
-       ! test -s actual3 &&
+       test_must_be_empty actual3 &&
        git config -f .gitmodules submodule.subname.ignore dirty &&
        git diff HEAD >actual4 &&
-       ! test -s actual4 &&
+       test_must_be_empty actual4 &&
        git config submodule.subname.ignore none &&
        git config submodule.subname.path sub &&
        git diff HEAD >actual &&
@@ -211,7 +211,7 @@ test_expect_success 'git diff between submodule commits' '
        expect_from_to >expect.body $subtip $subprev &&
        test_cmp expect.body actual.body &&
        git diff --ignore-submodules HEAD^..HEAD >actual &&
-       ! test -s actual
+       test_must_be_empty actual
 '
 
 test_expect_success 'git diff between submodule commits [.gitmodules]' '
@@ -227,7 +227,7 @@ test_expect_success 'git diff between submodule commits [.gitmodules]' '
        test_cmp expect.body actual.body &&
        git config -f .gitmodules submodule.subname.ignore all &&
        git diff HEAD^..HEAD >actual &&
-       ! test -s actual &&
+       test_must_be_empty actual &&
        git config submodule.subname.ignore dirty &&
        git config submodule.subname.path sub &&
        git diff  HEAD^..HEAD >actual &&
index 058ee0829ded8163f99325494f326ef6609fee06..302f2166a9b84f5de05bbb7e6d7a2a791853e5fe 100755 (executable)
@@ -273,17 +273,17 @@ test_expect_success 'submodule contains untracked content' '
 
 test_expect_success 'submodule contains untracked content (untracked ignored)' '
        git diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&
-       ! test -s actual
+       test_must_be_empty actual
 '
 
 test_expect_success 'submodule contains untracked content (dirty ignored)' '
        git diff-index -p --ignore-submodules=dirty --submodule=log HEAD >actual &&
-       ! test -s actual
+       test_must_be_empty actual
 '
 
 test_expect_success 'submodule contains untracked content (all ignored)' '
        git diff-index -p --ignore-submodules=all --submodule=log HEAD >actual &&
-       ! test -s actual
+       test_must_be_empty actual
 '
 
 test_expect_success 'submodule contains untracked and modifed content' '
@@ -308,13 +308,13 @@ test_expect_success 'submodule contains untracked and modifed content (untracked
 test_expect_success 'submodule contains untracked and modifed content (dirty ignored)' '
        echo new > sm1/foo6 &&
        git diff-index -p --ignore-submodules=dirty --submodule=log HEAD >actual &&
-       ! test -s actual
+       test_must_be_empty actual
 '
 
 test_expect_success 'submodule contains untracked and modifed content (all ignored)' '
        echo new > sm1/foo6 &&
        git diff-index -p --ignore-submodules --submodule=log HEAD >actual &&
-       ! test -s actual
+       test_must_be_empty actual
 '
 
 test_expect_success 'submodule contains modifed content' '
@@ -368,7 +368,7 @@ test_expect_success 'modified submodule contains untracked content (dirty ignore
 
 test_expect_success 'modified submodule contains untracked content (all ignored)' '
        git diff-index -p --ignore-submodules=all --submodule=log HEAD >actual &&
-       ! test -s actual
+       test_must_be_empty actual
 '
 
 test_expect_success 'modified submodule contains untracked and modifed content' '
@@ -407,7 +407,7 @@ test_expect_success 'modified submodule contains untracked and modifed content (
 test_expect_success 'modified submodule contains untracked and modifed content (all ignored)' '
        echo modification >> sm1/foo6 &&
        git diff-index -p --ignore-submodules --submodule=log HEAD >actual &&
-       ! test -s actual
+       test_must_be_empty actual
 '
 
 test_expect_success 'modified submodule contains modifed content' '
index 4b168d0ed7ff2bbb1d93895de7fdf3f14bfe334e..6fc3da8bd259e14f2736a35c8907215558014243 100755 (executable)
@@ -408,17 +408,17 @@ test_expect_success 'submodule contains untracked content' '
 
 test_expect_success 'submodule contains untracked content (untracked ignored)' '
        git diff-index -p --ignore-submodules=untracked --submodule=diff HEAD >actual &&
-       ! test -s actual
+       test_must_be_empty actual
 '
 
 test_expect_success 'submodule contains untracked content (dirty ignored)' '
        git diff-index -p --ignore-submodules=dirty --submodule=diff HEAD >actual &&
-       ! test -s actual
+       test_must_be_empty actual
 '
 
 test_expect_success 'submodule contains untracked content (all ignored)' '
        git diff-index -p --ignore-submodules=all --submodule=diff HEAD >actual &&
-       ! test -s actual
+       test_must_be_empty actual
 '
 
 test_expect_success 'submodule contains untracked and modified content' '
@@ -458,13 +458,13 @@ test_expect_success 'submodule contains untracked and modified content (untracke
 test_expect_success 'submodule contains untracked and modified content (dirty ignored)' '
        echo new > sm1/foo6 &&
        git diff-index -p --ignore-submodules=dirty --submodule=diff HEAD >actual &&
-       ! test -s actual
+       test_must_be_empty actual
 '
 
 test_expect_success 'submodule contains untracked and modified content (all ignored)' '
        echo new > sm1/foo6 &&
        git diff-index -p --ignore-submodules --submodule=diff HEAD >actual &&
-       ! test -s actual
+       test_must_be_empty actual
 '
 
 test_expect_success 'submodule contains modified content' '
@@ -549,7 +549,7 @@ test_expect_success 'modified submodule contains untracked content (dirty ignore
 
 test_expect_success 'modified submodule contains untracked content (all ignored)' '
        git diff-index -p --ignore-submodules=all --submodule=diff HEAD >actual &&
-       ! test -s actual
+       test_must_be_empty actual
 '
 
 test_expect_success 'modified submodule contains untracked and modified content' '
@@ -609,7 +609,7 @@ test_expect_success 'modified submodule contains untracked and modified content
 test_expect_success 'modified submodule contains untracked and modified content (all ignored)' '
        echo modification >> sm1/foo6 &&
        git diff-index -p --ignore-submodules --submodule=diff HEAD >actual &&
-       ! test -s actual
+       test_must_be_empty actual
 '
 
 # NOT OK
index 4fc27c51f7322ccb49a58d369185e64278ea246b..7e32237a2ae9a21e370d501caa8adfe561c6bc6b 100755 (executable)
@@ -100,7 +100,7 @@ test_expect_success 'whitespace=warn, default rule' '
 test_expect_success 'whitespace=error-all, default rule' '
 
        test_must_fail apply_patch --whitespace=error-all &&
-       ! test -s target
+       test_must_be_empty target
 
 '
 
index 1ebc587f8fc0010713f52196206462fa915cbca5..38fe717c12c173d0744dd29e3691f3d9aa05b781 100755 (executable)
@@ -651,7 +651,7 @@ test_expect_success 'am -3 -q is quiet' '
        git checkout -f lorem2 &&
        git reset base3way --hard &&
        git am -3 -q lorem-move.patch >output.out 2>&1 &&
-       ! test -s output.out
+       test_must_be_empty output.out
 '
 
 test_expect_success 'am pauses on conflict' '
@@ -874,7 +874,7 @@ test_expect_success 'am -q is quiet' '
        git checkout first &&
        test_tick &&
        git am -q <patch1 >output.out 2>&1 &&
-       ! test -s output.out
+       test_must_be_empty output.out
 '
 
 test_expect_success 'am empty-file does not infloop' '
index 7f278d8ce932f34420c337571ec043ffb5e318e9..ce151e71c19e27cec38b99719142fe2d48dffce7 100755 (executable)
@@ -104,17 +104,17 @@ test_expect_success 'post-update hook arguments' '
 '
 
 test_expect_success 'all hook stdin is /dev/null' '
-       ! test -s victim.git/update.stdin &&
-       ! test -s victim.git/post-update.stdin
+       test_must_be_empty victim.git/update.stdin &&
+       test_must_be_empty victim.git/post-update.stdin
 '
 
 test_expect_success 'all *-receive hook args are empty' '
-       ! test -s victim.git/pre-receive.args &&
-       ! test -s victim.git/post-receive.args
+       test_must_be_empty victim.git/pre-receive.args &&
+       test_must_be_empty victim.git/post-receive.args
 '
 
 test_expect_success 'send-pack produced no output' '
-       ! test -s send.out
+       test_must_be_empty send.out
 '
 
 cat <<EOF >expect
index 3d33ab3875383f4f71b486bfd3f2fce342e00474..07fcea04741afb362ec728a17eb1eaa283463b5f 100755 (executable)
@@ -161,7 +161,7 @@ test_expect_success 'clone shallow object count' '
 test_expect_success 'clone shallow object count (part 2)' '
        sed -e "/^in-pack:/d" -e "/^packs:/d" -e "/^size-pack:/d" \
            -e "/: 0$/d" count.shallow > count_output &&
-       ! test -s count_output
+       test_must_be_empty count_output
 '
 
 test_expect_success 'fsck in shallow repo' '
index 359e03ff836cf6ac087c83c5b7abe7365ecb4447..ce3af928437dee01a168cb3350403c0726229bbd 100755 (executable)
@@ -98,8 +98,8 @@ test_expect_success "fetch alone only fetches superproject" '
                cd downstream &&
                git fetch >../actual.out 2>../actual.err
        ) &&
-       ! test -s actual.out &&
-       ! test -s actual.err
+       test_must_be_empty actual.out &&
+       test_must_be_empty actual.err
 '
 
 test_expect_success "fetch --no-recurse-submodules only fetches superproject" '
@@ -107,8 +107,8 @@ test_expect_success "fetch --no-recurse-submodules only fetches superproject" '
                cd downstream &&
                git fetch --no-recurse-submodules >../actual.out 2>../actual.err
        ) &&
-       ! test -s actual.out &&
-       ! test -s actual.err
+       test_must_be_empty actual.out &&
+       test_must_be_empty actual.err
 '
 
 test_expect_success "using fetchRecurseSubmodules=true in .gitmodules recurses into submodules" '
@@ -127,8 +127,8 @@ test_expect_success "--no-recurse-submodules overrides .gitmodules config" '
                cd downstream &&
                git fetch --no-recurse-submodules >../actual.out 2>../actual.err
        ) &&
-       ! test -s actual.out &&
-       ! test -s actual.err
+       test_must_be_empty actual.out &&
+       test_must_be_empty actual.err
 '
 
 test_expect_success "using fetchRecurseSubmodules=false in .git/config overrides setting in .gitmodules" '
@@ -137,8 +137,8 @@ test_expect_success "using fetchRecurseSubmodules=false in .git/config overrides
                git config submodule.submodule.fetchRecurseSubmodules false &&
                git fetch >../actual.out 2>../actual.err
        ) &&
-       ! test -s actual.out &&
-       ! test -s actual.err
+       test_must_be_empty actual.out &&
+       test_must_be_empty actual.err
 '
 
 test_expect_success "--recurse-submodules overrides fetchRecurseSubmodules setting from .git/config" '
@@ -157,8 +157,8 @@ test_expect_success "--quiet propagates to submodules" '
                cd downstream &&
                git fetch --recurse-submodules --quiet >../actual.out 2>../actual.err
        ) &&
-       ! test -s actual.out &&
-       ! test -s actual.err
+       test_must_be_empty actual.out &&
+       test_must_be_empty actual.err
 '
 
 test_expect_success "--quiet propagates to parallel submodules" '
@@ -166,8 +166,8 @@ test_expect_success "--quiet propagates to parallel submodules" '
                cd downstream &&
                git fetch --recurse-submodules -j 2 --quiet  >../actual.out 2>../actual.err
        ) &&
-       ! test -s actual.out &&
-       ! test -s actual.err
+       test_must_be_empty actual.out &&
+       test_must_be_empty actual.err
 '
 
 test_expect_success "--dry-run propagates to submodules" '
@@ -221,8 +221,8 @@ test_expect_success "--no-recurse-submodules overrides config setting" '
                git config fetch.recurseSubmodules true &&
                git fetch --no-recurse-submodules >../actual.out 2>../actual.err
        ) &&
-       ! test -s actual.out &&
-       ! test -s actual.err
+       test_must_be_empty actual.out &&
+       test_must_be_empty actual.err
 '
 
 test_expect_success "Recursion doesn't happen when no new commits are fetched in the superproject" '
@@ -235,8 +235,8 @@ test_expect_success "Recursion doesn't happen when no new commits are fetched in
                git config --unset fetch.recurseSubmodules &&
                git fetch >../actual.out 2>../actual.err
        ) &&
-       ! test -s actual.out &&
-       ! test -s actual.err
+       test_must_be_empty actual.out &&
+       test_must_be_empty actual.err
 '
 
 test_expect_success "Recursion stops when no new submodule commits are fetched" '
@@ -268,7 +268,7 @@ test_expect_success "Recursion doesn't happen when new superproject commits don'
                cd downstream &&
                git fetch >../actual.out 2>../actual.err
        ) &&
-       ! test -s actual.out &&
+       test_must_be_empty actual.out &&
        test_i18ncmp expect.err.file actual.err
 '
 
@@ -357,8 +357,8 @@ test_expect_success "'--recurse-submodules=on-demand' doesn't recurse when no ne
                git fetch --recurse-submodules=on-demand >../actual.out 2>../actual.err &&
                git config --unset fetch.recurseSubmodules
        ) &&
-       ! test -s actual.out &&
-       ! test -s actual.err
+       test_must_be_empty actual.out &&
+       test_must_be_empty actual.err
 '
 
 test_expect_success "'--recurse-submodules=on-demand' recurses as deep as necessary (and ignores config)" '
@@ -402,7 +402,7 @@ test_expect_success "'--recurse-submodules=on-demand' stops when no new submodul
                cd downstream &&
                git fetch --recurse-submodules=on-demand >../actual.out 2>../actual.err
        ) &&
-       ! test -s actual.out &&
+       test_must_be_empty actual.out &&
        test_i18ncmp expect.err.file actual.err
 '
 
@@ -477,7 +477,7 @@ test_expect_success "don't fetch submodule when newly recorded commits are alrea
                cd downstream &&
                git fetch >../actual.out 2>../actual.err
        ) &&
-       ! test -s actual.out &&
+       test_must_be_empty actual.out &&
        test_i18ncmp expect.err actual.err &&
        (
                cd submodule &&
index 0d4c52016b2b3651fa638fcc416f22d236c87fc2..12c1e43a843023bc582cef2321a58d10c30b83a1 100755 (executable)
@@ -51,7 +51,7 @@ test_expect_success 'no-op fetch -v stderr is as expected' '
 
 test_expect_success 'no-op fetch without "-v" is quiet' '
        (cd clone && git fetch 2>../stderr) &&
-       ! test -s stderr
+       test_must_be_empty stderr
 '
 
 test_expect_success 'remote detects correct HEAD' '
index cc3fd2baf2b80817ffc39ab67a988dcf31dbc537..56ca467c0a18ed7267272eb288c86dec6b698909 100755 (executable)
@@ -384,7 +384,7 @@ test_expect_success 'mv does not complain when no .gitmodules file is found' '
        entry="$(git ls-files --stage sub | cut -f 1)" &&
        mkdir mod &&
        git mv sub mod/sub 2>actual.err &&
-       ! test -s actual.err &&
+       test_must_be_empty actual.err &&
        ! test -e sub &&
        [ "$entry" = "$(git ls-files --stage mod/sub | cut -f 1)" ] &&
        (
@@ -408,7 +408,7 @@ test_expect_success 'mv will error out on a modified .gitmodules file unless sta
        git diff-files --quiet -- sub &&
        git add .gitmodules &&
        git mv sub mod/sub 2>actual.err &&
-       ! test -s actual.err &&
+       test_must_be_empty actual.err &&
        ! test -e sub &&
        [ "$entry" = "$(git ls-files --stage mod/sub | cut -f 1)" ] &&
        (
@@ -469,7 +469,7 @@ test_expect_success 'checking out a commit before submodule moved needs manual u
        git update-index --refresh &&
        git diff-files --quiet -- sub .gitmodules &&
        git status -s sub2 >actual &&
-       ! test -s actual
+       test_must_be_empty actual
 '
 
 test_expect_success 'mv -k does not accidentally destroy submodules' '
index ab9da61da391f1b6040076dda2454f602adef7d2..0e7d4421a73615e2906594f3bdea2ce9be323040 100755 (executable)
@@ -139,7 +139,7 @@ test_expect_success "checkout -m with dirty tree, renamed" '
        test_cmp expect uno &&
        ! test -f one &&
        git diff --cached >current &&
-       ! test -s current
+       test_must_be_empty current
 
 '
 
@@ -163,7 +163,7 @@ test_expect_success 'checkout -m with merge conflict' '
        fill d2 aT d7 aS >expect &&
        test_cmp current expect &&
        git diff --cached two >current &&
-       ! test -s current
+       test_must_be_empty current
 '
 
 test_expect_success 'format of merge conflict from checkout -m' '
index 9e0d31700e0cf8228e0093f3166ec830a5816ba4..0fef49954f0b89c6f7532af24452e25805ddbe7b 100755 (executable)
@@ -174,7 +174,7 @@ test_expect_success 'submodule update does not fetch already present commits' '
          git submodule update > ../actual 2> ../actual.err
        ) &&
        test_i18ncmp expected actual &&
-       ! test -s actual.err
+       test_must_be_empty actual.err
 '
 
 test_expect_success 'submodule update should fail due to local changes' '
index fc44ec96aacbd9ed03341448a9b3bff44bce8c45..825da1404a0a036dfcc0789c951de5c9c53b1d1d 100755 (executable)
@@ -941,7 +941,7 @@ test_expect_success 'grep from a subdirectory to search wider area (2)' '
        (
                cd s || exit 1
                ( git grep xxyyzz .. >out ; echo $? >status )
-               ! test -s out &&
+               test_must_be_empty out &&
                test 1 = $(cat status)
        )
 '
index f762038f0ea95ce0f9d411ff6f494088ee1fc22c..3bf4255aa3ed9c05ca02d08b4795054f296e4de4 100755 (executable)
@@ -85,7 +85,7 @@ EOF
 test_expect_success 'clone using git svn' 'git svn clone -r1 "$svnrepo" x'
 test_expect_success 'enable broken symlink workaround' \
   '(cd x && git config svn.brokenSymlinkWorkaround true)'
-test_expect_success '"bar" is an empty file' 'test -f x/bar && ! test -s x/bar'
+test_expect_success '"bar" is an empty file' 'test_must_be_empty x/bar'
 test_expect_success 'get "bar" => symlink fix from svn' \
                '(cd x && git svn rebase)'
 test_expect_success SYMLINKS '"bar" becomes a symlink' 'test -h x/bar'
@@ -94,14 +94,14 @@ test_expect_success SYMLINKS '"bar" becomes a symlink' 'test -h x/bar'
 test_expect_success 'clone using git svn' 'git svn clone -r1 "$svnrepo" y'
 test_expect_success 'disable broken symlink workaround' \
   '(cd y && git config svn.brokenSymlinkWorkaround false)'
-test_expect_success '"bar" is an empty file' 'test -f y/bar && ! test -s y/bar'
+test_expect_success '"bar" is an empty file' 'test_must_be_empty y/bar'
 test_expect_success 'get "bar" => symlink fix from svn' \
                '(cd y && git svn rebase)'
 test_expect_success '"bar" does not become a symlink' '! test -L y/bar'
 
 # svn.brokenSymlinkWorkaround is unset
 test_expect_success 'clone using git svn' 'git svn clone -r1 "$svnrepo" z'
-test_expect_success '"bar" is an empty file' 'test -f z/bar && ! test -s z/bar'
+test_expect_success '"bar" is an empty file' 'test_must_be_empty z/bar'
 test_expect_success 'get "bar" => symlink fix from svn' \
                '(cd z && git svn rebase)'
 test_expect_success '"bar" does not become a symlink' '! test -L z/bar'
index 93db45db7d69e460d7005815c19ccc63e916e50c..2f80b216fe35bdcd4e3169306a69e8ca594dccdb 100755 (executable)
@@ -13,8 +13,7 @@ test_expect_success 'test that b1 exists and is empty' '
        (
                cd x &&
                git reset --hard origin/branch-c &&
-               test -f b1 &&
-               ! test -s b1
+               test_must_be_empty b1
        )
        '