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/t2204-add-ignored.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 't/t2204-add-ignored.sh') diff --git a/t/t2204-add-ignored.sh b/t/t2204-add-ignored.sh index 8340ac2f07..2e07365bbb 100755 --- a/t/t2204-add-ignored.sh +++ b/t/t2204-add-ignored.sh @@ -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 ) ' -- cgit v1.2.3