From ec10b018e76b3f4f40db96a24202c6b8c056bd0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?SZEDER=20G=C3=A1bor?= Date: Sun, 19 Aug 2018 23:57:22 +0200 Subject: tests: use 'test_must_be_empty' instead of '! test -s' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Junio C Hamano --- t/t5526-fetch-submodules.sh | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 't/t5526-fetch-submodules.sh') diff --git a/t/t5526-fetch-submodules.sh b/t/t5526-fetch-submodules.sh index 359e03ff83..ce3af92843 100755 --- a/t/t5526-fetch-submodules.sh +++ b/t/t5526-fetch-submodules.sh @@ -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 && -- cgit v1.2.3