tests: use 'test_must_be_empty' instead of '! test -s'
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>
@ -11,7 +11,7 @@ test_expect_success 'git show a ISO-8859-1 commit under C locale' '
@@ -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
@@ -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_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' '
@@ -268,7 +268,7 @@ test_expect_success '#4: core.worktree without GIT_DIR set is accepted' '
@ -382,7 +382,7 @@ test_expect_success 'rm does not complain when no .gitmodules file is found' '
@@ -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
@@ -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
@@ -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' '
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
@@ -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'
@@ -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
@@ -357,8 +357,8 @@ test_expect_success "'--recurse-submodules=on-demand' doesn't recurse when no ne
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
@@ -402,7 +402,7 @@ test_expect_success "'--recurse-submodules=on-demand' stops when no new submodul
@ -477,7 +477,7 @@ test_expect_success "don't fetch submodule when newly recorded commits are alrea
@@ -477,7 +477,7 @@ test_expect_success "don't fetch submodule when newly recorded commits are alrea
@ -384,7 +384,7 @@ test_expect_success 'mv does not complain when no .gitmodules file is found' '
@@ -384,7 +384,7 @@ test_expect_success 'mv does not complain when no .gitmodules file is found' '
@ -408,7 +408,7 @@ test_expect_success 'mv will error out on a modified .gitmodules file unless sta
@@ -408,7 +408,7 @@ test_expect_success 'mv will error out on a modified .gitmodules file unless sta
@ -469,7 +469,7 @@ test_expect_success 'checking out a commit before submodule moved needs manual u
@@ -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' '
@ -941,7 +941,7 @@ test_expect_success 'grep from a subdirectory to search wider area (2)' '
@@ -941,7 +941,7 @@ test_expect_success 'grep from a subdirectory to search wider area (2)' '