Merge branch 'da/mergetool-tests'

The clean-up of this test script was long overdue and is a very
welcome change.

* da/mergetool-tests:
  test-lib-functions: adjust style to match CodingGuidelines
  t7610-mergetool: use test_config to isolate tests
  t7610-mergetool: add missing && and remove commented-out code
  t7610-mergetool: use tabs instead of a mix of tabs and spaces
This commit is contained in:
Junio C Hamano
2014-10-21 13:28:14 -07:00
2 changed files with 442 additions and 444 deletions

View File

@@ -112,7 +112,7 @@ test_expect_success 'custom mergetool' '
'
test_expect_success 'mergetool crlf' '
git config core.autocrlf true &&
test_config core.autocrlf true &&
git checkout -b test2 branch1 &&
test_must_fail git merge master >/dev/null 2>&1 &&
( yes "" | git mergetool file1 >/dev/null 2>&1 ) &&
@@ -192,7 +192,7 @@ test_expect_success 'mergetool merges all from subdir' '
test_expect_success 'mergetool skips resolved paths when rerere is active' '
git config rerere.enabled true &&
rm -rf .git/rr-cache &&
git checkout -b test5 branch1
git checkout -b test5 branch1 &&
git submodule update -N &&
test_must_fail git merge master >/dev/null 2>&1 &&
( yes "l" | git mergetool --no-prompt submod >/dev/null 2>&1 ) &&
@@ -231,18 +231,12 @@ test_expect_success 'conflicted stash sets up rerere' '
'
test_expect_success 'mergetool takes partial path' '
git reset --hard
git reset --hard &&
git config rerere.enabled false &&
git checkout -b test12 branch1 &&
git submodule update -N &&
test_must_fail git merge master &&
#should not need these lines
#( yes "d" | git mergetool file11 >/dev/null 2>&1 ) &&
#( yes "d" | git mergetool file12 >/dev/null 2>&1 ) &&
#( yes "l" | git mergetool submod >/dev/null 2>&1 ) &&
#( yes "" | git mergetool file1 file2 >/dev/null 2>&1 ) &&
( yes "" | git mergetool subdir ) &&
test "$(cat subdir/file3)" = "master new sub" &&
@@ -511,14 +505,12 @@ test_expect_success 'file with no base' '
test_expect_success 'custom commands override built-ins' '
git checkout -b test14 branch1 &&
git config mergetool.defaults.cmd "cat \"\$REMOTE\" >\"\$MERGED\"" &&
git config mergetool.defaults.trustExitCode true &&
test_config mergetool.defaults.cmd "cat \"\$REMOTE\" >\"\$MERGED\"" &&
test_config mergetool.defaults.trustExitCode true &&
test_must_fail git merge master &&
git mergetool --no-prompt --tool defaults -- both &&
echo master both added >expected &&
test_cmp both expected &&
git config --unset mergetool.defaults.cmd &&
git config --unset mergetool.defaults.trustExitCode &&
git reset --hard master >/dev/null 2>&1
'

View File

@@ -413,7 +413,7 @@ test_external () {
# test_run_, but keep its stdout on our stdout even in
# non-verbose mode.
"$@" 2>&4
if [ "$?" = 0 ]
if test "$?" = 0
then
if test $test_external_has_tap -eq 0; then
test_ok_ "$descr"
@@ -440,11 +440,12 @@ test_external_without_stderr () {
tmp=${TMPDIR:-/tmp}
stderr="$tmp/git-external-stderr.$$.tmp"
test_external "$@" 4> "$stderr"
[ -f "$stderr" ] || error "Internal error: $stderr disappeared."
test -f "$stderr" || error "Internal error: $stderr disappeared."
descr="no stderr: $1"
shift
say >&3 "# expecting no stderr from previous command"
if [ ! -s "$stderr" ]; then
if test ! -s "$stderr"
then
rm "$stderr"
if test $test_external_has_tap -eq 0; then
@@ -454,8 +455,9 @@ test_external_without_stderr () {
test_success=$(($test_success + 1))
fi
else
if [ "$verbose" = t ]; then
output=`echo; echo "# Stderr is:"; cat "$stderr"`
if test "$verbose" = t
then
output=$(echo; echo "# Stderr is:"; cat "$stderr")
else
output=
fi
@@ -474,7 +476,7 @@ test_external_without_stderr () {
# The commands test the existence or non-existence of $1. $2 can be
# given to provide a more precise diagnosis.
test_path_is_file () {
if ! [ -f "$1" ]
if ! test -f "$1"
then
echo "File $1 doesn't exist. $*"
false
@@ -482,7 +484,7 @@ test_path_is_file () {
}
test_path_is_dir () {
if ! [ -d "$1" ]
if ! test -d "$1"
then
echo "Directory $1 doesn't exist. $*"
false
@@ -501,11 +503,12 @@ test_dir_is_empty () {
}
test_path_is_missing () {
if [ -e "$1" ]
if test -e "$1"
then
echo "Path exists:"
ls -ld "$1"
if [ $# -ge 1 ]; then
if test $# -ge 1
then
echo "$*"
fi
false
@@ -666,9 +669,12 @@ test_cmp_rev () {
# similar to GNU seq(1), but the latter might not be available
# everywhere (and does not do letters). It may be used like:
#
# for i in `test_seq 100`; do
# for j in `test_seq 10 20`; do
# for k in `test_seq a z`; do
# for i in $(test_seq 100)
# do
# for j in $(test_seq 10 20)
# do
# for k in $(test_seq a z)
# do
# echo $i-$j-$k
# done
# done