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 diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh index af61d08..4e588ed 100755 --- a/t/t0000-basic.sh +++ b/t/t0000-basic.sh @@ -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 ) diff --git a/t/t0090-cache-tree.sh b/t/t0090-cache-tree.sh index 0c61268..9e88a56 100755 --- a/t/t0090-cache-tree.sh +++ b/t/t0090-cache-tree.sh @@ -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' ' diff --git a/t/t0203-gettext-setlocale-sanity.sh b/t/t0203-gettext-setlocale-sanity.sh index 71b0d74..0ce1f22 100755 --- a/t/t0203-gettext-setlocale-sanity.sh +++ b/t/t0203-gettext-setlocale-sanity.sh @@ -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 ' diff --git a/t/t1501-work-tree.sh b/t/t1501-work-tree.sh index afcdfaf..3498d3d 100755 --- a/t/t1501-work-tree.sh +++ b/t/t1501-work-tree.sh @@ -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 } diff --git a/t/t1510-repo-setup.sh b/t/t1510-repo-setup.sh index 972bd9c..9974457 100755 --- a/t/t1510-repo-setup.sh +++ b/t/t1510-repo-setup.sh @@ -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 diff --git a/t/t2013-checkout-submodule.sh b/t/t2013-checkout-submodule.sh index 6ef1573..8f86b5f 100755 --- a/t/t2013-checkout-submodule.sh +++ b/t/t2013-checkout-submodule.sh @@ -44,7 +44,7 @@ test_expect_success '"checkout " 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 " honors submodule.*.ignore from .gitmodules' ' @@ -52,7 +52,7 @@ test_expect_success '"checkout " 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 " honors submodule.*.ignore from .git/config' ' @@ -60,7 +60,7 @@ test_expect_success '"checkout " 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 diff --git a/t/t2204-add-ignored.sh b/t/t2204-add-ignored.sh index 8340ac2..2e07365 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 ) ' diff --git a/t/t3600-rm.sh b/t/t3600-rm.sh index b8fbdef..b178a37 100755 --- a/t/t3600-rm.sh +++ b/t/t3600-rm.sh @@ -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' ' diff --git a/t/t4011-diff-symlink.sh b/t/t4011-diff-symlink.sh index 108c012..5ae19b9 100755 --- a/t/t4011-diff-symlink.sh +++ b/t/t4011-diff-symlink.sh @@ -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' ' diff --git a/t/t4019-diff-wserror.sh b/t/t4019-diff-wserror.sh index a501975..c6135c7 100755 --- a/t/t4019-diff-wserror.sh +++ b/t/t4019-diff-wserror.sh @@ -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 ' 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 && diff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh index 058ee08..302f216 100755 --- a/t/t4041-diff-submodule-option.sh +++ b/t/t4041-diff-submodule-option.sh @@ -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' ' diff --git a/t/t4060-diff-submodule-option-diff-format.sh b/t/t4060-diff-submodule-option-diff-format.sh index 4b168d0..6fc3da8 100755 --- a/t/t4060-diff-submodule-option-diff-format.sh +++ b/t/t4060-diff-submodule-option-diff-format.sh @@ -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 diff --git a/t/t4124-apply-ws-rule.sh b/t/t4124-apply-ws-rule.sh index 4fc27c5..7e32237 100755 --- a/t/t4124-apply-ws-rule.sh +++ b/t/t4124-apply-ws-rule.sh @@ -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 ' diff --git a/t/t4150-am.sh b/t/t4150-am.sh index 1ebc587..38fe717 100755 --- a/t/t4150-am.sh +++ b/t/t4150-am.sh @@ -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 output.out 2>&1 && - ! test -s output.out + test_must_be_empty output.out ' test_expect_success 'am empty-file does not infloop' ' diff --git a/t/t5401-update-hooks.sh b/t/t5401-update-hooks.sh index 7f278d8c..ce151e7 100755 --- a/t/t5401-update-hooks.sh +++ b/t/t5401-update-hooks.sh @@ -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 <expect diff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh index 3d33ab3..07fcea0 100755 --- a/t/t5500-fetch-pack.sh +++ b/t/t5500-fetch-pack.sh @@ -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' ' diff --git a/t/t5526-fetch-submodules.sh b/t/t5526-fetch-submodules.sh index 359e03f..ce3af92 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 && diff --git a/t/t5570-git-daemon.sh b/t/t5570-git-daemon.sh index 0d4c520..12c1e43 100755 --- a/t/t5570-git-daemon.sh +++ b/t/t5570-git-daemon.sh @@ -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' ' diff --git a/t/t7001-mv.sh b/t/t7001-mv.sh index cc3fd2b..56ca467 100755 --- a/t/t7001-mv.sh +++ b/t/t7001-mv.sh @@ -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' ' diff --git a/t/t7201-co.sh b/t/t7201-co.sh index ab9da61..0e7d442 100755 --- a/t/t7201-co.sh +++ b/t/t7201-co.sh @@ -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' ' diff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh index 9e0d317..0fef499 100755 --- a/t/t7406-submodule-update.sh +++ b/t/t7406-submodule-update.sh @@ -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' ' diff --git a/t/t7810-grep.sh b/t/t7810-grep.sh index fc44ec9..825da14 100755 --- a/t/t7810-grep.sh +++ b/t/t7810-grep.sh @@ -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) ) ' diff --git a/t/t9131-git-svn-empty-symlink.sh b/t/t9131-git-svn-empty-symlink.sh index f762038..3bf4255 100755 --- a/t/t9131-git-svn-empty-symlink.sh +++ b/t/t9131-git-svn-empty-symlink.sh @@ -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' diff --git a/t/t9135-git-svn-moved-branch-empty-file.sh b/t/t9135-git-svn-moved-branch-empty-file.sh index 93db45d..2f80b21 100755 --- a/t/t9135-git-svn-moved-branch-empty-file.sh +++ b/t/t9135-git-svn-moved-branch-empty-file.sh @@ -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 ) ' -- cgit v0.10.2-6-g49f6 From f0dc593a95877298ba6fa9d29e5c779832ad5894 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?SZEDER=20G=C3=A1bor?= Date: Sun, 19 Aug 2018 23:57:23 +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 no 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 created by: sed -i -e 's/test ! -s/test_must_be_empty/' t[0-9]*.sh Signed-off-by: SZEDER Gábor Signed-off-by: Junio C Hamano diff --git a/t/t4201-shortlog.sh b/t/t4201-shortlog.sh index 58c2773..d3a7ce6 100755 --- a/t/t4201-shortlog.sh +++ b/t/t4201-shortlog.sh @@ -192,7 +192,7 @@ test_expect_success 'shortlog with revision pseudo options' ' test_expect_success 'shortlog with --output=' ' git shortlog --output=shortlog -1 master >output && - test ! -s output && + test_must_be_empty output && test_line_count = 3 shortlog ' diff --git a/t/t4211-line-log.sh b/t/t4211-line-log.sh index d0377fa..6e378b2 100755 --- a/t/t4211-line-log.sh +++ b/t/t4211-line-log.sh @@ -102,7 +102,7 @@ test_expect_success '-L with --first-parent and a merge' ' test_expect_success '-L with --output' ' git checkout parallel-change && git log --output=log -L :main:b.c >output && - test ! -s output && + test_must_be_empty output && test_line_count = 70 log ' diff --git a/t/t8010-cat-file-filters.sh b/t/t8010-cat-file-filters.sh index 0f86c19..31de4b6 100755 --- a/t/t8010-cat-file-filters.sh +++ b/t/t8010-cat-file-filters.sh @@ -47,7 +47,7 @@ test_expect_success 'cat-file --textconv --path= works' ' test_expect_success '--path= complains without --textconv/--filters' ' sha1=$(git rev-parse -q --verify HEAD:world.txt) && test_must_fail git cat-file --path=hello.txt blob $sha1 >actual 2>err && - test ! -s actual && + test_must_be_empty actual && grep "path.*needs.*filters" err ' diff --git a/t/t9802-git-p4-filetype.sh b/t/t9802-git-p4-filetype.sh index 1fc9b33..9978352 100755 --- a/t/t9802-git-p4-filetype.sh +++ b/t/t9802-git-p4-filetype.sh @@ -310,7 +310,7 @@ test_expect_success SYMLINKS 'empty symlink target' ' # p4 to sync here will make it generate errors. cd "$cli" && p4 print -q //depot/empty-symlink#2 >out && - test ! -s out + test_must_be_empty out ) && test_when_finished cleanup_git && -- cgit v0.10.2-6-g49f6 From ec21ac8c189537df815e49bdf8f08da927665cf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?SZEDER=20G=C3=A1bor?= Date: Sun, 19 Aug 2018 23:57:24 +0200 Subject: tests: use 'test_must_be_empty' instead of 'test_cmp /dev/null ' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Using 'test_must_be_empty' is more idiomatic than 'test_cmp /dev/null out', and its message on error is perhaps a bit more to the point. This patch was basically created by running: sed -i -e 's%test_cmp /dev/null%test_must_be_empty%' t[0-9]*.sh with the exception of the change in 'should not fail in an empty repo' in 't7401-submodule-summary.sh', where it was 'test_cmp output /dev/null'. Signed-off-by: SZEDER Gábor Signed-off-by: Junio C Hamano diff --git a/t/t3210-pack-refs.sh b/t/t3210-pack-refs.sh index afa27ff..112cbb0 100755 --- a/t/t3210-pack-refs.sh +++ b/t/t3210-pack-refs.sh @@ -127,7 +127,7 @@ test_expect_success 'explicit pack-refs with dangling packed reference' ' git reflog expire --expire=all --all && git prune --expire=all && git pack-refs --all 2>result && - test_cmp /dev/null result + test_must_be_empty result ' test_expect_success 'delete ref with dangling packed version' ' @@ -139,7 +139,7 @@ test_expect_success 'delete ref with dangling packed version' ' git reflog expire --expire=all --all && git prune --expire=all && git branch -d lamb 2>result && - test_cmp /dev/null result + test_must_be_empty result ' test_expect_success 'delete ref while another dangling packed ref' ' @@ -150,7 +150,7 @@ test_expect_success 'delete ref while another dangling packed ref' ' git reflog expire --expire=all --all && git prune --expire=all && git branch -d lamb 2>result && - test_cmp /dev/null result + test_must_be_empty result ' test_expect_success 'pack ref directly below refs/' ' diff --git a/t/t3308-notes-merge.sh b/t/t3308-notes-merge.sh index ab946a5..d60588e 100755 --- a/t/t3308-notes-merge.sh +++ b/t/t3308-notes-merge.sh @@ -183,7 +183,7 @@ test_expect_success 'merge empty notes ref (z => y)' ' git notes add -m "foo" && git notes remove && git notes >output_notes_z && - test_cmp /dev/null output_notes_z && + test_must_be_empty output_notes_z && # Do the merge (z => y) git config core.notesRef refs/notes/y && git notes merge z && diff --git a/t/t3310-notes-merge-manual-resolve.sh b/t/t3310-notes-merge-manual-resolve.sh index 9c1bf6e..a1cf4ec 100755 --- a/t/t3310-notes-merge-manual-resolve.sh +++ b/t/t3310-notes-merge-manual-resolve.sh @@ -337,7 +337,7 @@ EOF git notes merge --commit && # No .git/NOTES_MERGE_* files left test_might_fail ls .git/NOTES_MERGE_* >output 2>/dev/null && - test_cmp /dev/null output && + test_must_be_empty output && # Merge commit has pre-merge y and pre-merge z as parents test "$(git rev-parse refs/notes/m^1)" = "$(cat pre_merge_y)" && test "$(git rev-parse refs/notes/m^2)" = "$(cat pre_merge_z)" && @@ -399,7 +399,7 @@ test_expect_success 'abort notes merge' ' git notes merge --abort && # No .git/NOTES_MERGE_* files left test_might_fail ls .git/NOTES_MERGE_* >output 2>/dev/null && - test_cmp /dev/null output && + test_must_be_empty output && # m has not moved (still == y) test "$(git rev-parse refs/notes/m)" = "$(cat pre_merge_y)" && # Verify that other notes refs has not changed (w, x, y and z) @@ -466,7 +466,7 @@ EOF git notes merge --commit && # No .git/NOTES_MERGE_* files left test_might_fail ls .git/NOTES_MERGE_* >output 2>/dev/null && - test_cmp /dev/null output && + test_must_be_empty output && # Merge commit has pre-merge y and pre-merge z as parents test "$(git rev-parse refs/notes/m^1)" = "$(cat pre_merge_y)" && test "$(git rev-parse refs/notes/m^2)" = "$(cat pre_merge_z)" && @@ -555,7 +555,7 @@ test_expect_success 'resolve situation by aborting the notes merge' ' git notes merge --abort && # No .git/NOTES_MERGE_* files left test_might_fail ls .git/NOTES_MERGE_* >output 2>/dev/null && - test_cmp /dev/null output && + test_must_be_empty output && # m has not moved (still == w) test "$(git rev-parse refs/notes/m)" = "$(git rev-parse refs/notes/w)" && # Verify that other notes refs has not changed (w, x, y and z) diff --git a/t/t4047-diff-dirstat.sh b/t/t4047-diff-dirstat.sh index 447a8ff..7fec2cb 100755 --- a/t/t4047-diff-dirstat.sh +++ b/t/t4047-diff-dirstat.sh @@ -940,7 +940,7 @@ test_expect_success 'diff.dirstat=0,lines' ' test_expect_success '--dirstat=future_param,lines,0 should fail loudly' ' test_must_fail git diff --dirstat=future_param,lines,0 HEAD^..HEAD >actual_diff_dirstat 2>actual_error && test_debug "cat actual_error" && - test_cmp /dev/null actual_diff_dirstat && + test_must_be_empty actual_diff_dirstat && test_i18ngrep -q "future_param" actual_error && test_i18ngrep -q "\--dirstat" actual_error ' @@ -948,7 +948,7 @@ test_expect_success '--dirstat=future_param,lines,0 should fail loudly' ' test_expect_success '--dirstat=dummy1,cumulative,2dummy should report both unrecognized parameters' ' test_must_fail git diff --dirstat=dummy1,cumulative,2dummy HEAD^..HEAD >actual_diff_dirstat 2>actual_error && test_debug "cat actual_error" && - test_cmp /dev/null actual_diff_dirstat && + test_must_be_empty actual_diff_dirstat && test_i18ngrep -q "dummy1" actual_error && test_i18ngrep -q "2dummy" actual_error && test_i18ngrep -q "\--dirstat" actual_error diff --git a/t/t4116-apply-reverse.sh b/t/t4116-apply-reverse.sh index ce8567f..b99e65c 100755 --- a/t/t4116-apply-reverse.sh +++ b/t/t4116-apply-reverse.sh @@ -42,7 +42,7 @@ test_expect_success 'apply in reverse' ' git reset --hard second && git apply --reverse --binary --index patch && git diff >diff && - test_cmp /dev/null diff + test_must_be_empty diff ' diff --git a/t/t5509-fetch-push-namespaces.sh b/t/t5509-fetch-push-namespaces.sh index 75c570a..c88df78 100755 --- a/t/t5509-fetch-push-namespaces.sh +++ b/t/t5509-fetch-push-namespaces.sh @@ -44,7 +44,7 @@ test_expect_success 'pushing into a repository using a ref namespace' ' test_cmp expected actual && # Try a namespace with no content git ls-remote "ext::git --namespace=garbage %s ../pushee" >actual && - test_cmp /dev/null actual && + test_must_be_empty actual && git ls-remote pushee-unnamespaced >actual && sed -e "s|refs/|refs/namespaces/namespace/refs/|" expected >expected.unnamespaced && test_cmp expected.unnamespaced actual diff --git a/t/t5523-push-upstream.sh b/t/t5523-push-upstream.sh index d6981ba..c0df81a 100755 --- a/t/t5523-push-upstream.sh +++ b/t/t5523-push-upstream.sh @@ -113,7 +113,7 @@ test_expect_success TTY 'quiet push' ' ensure_fresh_upstream && test_terminal git push --quiet --no-progress upstream master 2>&1 | tee output && - test_cmp /dev/null output + test_must_be_empty output ' test_done diff --git a/t/t5541-http-push-smart.sh b/t/t5541-http-push-smart.sh index a2af693..4319ef6 100755 --- a/t/t5541-http-push-smart.sh +++ b/t/t5541-http-push-smart.sh @@ -226,7 +226,7 @@ test_expect_success TTY 'push --quiet silences status and progress' ' cd "$ROOT_PATH"/test_repo_clone && test_commit quiet && test_terminal git push --quiet >output 2>&1 && - test_cmp /dev/null output + test_must_be_empty output ' test_expect_success TTY 'push --no-progress silences progress but not status' ' diff --git a/t/t7401-submodule-summary.sh b/t/t7401-submodule-summary.sh index 1cd12b3..9bc841d 100755 --- a/t/t7401-submodule-summary.sh +++ b/t/t7401-submodule-summary.sh @@ -300,7 +300,7 @@ test_expect_success 'should not fail in an empty repo' " git init xyzzy && cd xyzzy && git submodule summary >output 2>&1 && - test_cmp output /dev/null + test_must_be_empty output " test_done diff --git a/t/t7810-grep.sh b/t/t7810-grep.sh index 825da14..42d5354 100755 --- a/t/t7810-grep.sh +++ b/t/t7810-grep.sh @@ -483,7 +483,7 @@ test_expect_success 'grep -L -C' ' test_expect_success 'grep --files-without-match --quiet' ' git grep --files-without-match --quiet nonexistent_string >actual && - test_cmp /dev/null actual + test_must_be_empty actual ' cat >expected < Date: Sun, 19 Aug 2018 23:57:25 +0200 Subject: tests: use 'test_must_be_empty' instead of 'test_cmp ' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Using 'test_must_be_empty' is shorter and more idiomatic than >empty && test_cmp empty out as it saves the creation of an empty file. Furthermore, sometimes the expected empty file doesn't have such a descriptive name like 'empty', and its creation is far away from the place where it's finally used for comparison (e.g. in 't7600-merge.sh', where two expected empty files are created in the 'setup' test, but are used only about 500 lines later). These cases were found by instrumenting 'test_cmp' to error out the test script when it's used to compare empty files, and then converted manually. Note that even after this patch there still remain a lot of cases where we use 'test_cmp' to check empty files: - Sometimes the expected output is not hard-coded in the test, but 'test_cmp' is used to ensure that two similar git commands produce the same output, and that output happens to be empty, e.g. the test 'submodule update --merge - ignores --merge for new submodules' in 't7406-submodule-update.sh'. - Repetitive common tasks, including preparing the expected results and running 'test_cmp', are often extracted into a helper function, and some of this helper's callsites expect no output. - For the same reason as above, the whole 'test_expect_success' block is within a helper function, e.g. in 't3070-wildmatch.sh'. - Or 'test_cmp' is invoked in a loop, e.g. the test 'cvs update (-p)' in 't9400-git-cvsserver-server.sh'. Signed-off-by: SZEDER Gábor Signed-off-by: Junio C Hamano diff --git a/t/t0001-init.sh b/t/t0001-init.sh index 4c86505..28f34fd 100755 --- a/t/t0001-init.sh +++ b/t/t0001-init.sh @@ -167,9 +167,8 @@ test_expect_success 'reinit' ' ) && test_i18ngrep "Initialized empty" again/out1 && test_i18ngrep "Reinitialized existing" again/out2 && - >again/empty && - test_i18ncmp again/empty again/err1 && - test_i18ncmp again/empty again/err2 + test_must_be_empty again/err1 && + test_must_be_empty again/err2 ' test_expect_success 'init with --template' ' diff --git a/t/t0003-attributes.sh b/t/t0003-attributes.sh index f19ae4f..ee2f5c2 100755 --- a/t/t0003-attributes.sh +++ b/t/t0003-attributes.sh @@ -208,9 +208,8 @@ test_expect_success 'attribute test: --all option' ' ' test_expect_success 'attribute test: --cached option' ' - : >empty && git check-attr --cached --stdin --all actual && - test_cmp empty actual && + test_must_be_empty actual && git add .gitattributes a/.gitattributes a/b/.gitattributes && git check-attr --cached --stdin --all actual && test_cmp specified-all actual diff --git a/t/t0030-stripspace.sh b/t/t0030-stripspace.sh index b77948c..5ce47e8 100755 --- a/t/t0030-stripspace.sh +++ b/t/t0030-stripspace.sh @@ -320,22 +320,20 @@ test_expect_success \ test_expect_success \ 'spaces with newline at end should be replaced with empty string' ' - printf "" >expect && - echo | git stripspace >actual && - test_cmp expect actual && + test_must_be_empty actual && echo "$sss" | git stripspace >actual && - test_cmp expect actual && + test_must_be_empty actual && echo "$sss$sss" | git stripspace >actual && - test_cmp expect actual && + test_must_be_empty actual && echo "$sss$sss$sss" | git stripspace >actual && - test_cmp expect actual && + test_must_be_empty actual && echo "$sss$sss$sss$sss" | git stripspace >actual && - test_cmp expect actual + test_must_be_empty actual ' test_expect_success \ @@ -349,19 +347,17 @@ test_expect_success \ test_expect_success \ 'spaces without newline at end should be replaced with empty string' ' - printf "" >expect && - printf "" | git stripspace >actual && - test_cmp expect actual && + test_must_be_empty actual && printf "$sss$sss" | git stripspace >actual && - test_cmp expect actual && + test_must_be_empty actual && printf "$sss$sss$sss" | git stripspace >actual && - test_cmp expect actual && + test_must_be_empty actual && printf "$sss$sss$sss$sss" | git stripspace >actual && - test_cmp expect actual + test_must_be_empty actual ' test_expect_success \ diff --git a/t/t0040-parse-options.sh b/t/t0040-parse-options.sh index 04d474c..5b0560f 100755 --- a/t/t0040-parse-options.sh +++ b/t/t0040-parse-options.sh @@ -286,11 +286,9 @@ test_expect_success 'OPT_CALLBACK() and OPT_BIT() work' ' test_cmp expect output ' ->expect - test_expect_success 'OPT_CALLBACK() and callback errors work' ' test_must_fail test-parse-options --no-length >output 2>output.err && - test_i18ncmp expect output && + test_must_be_empty output && test_must_be_empty output.err ' diff --git a/t/t0061-run-command.sh b/t/t0061-run-command.sh index c887ed5..3e131c5 100755 --- a/t/t0061-run-command.sh +++ b/t/t0061-run-command.sh @@ -11,7 +11,6 @@ cat >hello-script <<-EOF #!$SHELL_PATH cat hello-script EOF ->empty test_expect_success 'start_command reports ENOENT' ' test-tool run-command start-command-ENOENT ./does-not-exist @@ -23,7 +22,7 @@ test_expect_success 'run_command can run a command' ' test-tool run-command run-command ./hello.sh >actual 2>err && test_cmp hello-script actual && - test_cmp empty err + test_must_be_empty err ' test_expect_success !MINGW 'run_command can run a script without a #! line' ' @@ -34,7 +33,7 @@ test_expect_success !MINGW 'run_command can run a script without a #! line' ' test-tool run-command run-command ./hello >actual 2>err && test_cmp hello-script actual && - test_cmp empty err + test_must_be_empty err ' test_expect_success 'run_command does not try to execute a directory' ' @@ -47,7 +46,7 @@ test_expect_success 'run_command does not try to execute a directory' ' PATH=$PWD/bin1:$PWD/bin2:$PATH \ test-tool run-command run-command greet >actual 2>err && test_cmp bin2/greet actual && - test_cmp empty err + test_must_be_empty err ' test_expect_success POSIXPERM 'run_command passes over non-executable file' ' @@ -64,7 +63,7 @@ test_expect_success POSIXPERM 'run_command passes over non-executable file' ' PATH=$PWD/bin1:$PWD/bin2:$PATH \ test-tool run-command run-command greet >actual 2>err && test_cmp bin2/greet actual && - test_cmp empty err + test_must_be_empty err ' test_expect_success POSIXPERM 'run_command reports EACCES' ' diff --git a/t/t1300-config.sh b/t/t1300-config.sh index 03c2237..84e88cf 100755 --- a/t/t1300-config.sh +++ b/t/t1300-config.sh @@ -346,12 +346,9 @@ test_expect_success 'working --list' ' git config --list > output && test_cmp expect output ' -cat > expect << EOF -EOF - test_expect_success '--list without repo produces empty output' ' git --git-dir=nonexistent config --list >output && - test_cmp expect output + test_must_be_empty output ' cat > expect << EOF diff --git a/t/t1410-reflog.sh b/t/t1410-reflog.sh index 8293131..388b061 100755 --- a/t/t1410-reflog.sh +++ b/t/t1410-reflog.sh @@ -290,9 +290,8 @@ test_expect_success 'stale dirs do not cause d/f conflicts (reflogs off)' ' # same as before, but we only create a reflog for "one" if # it already exists, which it does not git -c core.logallrefupdates=false branch one master && - : >expect && git log -g --format="%gd %gs" one >actual && - test_cmp expect actual + test_must_be_empty actual ' # Triggering the bug detected by this test requires a newline to fall diff --git a/t/t1411-reflog-show.sh b/t/t1411-reflog-show.sh index 5969077..26590f9 100755 --- a/t/t1411-reflog-show.sh +++ b/t/t1411-reflog-show.sh @@ -136,13 +136,12 @@ test_expect_success '--date magic does not override explicit @{0} syntax' ' test_cmp expect actual ' -: >expect test_expect_success 'empty reflog file' ' git branch empty && git reflog expire --expire=all refs/heads/empty && git log -g empty >actual && - test_cmp expect actual + test_must_be_empty actual ' # This guards against the alternative of showing the diffs vs. the diff --git a/t/t1450-fsck.sh b/t/t1450-fsck.sh index 91fd714..a652f60 100755 --- a/t/t1450-fsck.sh +++ b/t/t1450-fsck.sh @@ -16,8 +16,7 @@ test_expect_success setup ' git checkout HEAD^0 && test_commit B fileB two && git tag -d A B && - git reflog expire --expire=now --all && - >empty + git reflog expire --expire=now --all ' test_expect_success 'loose objects borrowed from alternate are not missing' ' @@ -29,12 +28,12 @@ test_expect_success 'loose objects borrowed from alternate are not missing' ' test_commit C fileC one && git fsck --no-dangling >../actual 2>&1 ) && - test_cmp empty actual + test_must_be_empty actual ' test_expect_success 'HEAD is part of refs, valid objects appear valid' ' git fsck >actual 2>&1 && - test_cmp empty actual + test_must_be_empty actual ' # Corruption tests follow. Make sure to remove all traces of the @@ -346,12 +345,12 @@ test_expect_success 'tag with NUL in header' ' test_expect_success 'cleaned up' ' git fsck >actual 2>&1 && - test_cmp empty actual + test_must_be_empty actual ' test_expect_success 'rev-list --verify-objects' ' git rev-list --verify-objects --all >/dev/null 2>out && - test_cmp empty out + test_must_be_empty out ' test_expect_success 'rev-list --verify-objects with bad sha1' ' diff --git a/t/t1600-index.sh b/t/t1600-index.sh index c442231..42962ed 100755 --- a/t/t1600-index.sh +++ b/t/t1600-index.sh @@ -41,8 +41,7 @@ test_expect_success 'no warning with bogus GIT_INDEX_VERSION and existing index' GIT_INDEX_VERSION=1 && export GIT_INDEX_VERSION && git add a 2>actual.err && - >expect.err && - test_i18ncmp expect.err actual.err + test_must_be_empty actual.err ) ' diff --git a/t/t1700-split-index.sh b/t/t1700-split-index.sh index 1e81b33..f85ba57 100755 --- a/t/t1700-split-index.sh +++ b/t/t1700-split-index.sh @@ -143,9 +143,7 @@ test_expect_success 'remove file not in base index' ' test_expect_success 'remove file in base index' ' git update-index --force-remove one && git ls-files --stage >ls-files.actual && - cat >ls-files.expect <<-EOF && - EOF - test_cmp ls-files.expect ls-files.actual && + test_must_be_empty ls-files.actual && test-tool dump-split-index .git/index | sed "/^own/d" >actual && cat >expect <<-EOF && diff --git a/t/t2200-add-update.sh b/t/t2200-add-update.sh index 314c73c..f764b7e 100755 --- a/t/t2200-add-update.sh +++ b/t/t2200-add-update.sh @@ -88,9 +88,8 @@ test_expect_success 'non-qualified update in subdir updates from the root' ' echo even more >>sub2 && git add -u ) && - : >expect && git diff-files --name-only >actual && - test_cmp expect actual + test_must_be_empty actual ' test_expect_success 'replace a file with a symlink' ' diff --git a/t/t2203-add-intent.sh b/t/t2203-add-intent.sh index e7a400b..68e54d5 100755 --- a/t/t2203-add-intent.sh +++ b/t/t2203-add-intent.sh @@ -195,8 +195,7 @@ test_expect_success 'rename detection finds the right names' ' test_cmp expected.4 actual.4 && git diff --cached --stat >actual.5 && - : >expected.5 && - test_cmp expected.5 actual.5 + test_must_be_empty actual.5 ) ' @@ -241,8 +240,7 @@ test_expect_success 'diff-files/diff-cached shows ita as new/not-new files' ' echo " create mode 100644 new-ita" >expected && test_cmp expected actual && git diff --cached --summary >actual2 && - : >expected2 && - test_cmp expected2 actual2 + test_must_be_empty actual2 ' diff --git a/t/t3001-ls-files-others-exclude.sh b/t/t3001-ls-files-others-exclude.sh index 3b47647..1ec7cb5 100755 --- a/t/t3001-ls-files-others-exclude.sh +++ b/t/t3001-ls-files-others-exclude.sh @@ -277,9 +277,8 @@ test_expect_success 'hide empty ignored sub-directory with --no-empty-directory' ' test_expect_success 'pattern matches prefix completely' ' - : >expect && git ls-files -i -o --exclude "/three/a.3[abc]" >actual && - test_cmp expect actual + test_must_be_empty actual ' test_expect_success 'ls-files with "**" patterns' ' @@ -295,9 +294,8 @@ EOF test_expect_success 'ls-files with "**" patterns and no slashes' ' - : >expect && git ls-files -o -i --exclude "one**a.1" >actual && - test_cmp expect actual + test_must_be_empty actual ' test_done diff --git a/t/t3004-ls-files-basic.sh b/t/t3004-ls-files-basic.sh index 9c7adbd..9fd5a1f 100755 --- a/t/t3004-ls-files-basic.sh +++ b/t/t3004-ls-files-basic.sh @@ -8,16 +8,14 @@ command-line arguments. . ./test-lib.sh ->empty - test_expect_success 'ls-files in empty repository' ' git ls-files >actual && - test_cmp empty actual + test_must_be_empty actual ' test_expect_success 'ls-files with nonexistent path' ' git ls-files doesnotexist >actual && - test_cmp empty actual + test_must_be_empty actual ' test_expect_success 'ls-files with nonsense option' ' diff --git a/t/t3035-merge-sparse.sh b/t/t3035-merge-sparse.sh index 0c0b433..c4b4a94 100755 --- a/t/t3035-merge-sparse.sh +++ b/t/t3035-merge-sparse.sh @@ -17,7 +17,6 @@ test_commit_this () { } test_expect_success 'setup' ' - : >empty && test_file checked-out init && test_file modify_delete modify_delete_init && test_commit_this init && @@ -38,7 +37,7 @@ test_expect_success 'reset --hard works after the conflict' ' test_expect_success 'is reset properly' ' git status --porcelain -- modify_delete >out && - test_cmp empty out && + test_must_be_empty out && test_path_is_missing modify_delete ' @@ -52,7 +51,7 @@ test_expect_success 'Merge abort works after the conflict' ' test_expect_success 'is aborted properly' ' git status --porcelain -- modify_delete >out && - test_cmp empty out && + test_must_be_empty out && test_path_is_missing modify_delete ' diff --git a/t/t3301-notes.sh b/t/t3301-notes.sh index 2d200fd..e5703a0 100755 --- a/t/t3301-notes.sh +++ b/t/t3301-notes.sh @@ -481,10 +481,8 @@ test_expect_success 'list specific note with "git notes list "' ' ' test_expect_success 'listing non-existing notes fails' ' - cat >expect <<-EOF && - EOF test_must_fail git notes list HEAD >actual && - test_cmp expect actual + test_must_be_empty actual ' test_expect_success 'append to existing note with "git notes append"' ' diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index 0161690..5997770 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -787,16 +787,15 @@ test_expect_success 'always cherry-pick with --no-ff' ' git tag original-no-ff-branch && set_fake_editor && git rebase -i --no-ff A && - touch empty && for p in 0 1 2 do test ! $(git rev-parse HEAD~$p) = $(git rev-parse original-no-ff-branch~$p) && git diff HEAD~$p original-no-ff-branch~$p > out && - test_cmp empty out + test_must_be_empty out done && test $(git rev-parse HEAD~3) = $(git rev-parse original-no-ff-branch~3) && git diff HEAD~3 original-no-ff-branch~3 > out && - test_cmp empty out + test_must_be_empty out ' test_expect_success 'set up commits with funny messages' ' diff --git a/t/t4015-diff-whitespace.sh b/t/t4015-diff-whitespace.sh index 5659c26..1ea9e0d 100755 --- a/t/t4015-diff-whitespace.sh +++ b/t/t4015-diff-whitespace.sh @@ -776,8 +776,6 @@ test_expect_success 'checkdiff allows new blank lines' ' git diff --check ' -cat <expect -EOF test_expect_success 'whitespace-only changes not reported' ' git reset --hard && echo >x "hello world" && @@ -785,7 +783,7 @@ test_expect_success 'whitespace-only changes not reported' ' git commit -m "hello 1" && echo >x "hello world" && git diff -b >actual && - test_cmp expect actual + test_must_be_empty actual ' cat <expect diff --git a/t/t4027-diff-submodule.sh b/t/t4027-diff-submodule.sh index e5f9eb7..9aa8e2b 100755 --- a/t/t4027-diff-submodule.sh +++ b/t/t4027-diff-submodule.sh @@ -239,10 +239,9 @@ test_expect_success 'git diff between submodule commits [.gitmodules]' ' ' test_expect_success 'git diff (empty submodule dir)' ' - : >empty && rm -rf sub/* sub/.git && git diff > actual.empty && - test_cmp empty actual.empty + test_must_be_empty actual.empty ' test_expect_success 'conflicted submodule setup' ' diff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh index 302f216..7a45942 100755 --- a/t/t4041-diff-submodule-option.sh +++ b/t/t4041-diff-submodule-option.sh @@ -257,9 +257,7 @@ test_expect_success 'typechanged submodule(blob->submodule)' ' commit_file sm1 && test_expect_success 'submodule is up to date' ' git diff-index -p --submodule=log HEAD >actual && - cat >expected <<-EOF && - EOF - test_cmp expected actual + test_must_be_empty actual ' test_expect_success 'submodule contains untracked content' ' diff --git a/t/t4060-diff-submodule-option-diff-format.sh b/t/t4060-diff-submodule-option-diff-format.sh index 6fc3da8..60c8dc7 100755 --- a/t/t4060-diff-submodule-option-diff-format.sh +++ b/t/t4060-diff-submodule-option-diff-format.sh @@ -392,9 +392,7 @@ test_expect_success 'typechanged submodule(blob->submodule)' ' commit_file sm1 && test_expect_success 'submodule is up to date' ' git diff-index -p --submodule=diff HEAD >actual && - cat >expected <<-EOF && - EOF - test_cmp expected actual + test_must_be_empty actual ' test_expect_success 'submodule contains untracked content' ' diff --git a/t/t4132-apply-removal.sh b/t/t4132-apply-removal.sh index a2bc1cd..fec1d6f 100755 --- a/t/t4132-apply-removal.sh +++ b/t/t4132-apply-removal.sh @@ -49,8 +49,7 @@ test_expect_success setup ' sed -e "s/TS0/$timeGMT/" -e "s/TS1/$epocGMT/" removeGMT.patch && sed -e "s/TS0/$timeWest/" -e "s/TS1/$epocWest2/" removeWest2.patch && - echo something >something && - >empty + echo something >something ' for patch in *.patch @@ -81,7 +80,7 @@ do git add file && git apply --index $patch && test -f file && - test_cmp empty file + test_must_be_empty file ;; remove*) # must remove the file diff --git a/t/t4203-mailmap.sh b/t/t4203-mailmap.sh index 0dd8b65..43b1522 100755 --- a/t/t4203-mailmap.sh +++ b/t/t4203-mailmap.sh @@ -461,11 +461,9 @@ test_expect_success 'Grep author with log.mailmap' ' test_cmp expect actual ' ->expect - test_expect_success 'Only grep replaced author with --use-mailmap' ' git log --use-mailmap --author "" >actual && - test_cmp expect actual + test_must_be_empty actual ' # git blame diff --git a/t/t4212-log-corrupt.sh b/t/t4212-log-corrupt.sh index 22aa8b7..03b952c 100755 --- a/t/t4212-log-corrupt.sh +++ b/t/t4212-log-corrupt.sh @@ -26,22 +26,20 @@ test_expect_success 'git log with broken author email' ' echo echo " foo" } >expect.out && - : >expect.err && git log broken_email >actual.out 2>actual.err && test_cmp expect.out actual.out && - test_cmp expect.err actual.err + test_must_be_empty actual.err ' test_expect_success 'git log --format with broken author email' ' echo "A U Thor+author@example.com+Thu Apr 7 15:13:13 2005 -0700" >expect.out && - : >expect.err && git log --format="%an+%ae+%ad" broken_email >actual.out 2>actual.err && test_cmp expect.out actual.out && - test_cmp expect.err actual.err + test_must_be_empty actual.err ' munge_author_date () { diff --git a/t/t4300-merge-tree.sh b/t/t4300-merge-tree.sh index 9015e47..d87cc7d 100755 --- a/t/t4300-merge-tree.sh +++ b/t/t4300-merge-tree.sh @@ -25,25 +25,19 @@ EXPECTED ' test_expect_success 'file add !A, B' ' - cat >expected <<\EXPECTED && -EXPECTED - git reset --hard initial && test_commit "add-not-a-b" "ONE" "AAA" && git merge-tree initial add-not-a-b initial >actual && - test_cmp expected actual + test_must_be_empty actual ' test_expect_success 'file add A, B (same)' ' - cat >expected <<\EXPECTED && -EXPECTED - git reset --hard initial && test_commit "add-a-b-same-A" "ONE" "AAA" && git reset --hard initial && test_commit "add-a-b-same-B" "ONE" "AAA" && git merge-tree initial add-a-b-same-A add-a-b-same-B >actual && - test_cmp expected actual + test_must_be_empty actual ' test_expect_success 'file add A, B (different)' ' @@ -68,13 +62,10 @@ EXPECTED ' test_expect_success 'file change A, !B' ' - cat >expected <<\EXPECTED && -EXPECTED - git reset --hard initial && test_commit "change-a-not-b" "initial-file" "BBB" && git merge-tree initial change-a-not-b initial >actual && - test_cmp expected actual + test_must_be_empty actual ' test_expect_success 'file change !A, B' ' @@ -94,15 +85,12 @@ EXPECTED ' test_expect_success 'file change A, B (same)' ' - cat >expected <<\EXPECTED && -EXPECTED - git reset --hard initial && test_commit "change-a-b-same-A" "initial-file" "AAA" && git reset --hard initial && test_commit "change-a-b-same-B" "initial-file" "AAA" && git merge-tree initial change-a-b-same-A change-a-b-same-B >actual && - test_cmp expected actual + test_must_be_empty actual ' test_expect_success 'file change A, B (different)' ' @@ -175,16 +163,13 @@ AAA" && ' test_expect_success 'file remove A, !B' ' - cat >expected <<\EXPECTED && -EXPECTED - git reset --hard initial && test_commit "rm-a-not-b-base" "ONE" "AAA" && git rm ONE && git commit -m "rm-a-not-b" && git tag "rm-a-not-b" && git merge-tree rm-a-not-b-base rm-a-not-b rm-a-not-b-base >actual && - test_cmp expected actual + test_must_be_empty actual ' test_expect_success 'file remove !A, B' ' @@ -206,16 +191,13 @@ EXPECTED ' test_expect_success 'file remove A, B (same)' ' - cat >expected <<\EXPECTED && -EXPECTED - git reset --hard initial && test_commit "rm-a-b-base" "ONE" "AAA" && git rm ONE && git commit -m "rm-a-b" && git tag "rm-a-b" && git merge-tree rm-a-b-base rm-a-b rm-a-b >actual && - test_cmp expected actual + test_must_be_empty actual ' test_expect_success 'file change A, remove B' ' @@ -260,13 +242,11 @@ EXPECTED ' test_expect_success 'tree add A, B (same)' ' - cat >expect <<-\EOF && - EOF git reset --hard initial && mkdir sub && test_commit "add sub/file" "sub/file" "file" add-tree-A && git merge-tree initial add-tree-A add-tree-A >actual && - test_cmp expect actual + test_must_be_empty actual ' test_expect_success 'tree add A, B (different)' ' diff --git a/t/t5304-prune.sh b/t/t5304-prune.sh index f20f03c..270da21 100755 --- a/t/t5304-prune.sh +++ b/t/t5304-prune.sh @@ -112,8 +112,7 @@ test_expect_success 'prune: do not prune detached HEAD with no reflog' ' # (should be removed and disabled by previous test) test_path_is_missing .git/logs && git prune -n >prune_actual && - : >prune_expected && - test_cmp prune_actual prune_expected + test_must_be_empty prune_actual ' diff --git a/t/t5314-pack-cycle-detection.sh b/t/t5314-pack-cycle-detection.sh index f31995d..e525466 100755 --- a/t/t5314-pack-cycle-detection.sh +++ b/t/t5314-pack-cycle-detection.sh @@ -98,9 +98,8 @@ test_expect_success 'repack' ' # We first want to check that we do not have any internal errors, # and also that we do not hit the last-ditch cycle-breaking code # in write_object(), which will issue a warning to stderr. - >expect && git repack -ad 2>stderr && - test_cmp expect stderr && + test_must_be_empty stderr && # And then double-check that the resulting pack is usable (i.e., # we did not fail to notice any cycles). We know we are accessing diff --git a/t/t5526-fetch-submodules.sh b/t/t5526-fetch-submodules.sh index ce3af92..fc95df0 100755 --- a/t/t5526-fetch-submodules.sh +++ b/t/t5526-fetch-submodules.sh @@ -495,7 +495,6 @@ test_expect_success "'fetch.recurseSubmodules=on-demand' works also without .git git add submodule && git rm .gitmodules && git commit -m "new submodule without .gitmodules" && - printf "" >expect.out && head2=$(git rev-parse --short HEAD) && echo "From $pwd/." >expect.err.2 && echo " $head1..$head2 master -> origin/master" >>expect.err.2 && @@ -514,7 +513,7 @@ test_expect_success "'fetch.recurseSubmodules=on-demand' works also without .git git config --unset fetch.recurseSubmodules && git reset --hard ) && - test_i18ncmp expect.out actual.out && + test_must_be_empty actual.out && test_i18ncmp expect.err.2 actual.err && git checkout HEAD^ -- .gitmodules && git add .gitmodules && diff --git a/t/t6112-rev-list-filters-objects.sh b/t/t6112-rev-list-filters-objects.sh index 0a37dd5..d4ff0b3 100755 --- a/t/t6112-rev-list-filters-objects.sh +++ b/t/t6112-rev-list-filters-objects.sh @@ -113,12 +113,11 @@ test_expect_success 'verify blob:limit=1k' ' ' test_expect_success 'verify blob:limit=1m' ' - cat expected && git -C r2 rev-list HEAD --quiet --objects --filter-print-omitted --filter=blob:limit=1m \ | awk -f print_1.awk \ | sed "s/~//" \ | sort >observed && - test_cmp observed expected + test_must_be_empty observed ' # Test sparse:path= filter. diff --git a/t/t6120-describe.sh b/t/t6120-describe.sh index 84dd1cb..d639d94 100755 --- a/t/t6120-describe.sh +++ b/t/t6120-describe.sh @@ -121,10 +121,9 @@ test_expect_success 'describe --contains defaults to HEAD without commit-ish' ' test_cmp expect actual ' -: >err.expect check_describe tags/A --all A^0 test_expect_success 'no warning was displayed for A' ' - test_cmp err.expect err.actual + test_must_be_empty err.actual ' test_expect_success 'rename tag A to Q locally' ' diff --git a/t/t6130-pathspec-noglob.sh b/t/t6130-pathspec-noglob.sh index 6583532..3776023 100755 --- a/t/t6130-pathspec-noglob.sh +++ b/t/t6130-pathspec-noglob.sh @@ -97,9 +97,8 @@ test_expect_success 'no-glob option matches literally (bracket)' ' ' test_expect_success 'no-glob option disables :(literal)' ' - : >expect && git --literal-pathspecs log --format=%s -- ":(literal)foo" >actual && - test_cmp expect actual + test_must_be_empty actual ' test_expect_success 'no-glob environment variable works' ' @@ -130,9 +129,8 @@ test_expect_success '**/ works with :(glob)' ' ' test_expect_success '**/ does not work with --noglob-pathspecs' ' - : >expect && git --noglob-pathspecs log --format=%s -- "**/bar" >actual && - test_cmp expect actual + test_must_be_empty actual ' test_expect_success '**/ works with :(glob) and --noglob-pathspecs' ' @@ -154,9 +152,8 @@ test_expect_success '**/ works with --glob-pathspecs' ' ' test_expect_success '**/ does not work with :(literal) and --glob-pathspecs' ' - : >expect && git --glob-pathspecs log --format=%s -- ":(literal)**/bar" >actual && - test_cmp expect actual + test_must_be_empty actual ' test_done diff --git a/t/t6200-fmt-merge-msg.sh b/t/t6200-fmt-merge-msg.sh index a54a52a..93f23cf 100755 --- a/t/t6200-fmt-merge-msg.sh +++ b/t/t6200-fmt-merge-msg.sh @@ -366,8 +366,6 @@ test_expect_success 'merge-msg with nothing to merge' ' test_unconfig merge.log && test_config merge.summary yes && - >empty && - ( cd remote && git checkout -b unrelated && @@ -376,7 +374,7 @@ test_expect_success 'merge-msg with nothing to merge' ' git fmt-merge-msg <.git/FETCH_HEAD >../actual ) && - test_cmp empty actual + test_must_be_empty actual ' test_expect_success 'merge-msg tag' ' diff --git a/t/t7004-tag.sh b/t/t7004-tag.sh index 93a6694..2e17cdb 100755 --- a/t/t7004-tag.sh +++ b/t/t7004-tag.sh @@ -325,11 +325,10 @@ test_expect_success \ test_cmp expect actual ' ->expect test_expect_success \ 'listing tags using v.* should print nothing because none have v.' ' git tag -l "v.*" > actual && - test_cmp expect actual + test_must_be_empty actual ' cat >expect < expected <actual && - test_cmp expected actual + test_must_be_empty actual " cat > expected <expect && test_must_fail git grep -I ina a >actual && - test_cmp expect actual + test_must_be_empty actual ' test_expect_success 'git grep -c ina a' ' @@ -81,9 +80,8 @@ test_expect_success 'git grep -L bar a' ' ' test_expect_success 'git grep -q ina a' ' - : >expect && git grep -q ina a >actual && - test_cmp expect actual + test_must_be_empty actual ' test_expect_success 'git grep -F ile a' ' diff --git a/t/t7064-wtstatus-pv2.sh b/t/t7064-wtstatus-pv2.sh index b9a86d3..11eccc2 100755 --- a/t/t7064-wtstatus-pv2.sh +++ b/t/t7064-wtstatus-pv2.sh @@ -364,11 +364,8 @@ test_expect_success 'verify upstream fields in branch header' ' test_cmp expect actual && ## Repeat the above but without --branch. - cat >expect <<-EOF && - EOF - git status --porcelain=v2 --untracked-files=all >actual && - test_cmp expect actual && + test_must_be_empty actual && ## Test upstream-gone case. Fake this by pointing origin/master at ## a non-existing commit. diff --git a/t/t7201-co.sh b/t/t7201-co.sh index 0e7d442..d67b10c 100755 --- a/t/t7201-co.sh +++ b/t/t7201-co.sh @@ -116,9 +116,8 @@ test_expect_success "checkout -m with dirty tree" ' git diff --name-status side >current.side && test_cmp expect.side current.side && - : >expect.index && git diff --cached >current.index && - test_cmp expect.index current.index + test_must_be_empty current.index ' test_expect_success "checkout -m with dirty tree, renamed" ' diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh index 48fd14f..894ea2f 100755 --- a/t/t7400-submodule-basic.sh +++ b/t/t7400-submodule-basic.sh @@ -101,7 +101,6 @@ inspect() { test_expect_success 'submodule add' ' echo "refs/heads/master" >expect && - >empty && ( cd addtest && @@ -123,7 +122,7 @@ test_expect_success 'submodule add' ' inspect addtest/submod ../.. && test_cmp expect heads && test_cmp expect head && - test_cmp empty untracked + test_must_be_empty untracked ' test_expect_success 'setup parent and one repository' ' @@ -188,7 +187,6 @@ test_expect_success 'submodule add --branch' ' refs/heads/initial refs/heads/master EOF - >empty && ( cd addtest && @@ -201,12 +199,11 @@ test_expect_success 'submodule add --branch' ' inspect addtest/submod-branch ../.. && test_cmp expect-heads heads && test_cmp expect-head head && - test_cmp empty untracked + test_must_be_empty untracked ' test_expect_success 'submodule add with ./ in path' ' echo "refs/heads/master" >expect && - >empty && ( cd addtest && @@ -218,12 +215,11 @@ test_expect_success 'submodule add with ./ in path' ' inspect addtest/dotsubmod/frotz ../../.. && test_cmp expect heads && test_cmp expect head && - test_cmp empty untracked + test_must_be_empty untracked ' test_expect_success 'submodule add with /././ in path' ' echo "refs/heads/master" >expect && - >empty && ( cd addtest && @@ -235,12 +231,11 @@ test_expect_success 'submodule add with /././ in path' ' inspect addtest/dotslashdotsubmod/frotz ../../.. && test_cmp expect heads && test_cmp expect head && - test_cmp empty untracked + test_must_be_empty untracked ' test_expect_success 'submodule add with // in path' ' echo "refs/heads/master" >expect && - >empty && ( cd addtest && @@ -252,12 +247,11 @@ test_expect_success 'submodule add with // in path' ' inspect addtest/slashslashsubmod/frotz ../../.. && test_cmp expect heads && test_cmp expect head && - test_cmp empty untracked + test_must_be_empty untracked ' test_expect_success 'submodule add with /.. in path' ' echo "refs/heads/master" >expect && - >empty && ( cd addtest && @@ -269,12 +263,11 @@ test_expect_success 'submodule add with /.. in path' ' inspect addtest/realsubmod ../.. && test_cmp expect heads && test_cmp expect head && - test_cmp empty untracked + test_must_be_empty untracked ' test_expect_success 'submodule add with ./, /.. and // in path' ' echo "refs/heads/master" >expect && - >empty && ( cd addtest && @@ -286,7 +279,7 @@ test_expect_success 'submodule add with ./, /.. and // in path' ' inspect addtest/realsubmod2 ../.. && test_cmp expect heads && test_cmp expect head && - test_cmp empty untracked + test_must_be_empty untracked ' test_expect_success !CYGWIN 'submodule add with \\ in path' ' @@ -305,7 +298,6 @@ test_expect_success !CYGWIN 'submodule add with \\ in path' ' test_expect_success 'submodule add in subdirectory' ' echo "refs/heads/master" >expect && - >empty && mkdir addtest/sub && ( @@ -318,7 +310,7 @@ test_expect_success 'submodule add in subdirectory' ' inspect addtest/realsubmod3 ../.. && test_cmp expect heads && test_cmp expect head && - test_cmp empty untracked + test_must_be_empty untracked ' test_expect_success 'submodule add in subdirectory with relative path should fail' ' @@ -501,8 +493,6 @@ test_expect_success 'checkout superproject with subproject already present' ' ' test_expect_success 'apply submodule diff' ' - >empty && - git branch second && ( cd init && @@ -517,7 +507,7 @@ test_expect_success 'apply submodule diff' ' git apply --index P.diff && git diff --cached master >staged && - test_cmp empty staged + test_must_be_empty staged ' test_expect_success 'update --init' ' diff --git a/t/t7501-commit.sh b/t/t7501-commit.sh index 9dbbd01..c1d232e 100755 --- a/t/t7501-commit.sh +++ b/t/t7501-commit.sh @@ -582,13 +582,11 @@ test_expect_success 'same tree (merge and amend merge)' ' git merge -s ours side -m "empty ok" && git diff HEAD^ HEAD >actual && - : >expected && - test_cmp expected actual && + test_must_be_empty actual && git commit --amend -m "empty really ok" && git diff HEAD^ HEAD >actual && - : >expected && - test_cmp expected actual + test_must_be_empty actual ' diff --git a/t/t7600-merge.sh b/t/t7600-merge.sh index 6736d8d..1061482 100755 --- a/t/t7600-merge.sh +++ b/t/t7600-merge.sh @@ -38,7 +38,6 @@ printf '%s\n' '1 X' 2 3 4 5 6 7 8 9 >result.1 printf '%s\n' '1 X' 2 3 4 '5 X' 6 7 8 9 >result.1-5 printf '%s\n' '1 X' 2 3 4 '5 X' 6 7 8 '9 X' >result.1-5-9 printf '%s\n' 1 2 3 4 5 6 7 8 '9 Z' >result.9z ->empty create_merge_msgs () { echo "Merge tag 'c2'" >msg.1-5 && @@ -58,8 +57,6 @@ create_merge_msgs () { echo && git log --no-merges ^HEAD c2 c3 } >squash.1-5-9 && - : >msg.nologff && - : >msg.nolognoff && { echo "* tag 'c3':" && echo " commit 3" @@ -519,7 +516,7 @@ test_expect_success 'tolerate unknown values for merge.ff' ' test_tick && git merge c1 2>message && verify_head "$c1" && - test_cmp empty message + test_must_be_empty message ' test_expect_success 'combining --squash and --no-ff is refused' ' @@ -551,13 +548,13 @@ test_expect_success 'merge log message' ' git reset --hard c0 && git merge --no-log c2 && git show -s --pretty=format:%b HEAD >msg.act && - test_cmp msg.nologff msg.act && + test_must_be_empty msg.act && git reset --hard c0 && test_config branch.master.mergeoptions "--no-ff" && git merge --no-log c2 && git show -s --pretty=format:%b HEAD >msg.act && - test_cmp msg.nolognoff msg.act && + test_must_be_empty msg.act && git merge --log c3 && git show -s --pretty=format:%b HEAD >msg.act && diff --git a/t/t7610-mergetool.sh b/t/t7610-mergetool.sh index 4d46c59..78bed2a 100755 --- a/t/t7610-mergetool.sh +++ b/t/t7610-mergetool.sh @@ -328,9 +328,8 @@ test_expect_success 'mergetool produces no errors when keepBackup is used' ' git checkout -b test$test_count move-to-c && test_config mergetool.keepBackup true && test_must_fail git merge move-to-b && - : >expect && echo d | git mergetool a/a/file.txt 2>actual && - test_cmp expect actual && + test_must_be_empty actual && ! test -d a ' diff --git a/t/t7810-grep.sh b/t/t7810-grep.sh index 42d5354..c82c8f5 100755 --- a/t/t7810-grep.sh +++ b/t/t7810-grep.sh @@ -217,9 +217,8 @@ do ' test_expect_success "grep -w $L (w)" ' - : >expected && test_must_fail git grep -n -w -e "^w" $H >actual && - test_cmp expected actual + test_must_be_empty actual ' test_expect_success "grep -w $L (x)" ' @@ -239,26 +238,24 @@ do ' test_expect_success "grep -w $L (y-2)" ' - : >expected && if git grep -n -w -e "^y y" $H >actual then echo should not have matched cat actual false else - test_cmp expected actual + test_must_be_empty actual fi ' test_expect_success "grep -w $L (z)" ' - : >expected && if git grep -n -w -e "^z" $H >actual then echo should not have matched cat actual false else - test_cmp expected actual + test_must_be_empty actual fi ' @@ -604,11 +601,10 @@ z:zzz EOF test_expect_success 'grep -q, silently report matches' ' - >empty && git grep -q mmap >actual && - test_cmp empty actual && + test_must_be_empty actual && test_must_fail git grep -q qfwfq >actual && - test_cmp empty actual + test_must_be_empty actual ' test_expect_success 'grep -C1 hunk mark between files' ' @@ -701,8 +697,7 @@ test_expect_success 'log grep (9)' ' test_expect_success 'log grep (9)' ' git log -g --grep-reflog="commit: third" --author="non-existent" --pretty=tformat:%s >actual && - : >expect && - test_cmp expect actual + test_must_be_empty actual ' test_expect_success 'log --grep-reflog can only be used under -g' ' @@ -792,15 +787,13 @@ test_expect_success 'log --all-match --grep --grep --author takes intersection' ' test_expect_success 'log --author does not search in timestamp' ' - : >expect && git log --author="$GIT_AUTHOR_DATE" >actual && - test_cmp expect actual + test_must_be_empty actual ' test_expect_success 'log --committer does not search in timestamp' ' - : >expect && git log --committer="$GIT_COMMITTER_DATE" >actual && - test_cmp expect actual + test_must_be_empty actual ' test_expect_success 'grep with CE_VALID file' ' @@ -1051,13 +1044,12 @@ test_expect_success 'inside git repository but with --no-index' ' echo ".gitignore:.*o*" && cat is/expect.unignored } >is/expect.full && - : >is/expect.empty && echo file2:world >is/expect.sub && ( cd is/git && git init && test_must_fail git grep o >../actual.full && - test_cmp ../expect.empty ../actual.full && + test_must_be_empty ../actual.full && git grep --untracked o >../actual.unignored && test_cmp ../expect.unignored ../actual.unignored && @@ -1070,7 +1062,7 @@ test_expect_success 'inside git repository but with --no-index' ' cd sub && test_must_fail git grep o >../../actual.sub && - test_cmp ../../expect.empty ../../actual.sub && + test_must_be_empty ../../actual.sub && git grep --no-index o >../../actual.sub && test_cmp ../../expect.sub ../../actual.sub && @@ -1236,10 +1228,9 @@ test_expect_success !PCRE 'grep -P pattern errors without PCRE' ' ' test_expect_success 'grep pattern with grep.extendedRegexp=true' ' - >empty && test_must_fail git -c grep.extendedregexp=true \ grep "\p{Ps}.*?\p{Pe}" hello.c >actual && - test_cmp empty actual + test_must_be_empty actual ' test_expect_success PCRE 'grep -P pattern with grep.extendedRegexp=true' ' diff --git a/t/t7811-grep-open.sh b/t/t7811-grep-open.sh index e1951a5..d1ebfd8 100755 --- a/t/t7811-grep-open.sh +++ b/t/t7811-grep-open.sh @@ -51,14 +51,13 @@ test_expect_success SIMPLEPAGER 'git grep -O' ' grep.h EOF echo grep.h >expect.notless && - >empty && PATH=.:$PATH git grep -O GREP_PATTERN >out && { test_cmp expect.less pager-args || test_cmp expect.notless pager-args } && - test_cmp empty out + test_must_be_empty out ' test_expect_success 'git grep -O --cached' ' @@ -72,7 +71,6 @@ test_expect_success 'git grep -O --no-index' ' grep.h untracked EOF - >empty && ( GIT_PAGER='\''printf "%s\n" >pager-args'\'' && @@ -80,7 +78,7 @@ test_expect_success 'git grep -O --no-index' ' git grep --no-index -O GREP_PATTERN >out ) && test_cmp expect pager-args && - test_cmp empty out + test_must_be_empty out ' test_expect_success 'setup: fake "less"' ' @@ -96,15 +94,14 @@ test_expect_success 'git grep -O jumps to line in less' ' +/*GREP_PATTERN grep.h EOF - >empty && GIT_PAGER=./less git grep -O GREP_PATTERN >out && test_cmp expect actual && - test_cmp empty out && + test_must_be_empty out && git grep -O./less GREP_PATTERN >out2 && test_cmp expect actual && - test_cmp empty out2 + test_must_be_empty out2 ' test_expect_success 'modified file' ' @@ -122,7 +119,7 @@ test_expect_success 'modified file' ' test_when_finished "git checkout HEAD unrelated" && GIT_PAGER=./less git grep -F -O "enum grep_pat_token" >out && test_cmp expect actual && - test_cmp empty out + test_must_be_empty out ' test_expect_success 'copes with color settings' ' @@ -138,7 +135,6 @@ test_expect_success 'copes with color settings' ' test_expect_success 'run from subdir' ' rm -f actual && echo grep.c >expect && - >empty && ( cd subdir && @@ -156,8 +152,8 @@ test_expect_success 'run from subdir' ' ;; esac && test_cmp expect args && - test_cmp empty out && - test_cmp empty out2 + test_must_be_empty out && + test_must_be_empty out2 ' test_done diff --git a/t/t9011-svn-da.sh b/t/t9011-svn-da.sh index b38d16f..ab1ef28 100755 --- a/t/t9011-svn-da.sh +++ b/t/t9011-svn-da.sh @@ -18,7 +18,7 @@ test_expect_success 'reject empty delta' ' test_expect_success 'delta can empty file' ' printf "SVNQ" | q_to_nul >clear.delta && test-svn-fe -d preimage clear.delta 4 >actual && - test_cmp empty actual + test_must_be_empty actual ' test_expect_success 'reject svndiff2' ' @@ -29,7 +29,7 @@ test_expect_success 'reject svndiff2' ' test_expect_success 'one-window empty delta' ' printf "SVNQ%s" "QQQQQ" | q_to_nul >clear.onewindow && test-svn-fe -d preimage clear.onewindow 9 >actual && - test_cmp empty actual + test_must_be_empty actual ' test_expect_success 'reject incomplete window header' ' @@ -50,7 +50,7 @@ test_expect_success 'two-window empty delta' ' printf "SVNQ%s%s" "QQQQQ" "QQQQQ" | q_to_nul >clear.twowindow && test-svn-fe -d preimage clear.twowindow 14 >actual && test_must_fail test-svn-fe -d preimage clear.twowindow 13 && - test_cmp empty actual + test_must_be_empty actual ' test_expect_success 'noisy zeroes' ' @@ -60,7 +60,7 @@ test_expect_success 'noisy zeroes' ' q_to_nul >clear.noisy && len=$(wc -c clear.readpreimage && test-svn-fe -d preimage clear.readpreimage 9 >actual && - test_cmp empty actual + test_must_be_empty actual ' test_expect_success 'preimage view: right endpoint cannot backtrack' ' @@ -99,7 +99,7 @@ test_expect_success 'preimage view: left endpoint can advance' ' q_to_nul >clear.shrinkbacktrack && test-svn-fe -d preimage clear.preshrink 14 >actual && test_must_fail test-svn-fe -d preimage clear.shrinkbacktrack 14 && - test_cmp empty actual + test_must_be_empty actual ' test_expect_success 'preimage view: offsets compared by value' ' @@ -109,7 +109,7 @@ test_expect_success 'preimage view: offsets compared by value' ' q_to_nul >clear.noisyadvance && test_must_fail test-svn-fe -d preimage clear.noisybacktrack 15 && test-svn-fe -d preimage clear.noisyadvance 15 && - test_cmp empty actual + test_must_be_empty actual ' test_expect_success 'preimage view: reject truncated preimage' ' diff --git a/t/t9200-git-cvsexportcommit.sh b/t/t9200-git-cvsexportcommit.sh index 1319415..99d7aa6 100755 --- a/t/t9200-git-cvsexportcommit.sh +++ b/t/t9200-git-cvsexportcommit.sh @@ -43,11 +43,11 @@ check_entries () { sed -ne '/^\//p' "$1/CVS/Entries" | sort | cut -d/ -f2,3,5 >actual if test -z "$2" then - >expected + test_must_be_empty actual else printf '%s\n' "$2" | tr '|' '\012' >expected + test_cmp expected actual fi - test_cmp expected actual } test_expect_success \ diff --git a/t/t9903-bash-prompt.sh b/t/t9903-bash-prompt.sh index c3b89ae..056bf1d 100755 --- a/t/t9903-bash-prompt.sh +++ b/t/t9903-bash-prompt.sh @@ -516,10 +516,9 @@ test_expect_success 'prompt - format string starting with dash' ' test_expect_success 'prompt - pc mode' ' printf "BEFORE: (\${__git_ps1_branch_name}):AFTER\\nmaster" >expected && - printf "" >expected_output && ( __git_ps1 "BEFORE:" ":AFTER" >"$actual" && - test_cmp expected_output "$actual" && + test_must_be_empty "$actual" && printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual" ) && test_cmp expected "$actual" @@ -715,13 +714,12 @@ test_expect_success 'prompt - hide if pwd ignored - env var set, config disabled ' test_expect_success 'prompt - hide if pwd ignored - env var set, config unset' ' - printf "" >expected && ( cd ignored_dir && GIT_PS1_HIDE_IF_PWD_IGNORED=y && __git_ps1 >"$actual" ) && - test_cmp expected "$actual" + test_must_be_empty "$actual" ' test_expect_success 'prompt - hide if pwd ignored - env var set, config unset, pc mode' ' -- cgit v0.10.2-6-g49f6