Skip to content

Commit

Permalink
tests: add missing &&
Browse files Browse the repository at this point in the history
Breaks in a test assertion's && chain can potentially hide
failures from earlier commands in the chain.

Commands intended to fail should be marked with !, test_must_fail, or
test_might_fail.  The examples in this patch do not require that.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Jonathan Nieder authored and Junio C Hamano committed Nov 9, 2010
1 parent 00648ba commit a48fcd8
Show file tree
Hide file tree
Showing 84 changed files with 166 additions and 166 deletions.
2 changes: 1 addition & 1 deletion t/annotate-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ test_expect_success \
'prepare reference tree' \
'echo "1A quick brown fox jumps over the" >file &&
echo "lazy dog" >>file &&
git add file
git add file &&
GIT_AUTHOR_NAME="A" git commit -a -m "Initial."'

test_expect_success \
Expand Down
2 changes: 1 addition & 1 deletion t/t0003-attributes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ test_expect_success 'attribute test' '

test_expect_success 'attribute test: read paths from stdin' '
cat <<EOF > expect
cat <<EOF > expect &&
f: test: f
a/f: test: f
a/c/f: test: f
Expand Down
4 changes: 2 additions & 2 deletions t/t0024-crlf-archive.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ UNZIP=${UNZIP:-unzip}

test_expect_success setup '
git config core.autocrlf true
git config core.autocrlf true &&
printf "CRLF line ending\r\nAnd another\r\n" > sample &&
git add sample &&
Expand All @@ -20,7 +20,7 @@ test_expect_success setup '
test_expect_success 'tar archive' '
git archive --format=tar HEAD |
( mkdir untarred && cd untarred && "$TAR" -xf - )
( mkdir untarred && cd untarred && "$TAR" -xf - ) &&
test_cmp sample untarred/sample
Expand Down
2 changes: 1 addition & 1 deletion t/t0026-eol-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ test_expect_success setup '
git config core.autocrlf false &&
echo "one text" > .gitattributes
echo "one text" > .gitattributes &&
for w in Hello world how are you; do echo $w; done >one &&
for w in I am very very fine thank you; do echo $w; done >two &&
Expand Down
12 changes: 6 additions & 6 deletions t/t0050-filesystem.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,22 @@ unibad=
no_symlinks=
test_expect_success 'see what we expect' '
test_case=test_expect_success
test_unicode=test_expect_success
test_case=test_expect_success &&
test_unicode=test_expect_success &&
mkdir junk &&
echo good >junk/CamelCase &&
echo bad >junk/camelcase &&
if test "$(cat junk/CamelCase)" != good
then
test_case=test_expect_failure
test_case=test_expect_failure &&
case_insensitive=t
fi &&
rm -fr junk &&
mkdir junk &&
>junk/"$auml" &&
case "$(cd junk && echo *)" in
"$aumlcdiar")
test_unicode=test_expect_failure
test_unicode=test_expect_failure &&
unibad=t
;;
*) ;;
Expand All @@ -36,7 +36,7 @@ test_expect_success 'see what we expect' '
{
ln -s x y 2> /dev/null &&
test -h y 2> /dev/null ||
no_symlinks=1
no_symlinks=1 &&
rm -f y
}
'
Expand Down Expand Up @@ -128,7 +128,7 @@ test_expect_success "setup unicode normalization tests" '
cd unicode &&
touch "$aumlcdiar" &&
git add "$aumlcdiar" &&
git commit -m initial
git commit -m initial &&
git tag initial &&
git checkout -b topic &&
git mv $aumlcdiar tmp &&
Expand Down
2 changes: 1 addition & 1 deletion t/t1000-read-tree-m-3way.sh
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ test_expect_success \
test_expect_success \
'6 - must not exist in O && !A && !B case' "
rm -f .git/index DD &&
echo DD >DD
echo DD >DD &&
git update-index --add DD &&
test_must_fail git read-tree -m $tree_O $tree_A $tree_B
"
Expand Down
2 changes: 1 addition & 1 deletion t/t1001-read-tree-m-2way.sh
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ test_expect_success '-m references the correct modified tree' '
echo >file-a &&
echo >file-b &&
git add file-a file-b &&
git commit -a -m "test for correct modified tree"
git commit -a -m "test for correct modified tree" &&
git branch initial-mod &&
echo b >file-b &&
git commit -a -m "B" &&
Expand Down
2 changes: 1 addition & 1 deletion t/t1011-read-tree-sparse-checkout.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ test_expect_success 'read-tree without .git/info/sparse-checkout' '
'

test_expect_success 'read-tree with .git/info/sparse-checkout but disabled' '
echo >.git/info/sparse-checkout
echo >.git/info/sparse-checkout &&
git read-tree -m -u HEAD &&
git ls-files -t >result &&
test_cmp expected.swt result &&
Expand Down
2 changes: 1 addition & 1 deletion t/t1200-tutorial.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ test_expect_success 'git diff' '
'

test_expect_success 'tree' '
tree=$(git write-tree 2>/dev/null)
tree=$(git write-tree 2>/dev/null) &&
test 8988da15d077d4829fc51d8544c097def6644dbb = $tree
'

Expand Down
2 changes: 1 addition & 1 deletion t/t1302-repo-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ test_expect_success 'gitdir selection on unsupported repo' '
(
cd test2 &&
git config core.repositoryformatversion >../actual
)
) &&
test_cmp expect actual
'

Expand Down
2 changes: 1 addition & 1 deletion t/t1401-symbolic-ref.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ test_expect_success 'symbolic-ref refuses non-ref for HEAD' '
reset_to_sane

test_expect_success 'symbolic-ref refuses bare sha1' '
echo content >file && git add file && git commit -m one
echo content >file && git add file && git commit -m one &&
test_must_fail git symbolic-ref HEAD `git rev-parse HEAD`
'
reset_to_sane
Expand Down
4 changes: 2 additions & 2 deletions t/t1402-check-ref-format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ test_expect_success "check-ref-format --branch @{-1}" '
T=$(git write-tree) &&
sha1=$(echo A | git commit-tree $T) &&
git update-ref refs/heads/master $sha1 &&
git update-ref refs/remotes/origin/master $sha1
git update-ref refs/remotes/origin/master $sha1 &&
git checkout master &&
git checkout origin/master &&
git checkout master &&
Expand All @@ -47,7 +47,7 @@ test_expect_success 'check-ref-format --branch from subdir' '
T=$(git write-tree) &&
sha1=$(echo A | git commit-tree $T) &&
git update-ref refs/heads/master $sha1 &&
git update-ref refs/remotes/origin/master $sha1
git update-ref refs/remotes/origin/master $sha1 &&
git checkout master &&
git checkout origin/master &&
git checkout master &&
Expand Down
8 changes: 4 additions & 4 deletions t/t1410-reflog.sh
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,8 @@ test_expect_success 'delete' '
test_tick &&
git commit -m tiger C &&
HEAD_entry_count=$(git reflog | wc -l)
master_entry_count=$(git reflog show master | wc -l)
HEAD_entry_count=$(git reflog | wc -l) &&
master_entry_count=$(git reflog show master | wc -l) &&
test $HEAD_entry_count = 5 &&
test $master_entry_count = 5 &&
Expand All @@ -199,13 +199,13 @@ test_expect_success 'delete' '
test $HEAD_entry_count = $(git reflog | wc -l) &&
! grep ox < output &&
master_entry_count=$(wc -l < output)
master_entry_count=$(wc -l < output) &&
git reflog delete HEAD@{1} &&
test $(($HEAD_entry_count -1)) = $(git reflog | wc -l) &&
test $master_entry_count = $(git reflog show master | wc -l) &&
HEAD_entry_count=$(git reflog | wc -l)
HEAD_entry_count=$(git reflog | wc -l) &&
git reflog delete master@{07.04.2005.15:15:00.-0700} &&
git reflog show master > output &&
Expand Down
4 changes: 2 additions & 2 deletions t/t1450-fsck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ test_expect_success 'object with bad sha1' '
sha=$(echo blob | git hash-object -w --stdin) &&
old=$(echo $sha | sed "s+^..+&/+") &&
new=$(dirname $old)/ffffffffffffffffffffffffffffffffffffff &&
sha="$(dirname $new)$(basename $new)"
sha="$(dirname $new)$(basename $new)" &&
mv .git/objects/$old .git/objects/$new &&
test_when_finished "remove_object $sha" &&
git update-index --add --cacheinfo 100644 $sha foo &&
Expand Down Expand Up @@ -111,7 +111,7 @@ test_expect_success 'email with embedded > is not okay' '
'

test_expect_success 'tag pointing to nonexistent' '
cat >invalid-tag <<-\EOF
cat >invalid-tag <<-\EOF &&
object ffffffffffffffffffffffffffffffffffffffff
type commit
tag invalid
Expand Down
2 changes: 1 addition & 1 deletion t/t2007-checkout-symlink.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ test_expect_success SYMLINKS setup '
git branch side &&
echo goodbye >nitfol &&
git add nitfol
git add nitfol &&
test_tick &&
git commit -m "master adds file nitfol" &&
Expand Down
2 changes: 1 addition & 1 deletion t/t2016-checkout-patch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ test_expect_success PERL 'git checkout -p' '
'

test_expect_success PERL 'git checkout -p with staged changes' '
set_state dir/foo work index
set_state dir/foo work index &&
(echo n; echo y) | git checkout -p &&
verify_saved_state bar &&
verify_state dir/foo index index
Expand Down
2 changes: 1 addition & 1 deletion t/t2017-checkout-orphan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ TEST_FILE=foo
test_expect_success 'Setup' '
echo "Initial" >"$TEST_FILE" &&
git add "$TEST_FILE" &&
git commit -m "First Commit"
git commit -m "First Commit" &&
test_tick &&
echo "State 1" >>"$TEST_FILE" &&
git add "$TEST_FILE" &&
Expand Down
4 changes: 2 additions & 2 deletions t/t2050-git-dir-relative.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ chmod +x .git/hooks/post-commit'

test_expect_success 'post-commit hook used ordinarily' '
echo initial >top &&
git add top
git add top &&
git commit -m initial &&
test -r "${COMMIT_FILE}"
'
Expand All @@ -45,7 +45,7 @@ test -r "${COMMIT_FILE}"
rm -rf "${COMMIT_FILE}"

test_expect_success 'post-commit-hook from sub dir' '
echo changed again >top
echo changed again >top &&
cd subdir &&
git --git-dir .git --work-tree .. add ../top &&
git --git-dir .git --work-tree .. commit -m subcommit &&
Expand Down
2 changes: 1 addition & 1 deletion t/t2101-update-index-reupdate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ test_expect_success 'update-index again' \
echo hello world >dir1/file3 &&
echo goodbye people >file2 &&
git update-index --add file2 dir1/file3 &&
echo hello everybody >file2
echo hello everybody >file2 &&
echo happy >dir1/file3 &&
git update-index --again &&
git ls-files -s >current &&
Expand Down
2 changes: 1 addition & 1 deletion t/t2200-add-update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ test_expect_success setup '
echo initial >dir1/sub2 &&
echo initial >dir2/sub3 &&
git add check dir1 dir2 top foo &&
test_tick
test_tick &&
git commit -m initial &&
echo changed >check &&
Expand Down
2 changes: 1 addition & 1 deletion t/t3001-ls-files-others-exclude.sh
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ test_expect_success 'trailing slash in exclude allows directory match (2)' '

test_expect_success 'trailing slash in exclude forces directory match (1)' '
>two
>two &&
git ls-files --others --exclude=two/ >output &&
grep "^two" output
Expand Down
2 changes: 1 addition & 1 deletion t/t3030-merge-recursive.sh
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ test_expect_success 'reset and bind merge' '
echo "100644 $o0 0 c"
echo "100644 $o1 0 d/e"
) >expected &&
test_cmp expected actual
test_cmp expected actual &&
git read-tree --prefix=z/ master &&
git ls-files -s >actual &&
Expand Down
4 changes: 2 additions & 2 deletions t/t3050-subprojects-fetch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ test_expect_success setup '
cd sub &&
git init &&
>subfile &&
git add subfile
git add subfile &&
git commit -m "subproject commit #1"
) &&
>mainfile
>mainfile &&
git add sub mainfile &&
test_tick &&
git commit -m "superproject commit #1"
Expand Down
6 changes: 3 additions & 3 deletions t/t3203-branch-output.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ test_expect_success 'make commits' '
'

test_expect_success 'make branches' '
git branch branch-one
git branch branch-one &&
git branch branch-two HEAD^
'

test_expect_success 'make remote branches' '
git update-ref refs/remotes/origin/branch-one branch-one
git update-ref refs/remotes/origin/branch-two branch-two
git update-ref refs/remotes/origin/branch-one branch-one &&
git update-ref refs/remotes/origin/branch-two branch-two &&
git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/branch-one
'

Expand Down
8 changes: 4 additions & 4 deletions t/t3300-funny-names.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ test_expect_success TABS_IN_FILENAMES 'git ls-files no-funny' \
test_cmp expected current'

test_expect_success TABS_IN_FILENAMES 'setup expect' '
t0=`git write-tree`
echo "$t0" >t0
t0=`git write-tree` &&
echo "$t0" >t0 &&
cat > expected <<\EOF
just space
Expand All @@ -69,8 +69,8 @@ test_expect_success TABS_IN_FILENAMES 'git ls-files -z with-funny' \
test_cmp expected current'

test_expect_success TABS_IN_FILENAMES 'setup expect' '
t1=`git write-tree`
echo "$t1" >t1
t1=`git write-tree` &&
echo "$t1" >t1 &&
cat > expected <<\EOF
just space
Expand Down
2 changes: 1 addition & 1 deletion t/t3307-notes-man.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ test_expect_success 'example 1: notes to add an Acked-by line' '
'

test_expect_success 'example 2: binary notes' '
cp "$TEST_DIRECTORY"/test4012.png .
cp "$TEST_DIRECTORY"/test4012.png . &&
git checkout B &&
blob=$(git hash-object -w test4012.png) &&
git notes --ref=logo add -C "$blob" &&
Expand Down
6 changes: 3 additions & 3 deletions t/t3406-rebase-message.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,20 @@ test_expect_success 'rebase -m' '
'

test_expect_success 'rebase --stat' '
git reset --hard start
git reset --hard start &&
git rebase --stat master >diffstat.txt &&
grep "^ fileX | *1 +$" diffstat.txt
'

test_expect_success 'rebase w/config rebase.stat' '
git reset --hard start
git reset --hard start &&
git config rebase.stat true &&
git rebase master >diffstat.txt &&
grep "^ fileX | *1 +$" diffstat.txt
'

test_expect_success 'rebase -n overrides config rebase.stat config' '
git reset --hard start
git reset --hard start &&
git config rebase.stat true &&
git rebase -n master >diffstat.txt &&
! grep "^ fileX | *1 +$" diffstat.txt
Expand Down
2 changes: 1 addition & 1 deletion t/t3408-rebase-multi-line.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ test_expect_success setup '
git commit -a -m "A sample commit log message that has a long
summary that spills over multiple lines.
But otherwise with a sane description."
But otherwise with a sane description." &&
git branch side &&
Expand Down
4 changes: 2 additions & 2 deletions t/t3412-rebase-root.sh
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,14 @@ EOF
test_expect_success 'pre-rebase hook stops rebase' '
git checkout -b stops1 other &&
test_must_fail git rebase --root --onto master &&
test "z$(git symbolic-ref HEAD)" = zrefs/heads/stops1
test "z$(git symbolic-ref HEAD)" = zrefs/heads/stops1 &&
test 0 = $(git rev-list other...stops1 | wc -l)
'

test_expect_success 'pre-rebase hook stops rebase -i' '
git checkout -b stops2 other &&
test_must_fail git rebase --root --onto master &&
test "z$(git symbolic-ref HEAD)" = zrefs/heads/stops2
test "z$(git symbolic-ref HEAD)" = zrefs/heads/stops2 &&
test 0 = $(git rev-list other...stops2 | wc -l)
'

Expand Down
Loading

0 comments on commit a48fcd8

Please sign in to comment.