Skip to content

Commit

Permalink
Merge branch 'rr/test-chaining'
Browse files Browse the repository at this point in the history
* rr/test-chaining:
  t3401: use test_commit in setup
  t3401: modernize style
  t3040 (subprojects-basic): fix '&&' chaining, modernize style
  t1510 (worktree): fix '&&' chaining
  t3030 (merge-recursive): use test_expect_code
  test: fix '&&' chaining
  t3200 (branch): fix '&&' chaining
  • Loading branch information
Junio C Hamano committed Dec 20, 2011
2 parents 33e7fef + 13c907c commit 9293aac
Show file tree
Hide file tree
Showing 15 changed files with 123 additions and 199 deletions.
2 changes: 1 addition & 1 deletion t/t1007-hash-object.sh
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ for args in "-w --stdin-paths" "--stdin-paths -w"; do
done

test_expect_success 'corrupt tree' '
echo abc >malformed-tree
echo abc >malformed-tree &&
test_must_fail git hash-object -t tree malformed-tree
'

Expand Down
2 changes: 1 addition & 1 deletion t/t1013-loose-object-format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ assert_blob_equals() {
}

test_expect_success setup '
cp -R "$TEST_DIRECTORY/t1013/objects" .git/
cp -R "$TEST_DIRECTORY/t1013/objects" .git/ &&
git --version
'

Expand Down
2 changes: 1 addition & 1 deletion t/t1300-repo-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ cat > expect << EOF
WhatEver = Second
EOF
test_expect_success 'similar section' '
git config Cores.WhatEver Second
git config Cores.WhatEver Second &&
test_cmp expect .git/config
'

Expand Down
2 changes: 1 addition & 1 deletion t/t1412-reflog-loop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ test_expect_success 'setup reflog with alternating commits' '
'

test_expect_success 'reflog shows all entries' '
cat >expect <<-\EOF
cat >expect <<-\EOF &&
topic@{0} reset: moving to two
topic@{1} reset: moving to one
topic@{2} reset: moving to two
Expand Down
6 changes: 3 additions & 3 deletions t/t1501-worktree.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ test_expect_success 'setup: helper for testing rev-parse' '
'

test_expect_success 'setup: core.worktree = relative path' '
unset GIT_WORK_TREE;
sane_unset GIT_WORK_TREE &&
GIT_DIR=repo.git &&
GIT_CONFIG="$(pwd)"/$GIT_DIR/config &&
export GIT_DIR GIT_CONFIG &&
Expand Down Expand Up @@ -89,7 +89,7 @@ test_expect_success 'subdir of work tree' '
'

test_expect_success 'setup: core.worktree = absolute path' '
unset GIT_WORK_TREE;
sane_unset GIT_WORK_TREE &&
GIT_DIR=$(pwd)/repo.git &&
GIT_CONFIG=$GIT_DIR/config &&
export GIT_DIR GIT_CONFIG &&
Expand Down Expand Up @@ -334,7 +334,7 @@ test_expect_success 'absolute pathspec should fail gracefully' '
'

test_expect_success 'make_relative_path handles double slashes in GIT_DIR' '
>dummy_file
>dummy_file &&
echo git --git-dir="$(pwd)//repo.git" --work-tree="$(pwd)" add dummy_file &&
git --git-dir="$(pwd)//repo.git" --work-tree="$(pwd)" add dummy_file
'
Expand Down
4 changes: 2 additions & 2 deletions t/t1510-repo-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ test_expect_success '#22a: core.worktree = GIT_DIR = .git dir' '
# like case #6.
setup_repo 22a "$here/22a/.git" "" unset &&
setup_repo 22ab . "" unset
setup_repo 22ab . "" unset &&
mkdir -p 22a/.git/sub 22a/sub &&
mkdir -p 22ab/.git/sub 22ab/sub &&
try_case 22a/.git unset . \
Expand Down Expand Up @@ -742,7 +742,7 @@ test_expect_success '#28: core.worktree and core.bare conflict (gitfile case)' '
# Case #29: GIT_WORK_TREE(+core.worktree) overrides core.bare (gitfile case).
test_expect_success '#29: setup' '
setup_repo 29 non-existent gitfile true &&
mkdir -p 29/sub/sub 29/wt/sub
mkdir -p 29/sub/sub 29/wt/sub &&
(
cd 29 &&
GIT_WORK_TREE="$here/29" &&
Expand Down
2 changes: 1 addition & 1 deletion t/t1511-rev-parse-caret.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ test_description='tests for ref^{stuff}'

test_expect_success 'setup' '
echo blob >a-blob &&
git tag -a -m blob blob-tag `git hash-object -w a-blob`
git tag -a -m blob blob-tag `git hash-object -w a-blob` &&
mkdir a-tree &&
echo moreblobs >a-tree/another-blob &&
git add . &&
Expand Down
72 changes: 6 additions & 66 deletions t/t3030-merge-recursive.sh
Original file line number Diff line number Diff line change
Expand Up @@ -285,17 +285,7 @@ test_expect_success 'merge-recursive simple' '
rm -fr [abcd] &&
git checkout -f "$c2" &&
git merge-recursive "$c0" -- "$c2" "$c1"
status=$?
case "$status" in
1)
: happy
;;
*)
echo >&2 "why status $status!!!"
false
;;
esac
test_expect_code 1 git merge-recursive "$c0" -- "$c2" "$c1"
'

test_expect_success 'merge-recursive result' '
Expand Down Expand Up @@ -334,17 +324,7 @@ test_expect_success 'merge-recursive remove conflict' '
rm -fr [abcd] &&
git checkout -f "$c1" &&
git merge-recursive "$c0" -- "$c1" "$c5"
status=$?
case "$status" in
1)
: happy
;;
*)
echo >&2 "why status $status!!!"
false
;;
esac
test_expect_code 1 git merge-recursive "$c0" -- "$c1" "$c5"
'

test_expect_success 'merge-recursive remove conflict' '
Expand Down Expand Up @@ -388,17 +368,7 @@ test_expect_success 'merge-recursive d/f conflict' '
git reset --hard &&
git checkout -f "$c1" &&
git merge-recursive "$c0" -- "$c1" "$c4"
status=$?
case "$status" in
1)
: happy
;;
*)
echo >&2 "why status $status!!!"
false
;;
esac
test_expect_code 1 git merge-recursive "$c0" -- "$c1" "$c4"
'

test_expect_success 'merge-recursive d/f conflict result' '
Expand All @@ -422,17 +392,7 @@ test_expect_success 'merge-recursive d/f conflict the other way' '
git reset --hard &&
git checkout -f "$c4" &&
git merge-recursive "$c0" -- "$c4" "$c1"
status=$?
case "$status" in
1)
: happy
;;
*)
echo >&2 "why status $status!!!"
false
;;
esac
test_expect_code 1 git merge-recursive "$c0" -- "$c4" "$c1"
'

test_expect_success 'merge-recursive d/f conflict result the other way' '
Expand All @@ -456,17 +416,7 @@ test_expect_success 'merge-recursive d/f conflict' '
git reset --hard &&
git checkout -f "$c1" &&
git merge-recursive "$c0" -- "$c1" "$c6"
status=$?
case "$status" in
1)
: happy
;;
*)
echo >&2 "why status $status!!!"
false
;;
esac
test_expect_code 1 git merge-recursive "$c0" -- "$c1" "$c6"
'

test_expect_success 'merge-recursive d/f conflict result' '
Expand All @@ -490,17 +440,7 @@ test_expect_success 'merge-recursive d/f conflict' '
git reset --hard &&
git checkout -f "$c6" &&
git merge-recursive "$c0" -- "$c6" "$c1"
status=$?
case "$status" in
1)
: happy
;;
*)
echo >&2 "why status $status!!!"
false
;;
esac
test_expect_code 1 git merge-recursive "$c0" -- "$c6" "$c1"
'

test_expect_success 'merge-recursive d/f conflict result' '
Expand Down
144 changes: 72 additions & 72 deletions t/t3040-subprojects-basic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,81 +3,81 @@
test_description='Basic subproject functionality'
. ./test-lib.sh

test_expect_success 'Super project creation' \
': >Makefile &&
git add Makefile &&
git commit -m "Superproject created"'


cat >expected <<EOF
:000000 160000 00000... A sub1
:000000 160000 00000... A sub2
EOF
test_expect_success 'create subprojects' \
'mkdir sub1 &&
( cd sub1 && git init && : >Makefile && git add * &&
git commit -q -m "subproject 1" ) &&
mkdir sub2 &&
( cd sub2 && git init && : >Makefile && git add * &&
git commit -q -m "subproject 2" ) &&
git update-index --add sub1 &&
git add sub2 &&
git commit -q -m "subprojects added" &&
git diff-tree --abbrev=5 HEAD^ HEAD |cut -d" " -f-3,5- >current &&
test_cmp expected current'

git branch save HEAD

test_expect_success 'check if fsck ignores the subprojects' \
'git fsck --full'

test_expect_success 'check if commit in a subproject detected' \
'( cd sub1 &&
echo "all:" >>Makefile &&
echo " true" >>Makefile &&
git commit -q -a -m "make all" ) && {
git diff-files --exit-code
test $? = 1
}'

test_expect_success 'check if a changed subproject HEAD can be committed' \
'git commit -q -a -m "sub1 changed" && {
git diff-tree --exit-code HEAD^ HEAD
test $? = 1
}'

test_expect_success 'check if diff-index works for subproject elements' \
'git diff-index --exit-code --cached save -- sub1
test $? = 1'

test_expect_success 'check if diff-tree works for subproject elements' \
'git diff-tree --exit-code HEAD^ HEAD -- sub1
test $? = 1'

test_expect_success 'check if git diff works for subproject elements' \
'git diff --exit-code HEAD^ HEAD
test $? = 1'

test_expect_success 'check if clone works' \
'git ls-files -s >expected &&
git clone -l -s . cloned &&
( cd cloned && git ls-files -s ) >current &&
test_cmp expected current'

test_expect_success 'removing and adding subproject' \
'git update-index --force-remove -- sub2 &&
mv sub2 sub3 &&
git add sub3 &&
git commit -q -m "renaming a subproject" && {
git diff -M --name-status --exit-code HEAD^ HEAD
test $? = 1
}'
test_expect_success 'setup: create superproject' '
: >Makefile &&
git add Makefile &&
git commit -m "Superproject created"
'

test_expect_success 'setup: create subprojects' '
mkdir sub1 &&
( cd sub1 && git init && : >Makefile && git add * &&
git commit -q -m "subproject 1" ) &&
mkdir sub2 &&
( cd sub2 && git init && : >Makefile && git add * &&
git commit -q -m "subproject 2" ) &&
git update-index --add sub1 &&
git add sub2 &&
git commit -q -m "subprojects added" &&
git diff-tree --abbrev=5 HEAD^ HEAD |cut -d" " -f-3,5- >current &&
git branch save HEAD &&
cat >expected <<-\EOF &&
:000000 160000 00000... A sub1
:000000 160000 00000... A sub2
EOF
test_cmp expected current
'

test_expect_success 'check if fsck ignores the subprojects' '
git fsck --full
'

test_expect_success 'check if commit in a subproject detected' '
( cd sub1 &&
echo "all:" >>Makefile &&
echo " true" >>Makefile &&
git commit -q -a -m "make all" ) &&
test_expect_code 1 git diff-files --exit-code
'

test_expect_success 'check if a changed subproject HEAD can be committed' '
git commit -q -a -m "sub1 changed" &&
test_expect_code 1 git diff-tree --exit-code HEAD^ HEAD
'

test_expect_success 'check if diff-index works for subproject elements' '
test_expect_code 1 git diff-index --exit-code --cached save -- sub1
'

test_expect_success 'check if diff-tree works for subproject elements' '
test_expect_code 1 git diff-tree --exit-code HEAD^ HEAD -- sub1
'

test_expect_success 'check if git diff works for subproject elements' '
test_expect_code 1 git diff --exit-code HEAD^ HEAD
'

test_expect_success 'check if clone works' '
git ls-files -s >expected &&
git clone -l -s . cloned &&
( cd cloned && git ls-files -s ) >current &&
test_cmp expected current
'

test_expect_success 'removing and adding subproject' '
git update-index --force-remove -- sub2 &&
mv sub2 sub3 &&
git add sub3 &&
git commit -q -m "renaming a subproject" &&
test_expect_code 1 git diff -M --name-status --exit-code HEAD^ HEAD
'

# the index must contain the object name the HEAD of the
# subproject sub1 was at the point "save"
test_expect_success 'checkout in superproject' \
'git checkout save &&
git diff-index --exit-code --raw --cached save -- sub1'
test_expect_success 'checkout in superproject' '
git checkout save &&
git diff-index --exit-code --raw --cached save -- sub1
'

# just interesting what happened...
# git diff --name-status -M save master
Expand Down
4 changes: 2 additions & 2 deletions t/t3200-branch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ test_expect_success \

test_expect_success \
'git branch --help should not have created a bogus branch' '
git branch --help </dev/null >/dev/null 2>/dev/null;
test_might_fail git branch --help </dev/null >/dev/null 2>/dev/null &&
test_path_is_missing .git/refs/heads/--help
'

Expand Down Expand Up @@ -88,7 +88,7 @@ test_expect_success \
test_expect_success \
'git branch -m n/n n should work' \
'git branch -l n/n &&
git branch -m n/n n
git branch -m n/n n &&
test_path_is_file .git/logs/refs/heads/n'

test_expect_success 'git branch -m o/o o should fail when o/p exists' '
Expand Down
Loading

0 comments on commit 9293aac

Please sign in to comment.