summaryrefslogtreecommitdiff
path: root/t/t4027-diff-submodule.sh
diff options
context:
space:
mode:
authorSZEDER Gábor <szeder.dev@gmail.com>2018-08-19 21:57:22 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-08-21 18:48:29 (GMT)
commitec10b018e76b3f4f40db96a24202c6b8c056bd0f (patch)
treefca8ac2204c583b2aec884c7a87541f11d117735 /t/t4027-diff-submodule.sh
parentd3c6751b18170276f80e3578d16877d43ad22709 (diff)
downloadgit-ec10b018e76b3f4f40db96a24202c6b8c056bd0f.zip
git-ec10b018e76b3f4f40db96a24202c6b8c056bd0f.tar.gz
git-ec10b018e76b3f4f40db96a24202c6b8c056bd0f.tar.bz2
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>
Diffstat (limited to 't/t4027-diff-submodule.sh')
-rwxr-xr-xt/t4027-diff-submodule.sh26
1 files changed, 13 insertions, 13 deletions
diff --git a/t/t4027-diff-submodule.sh b/t/t4027-diff-submodule.sh
index 6304130..e5f9eb7 100755
--- a/t/t4027-diff-submodule.sh
+++ b/t/t4027-diff-submodule.sh
@@ -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 &&