Skip to content
Snippets Groups Projects
Commit 986c5181 authored by Junio C Hamano's avatar Junio C Hamano
Browse files

Merge branch 'sg/test-must-be-empty'

Test fixes.

* sg/test-must-be-empty:
  tests: use 'test_must_be_empty' instead of 'test_cmp <empty> <out>'
  tests: use 'test_must_be_empty' instead of 'test_cmp /dev/null <out>'
  tests: use 'test_must_be_empty' instead of 'test ! -s'
  tests: use 'test_must_be_empty' instead of '! test -s'
parents fc0df933 1c5e94f4
No related branches found
No related tags found
No related merge requests found
Showing
with 54 additions and 75 deletions
Loading
Loading
@@ -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
)
Loading
Loading
Loading
Loading
@@ -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' '
Loading
Loading
Loading
Loading
@@ -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 <stdin-all | sort >actual &&
test_cmp empty actual &&
test_must_be_empty actual &&
git add .gitattributes a/.gitattributes a/b/.gitattributes &&
git check-attr --cached --stdin --all <stdin-all | sort >actual &&
test_cmp specified-all actual
Loading
Loading
Loading
Loading
@@ -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 \
Loading
Loading
@@ -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 \
Loading
Loading
Loading
Loading
@@ -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
'
 
Loading
Loading
Loading
Loading
@@ -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
Loading
Loading
@@ -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' '
Loading
Loading
@@ -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' '
Loading
Loading
@@ -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' '
Loading
Loading
@@ -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' '
Loading
Loading
Loading
Loading
@@ -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' '
Loading
Loading
Loading
Loading
@@ -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
'
 
Loading
Loading
@@ -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
'
 
Loading
Loading
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -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' '
Loading
Loading
@@ -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
Loading
Loading
@@ -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' '
Loading
Loading
Loading
Loading
@@ -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
}
Loading
Loading
Loading
Loading
@@ -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' '
Loading
Loading
@@ -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' '
Loading
Loading
@@ -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' '
Loading
Loading
@@ -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' '
Loading
Loading
@@ -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)' '
Loading
Loading
@@ -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.
Loading
Loading
@@ -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' '
Loading
Loading
@@ -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' '
Loading
Loading
@@ -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
Loading
Loading
@@ -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)' '
Loading
Loading
@@ -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
 
Loading
Loading
Loading
Loading
@@ -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
)
'
 
Loading
Loading
Loading
Loading
@@ -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 &&
Loading
Loading
Loading
Loading
@@ -44,7 +44,7 @@ test_expect_success '"checkout <submodule>" 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 <submodule>" honors submodule.*.ignore from .gitmodules' '
Loading
Loading
@@ -52,7 +52,7 @@ test_expect_success '"checkout <submodule>" 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 <submodule>" honors submodule.*.ignore from .git/config' '
Loading
Loading
@@ -60,7 +60,7 @@ test_expect_success '"checkout <submodule>" 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
Loading
Loading
Loading
Loading
@@ -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' '
Loading
Loading
Loading
Loading
@@ -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
 
)
'
Loading
Loading
@@ -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
'
 
 
Loading
Loading
Loading
Loading
@@ -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" '
Loading
Loading
@@ -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
Loading
Loading
@@ -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
)
'
 
Loading
Loading
@@ -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
)
'
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment