Skip to content

Commit

Permalink
Merge branch 'ab/test-must-be-empty-for-master'
Browse files Browse the repository at this point in the history
Test updates.

* ab/test-must-be-empty-for-master:
  tests: make use of the test_must_be_empty function
  • Loading branch information
gitster committed Aug 20, 2018
2 parents 34f2297 + d3c6751 commit 14677d2
Show file tree
Hide file tree
Showing 45 changed files with 111 additions and 205 deletions.
9 changes: 3 additions & 6 deletions t/t0008-ignores.sh
Original file line number Diff line number Diff line change
Expand Up @@ -807,10 +807,9 @@ test_expect_success 'trailing whitespace is ignored' '
cat >expect <<EOF &&
whitespace/untracked
EOF
: >err.expect &&
git ls-files -o -X ignore whitespace >actual 2>err &&
test_cmp expect actual &&
test_cmp err.expect err
test_must_be_empty err
'

test_expect_success !MINGW 'quoting allows trailing whitespace' '
Expand All @@ -820,10 +819,9 @@ test_expect_success !MINGW 'quoting allows trailing whitespace' '
>whitespace/untracked &&
echo "whitespace/trailing\\ \\ " >ignore &&
echo whitespace/untracked >expect &&
: >err.expect &&
git ls-files -o -X ignore whitespace >actual 2>err &&
test_cmp expect actual &&
test_cmp err.expect err
test_must_be_empty err
'

test_expect_success !MINGW,!CYGWIN 'correct handling of backslashes' '
Expand All @@ -845,10 +843,9 @@ test_expect_success !MINGW,!CYGWIN 'correct handling of backslashes' '
whitespace/trailing 6 \\a\\Z
EOF
echo whitespace/untracked >expect &&
>err.expect &&
git ls-files -o -X ignore whitespace >actual 2>err &&
test_cmp expect actual &&
test_cmp err.expect err
test_must_be_empty err
'

test_expect_success 'info/exclude trumps core.excludesfile' '
Expand Down
17 changes: 8 additions & 9 deletions t/t0030-stripspace.sh
Original file line number Diff line number Diff line change
Expand Up @@ -110,31 +110,30 @@ test_expect_success \

test_expect_success \
'only consecutive blank lines should be completely removed' '
> expect &&
printf "\n" | git stripspace >actual &&
test_cmp expect actual &&
test_must_be_empty actual &&
printf "\n\n\n" | git stripspace >actual &&
test_cmp expect actual &&
test_must_be_empty actual &&
printf "$sss\n$sss\n$sss\n" | git stripspace >actual &&
test_cmp expect actual &&
test_must_be_empty actual &&
printf "$sss$sss\n$sss\n\n" | git stripspace >actual &&
test_cmp expect actual &&
test_must_be_empty actual &&
printf "\n$sss\n$sss$sss\n" | git stripspace >actual &&
test_cmp expect actual &&
test_must_be_empty actual &&
printf "$sss$sss$sss$sss\n\n\n" | git stripspace >actual &&
test_cmp expect actual &&
test_must_be_empty actual &&
printf "\n$sss$sss$sss$sss\n\n" | git stripspace >actual &&
test_cmp expect actual &&
test_must_be_empty actual &&
printf "\n\n$sss$sss$sss$sss\n" | git stripspace >actual &&
test_cmp expect actual
test_must_be_empty actual
'

test_expect_success \
Expand Down
3 changes: 1 addition & 2 deletions t/t0300-credentials.sh
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,7 @@ test_expect_success 'helpers can abort the process' '
-c credential.helper="!f() { echo quit=1; }; f" \
-c credential.helper="verbatim foo bar" \
credential fill >stdout &&
>expect &&
test_cmp expect stdout
test_must_be_empty stdout
'

test_expect_success 'empty helper spec resets helper list' '
Expand Down
3 changes: 1 addition & 2 deletions t/t1011-read-tree-sparse-checkout.sh
Original file line number Diff line number Diff line change
Expand Up @@ -227,12 +227,11 @@ test_expect_success 'index removal and worktree narrowing at the same time' '
'

test_expect_success 'read-tree --reset removes outside worktree' '
>empty &&
echo init.t >.git/info/sparse-checkout &&
git checkout -f top &&
git reset --hard removed &&
git ls-files sub/added >result &&
test_cmp empty result
test_must_be_empty result
'

test_expect_success 'print errors when failed to update worktree' '
Expand Down
6 changes: 2 additions & 4 deletions t/t1306-xdg-files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,10 @@ test_expect_success 'Exclusion in a non-XDG global ignore file' '
'

test_expect_success 'Checking XDG ignore file when HOME is unset' '
>expected &&
(sane_unset HOME &&
git config --unset core.excludesfile &&
git ls-files --exclude-standard --ignored >actual) &&
test_cmp expected actual
test_must_be_empty actual
'

test_expect_success 'Checking attributes in the XDG attributes file' '
Expand All @@ -132,10 +131,9 @@ test_expect_success 'Checking attributes in the XDG attributes file' '
'

test_expect_success 'Checking XDG attributes when HOME is unset' '
>expected &&
(sane_unset HOME &&
git check-attr -a f >actual) &&
test_cmp expected actual
test_must_be_empty actual
'

test_expect_success '$XDG_CONFIG_HOME overrides $HOME/.config/git/attributes' '
Expand Down
46 changes: 17 additions & 29 deletions t/t1403-show-ref.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,22 @@ test_expect_success 'show-ref' '
git show-ref refs/tags/A >actual &&
test_cmp expect actual &&
>expect &&
test_must_fail git show-ref D >actual &&
test_cmp expect actual
test_must_be_empty actual
'

test_expect_success 'show-ref -q' '
>expect &&
git show-ref -q A >actual &&
test_cmp expect actual &&
test_must_be_empty actual &&
git show-ref -q tags/A >actual &&
test_cmp expect actual &&
test_must_be_empty actual &&
git show-ref -q refs/tags/A >actual &&
test_cmp expect actual &&
test_must_be_empty actual &&
test_must_fail git show-ref -q D >actual &&
test_cmp expect actual
test_must_be_empty actual
'

test_expect_success 'show-ref --verify' '
Expand All @@ -54,32 +50,28 @@ test_expect_success 'show-ref --verify' '
git show-ref --verify refs/tags/A >actual &&
test_cmp expect actual &&
>expect &&
test_must_fail git show-ref --verify A >actual &&
test_cmp expect actual &&
test_must_be_empty actual &&
test_must_fail git show-ref --verify tags/A >actual &&
test_cmp expect actual &&
test_must_be_empty actual &&
test_must_fail git show-ref --verify D >actual &&
test_cmp expect actual
test_must_be_empty actual
'

test_expect_success 'show-ref --verify -q' '
>expect &&
git show-ref --verify -q refs/tags/A >actual &&
test_cmp expect actual &&
test_must_be_empty actual &&
test_must_fail git show-ref --verify -q A >actual &&
test_cmp expect actual &&
test_must_be_empty actual &&
test_must_fail git show-ref --verify -q tags/A >actual &&
test_cmp expect actual &&
test_must_be_empty actual &&
test_must_fail git show-ref --verify -q D >actual &&
test_cmp expect actual
test_must_be_empty actual
'

test_expect_success 'show-ref -d' '
Expand Down Expand Up @@ -113,19 +105,17 @@ test_expect_success 'show-ref -d' '
git show-ref -d --verify refs/heads/master >actual &&
test_cmp expect actual &&
>expect &&
test_must_fail git show-ref -d --verify master >actual &&
test_cmp expect actual &&
test_must_be_empty actual &&
test_must_fail git show-ref -d --verify heads/master >actual &&
test_cmp expect actual &&
test_must_be_empty actual &&
test_must_fail git show-ref --verify -d A C >actual &&
test_cmp expect actual &&
test_must_be_empty actual &&
test_must_fail git show-ref --verify -d tags/A tags/C >actual &&
test_cmp expect actual
test_must_be_empty actual
'

Expand Down Expand Up @@ -178,10 +168,8 @@ test_expect_success 'show-ref --verify HEAD' '
git show-ref --verify HEAD >actual &&
test_cmp expect actual &&
>expect &&
git show-ref --verify -q HEAD >actual &&
test_cmp expect actual
test_must_be_empty actual
'

test_expect_success 'show-ref --verify with dangling ref' '
Expand Down
3 changes: 1 addition & 2 deletions t/t1507-rev-parse-upstream.sh
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,7 @@ test_expect_success 'branch -d other@{u}' '
git checkout -t -b other master &&
git branch -d @{u} &&
git for-each-ref refs/heads/master >actual &&
>expect &&
test_cmp expect actual
test_must_be_empty actual
'

test_expect_success 'checkout other@{u}' '
Expand Down
3 changes: 1 addition & 2 deletions t/t2202-add-addremove.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ test_expect_success 'Just "git add" is a no-op' '
>will-not-be-added &&
git add &&
git diff-index --name-status --cached HEAD >actual &&
>expect &&
test_cmp expect actual
test_must_be_empty actual
'

test_done
15 changes: 5 additions & 10 deletions t/t3001-ls-files-others-exclude.sh
Original file line number Diff line number Diff line change
Expand Up @@ -210,26 +210,23 @@ test_expect_success 'subdirectory ignore (toplevel)' '
cd top &&
git ls-files -o --exclude-standard
) >actual &&
>expect &&
test_cmp expect actual
test_must_be_empty actual
'

test_expect_success 'subdirectory ignore (l1/l2)' '
(
cd top/l1/l2 &&
git ls-files -o --exclude-standard
) >actual &&
>expect &&
test_cmp expect actual
test_must_be_empty actual
'

test_expect_success 'subdirectory ignore (l1)' '
(
cd top/l1 &&
git ls-files -o --exclude-standard
) >actual &&
>expect &&
test_cmp expect actual
test_must_be_empty actual
'

test_expect_success 'show/hide empty ignored directory (setup)' '
Expand All @@ -251,8 +248,7 @@ test_expect_success 'hide empty ignored directory with --no-empty-directory' '
cd top &&
git ls-files -o -i --exclude l1 --directory --no-empty-directory
) >actual &&
>expect &&
test_cmp expect actual
test_must_be_empty actual
'

test_expect_success 'show/hide empty ignored sub-directory (setup)' '
Expand All @@ -277,8 +273,7 @@ test_expect_success 'hide empty ignored sub-directory with --no-empty-directory'
cd top &&
git ls-files -o -i --exclude l1 --directory --no-empty-directory
) >actual &&
>expect &&
test_cmp expect actual
test_must_be_empty actual
'

test_expect_success 'pattern matches prefix completely' '
Expand Down
3 changes: 1 addition & 2 deletions t/t3070-wildmatch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ match_with_ls_files() {

match_stdout_stderr_cmp="
tr -d '\0' <actual.raw >actual &&
>expect.err &&
test_cmp expect.err actual.err &&
test_must_be_empty actual.err &&
test_cmp expect actual"

if test "$match_expect" = 'E'
Expand Down
15 changes: 5 additions & 10 deletions t/t3201-branch-contains.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,14 @@ test_expect_success 'branch --contains master' '
test_expect_success 'branch --no-contains=master' '
git branch --no-contains=master >actual &&
>expect &&
test_cmp expect actual
test_must_be_empty actual
'

test_expect_success 'branch --no-contains master' '
git branch --no-contains master >actual &&
>expect &&
test_cmp expect actual
test_must_be_empty actual
'

Expand Down Expand Up @@ -94,8 +92,7 @@ test_expect_success 'branch --contains with pattern implies --list' '
test_expect_success 'branch --no-contains with pattern implies --list' '
git branch --no-contains=master master >actual &&
>expect &&
test_cmp expect actual
test_must_be_empty actual
'

Expand Down Expand Up @@ -123,8 +120,7 @@ test_expect_success 'branch --merged with pattern implies --list' '
test_expect_success 'side: branch --no-merged' '
git branch --no-merged >actual &&
>expect &&
test_cmp expect actual
test_must_be_empty actual
'

Expand Down Expand Up @@ -152,8 +148,7 @@ test_expect_success 'master: branch --no-merged' '
test_expect_success 'branch --no-merged with pattern implies --list' '
git branch --no-merged=master master >actual &&
>expect &&
test_cmp expect actual
test_must_be_empty actual
'

Expand Down
3 changes: 1 addition & 2 deletions t/t3700-add.sh
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,8 @@ test_expect_success 'git add --refresh with pathspec' '
git add foo bar baz && H=$(git rev-parse :foo) && git rm -f foo &&
echo "100644 $H 3 foo" | git update-index --index-info &&
test-tool chmtime -60 bar baz &&
>expect &&
git add --refresh bar >actual &&
test_cmp expect actual &&
test_must_be_empty actual &&
git diff-files --name-only >actual &&
! grep bar actual&&
Expand Down
3 changes: 1 addition & 2 deletions t/t3910-mac-os-precompose.sh
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,8 @@ test_expect_failure 'handle existing decomposed filenames' '
echo content >"verbatim.$Adiarnfd" &&
git -c core.precomposeunicode=false add "verbatim.$Adiarnfd" &&
git commit -m "existing decomposed file" &&
>expect &&
git ls-files --exclude-standard -o "verbatim*" >untracked &&
test_cmp expect untracked
test_must_be_empty untracked
'

# Test if the global core.precomposeunicode stops autosensing
Expand Down
3 changes: 1 addition & 2 deletions t/t4010-diff-pathspec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ test_expect_success 'diff-tree pathspec' '
tree2=$(git write-tree) &&
echo "$tree2" &&
git diff-tree -r --name-only $tree $tree2 -- pa path1/a >current &&
>expected &&
test_cmp expected current
test_must_be_empty current
'

test_expect_success 'diff-tree with wildcard shows dir also matches' '
Expand Down
Loading

0 comments on commit 14677d2

Please sign in to comment.