Merge branch 'sg/test-i18ngrep' into maint

Test fixes.

* sg/test-i18ngrep:
  t: make 'test_i18ngrep' more informative on failure
  t: validate 'test_i18ngrep's parameters
  t: move 'test_i18ncmp' and 'test_i18ngrep' to 'test-lib-functions.sh'
  t5536: let 'test_i18ngrep' read the file without redirection
  t5510: consolidate 'grep' and 'test_i18ngrep' patterns
  t4001: don't run 'git status' upstream of a pipe
  t6022: don't run 'git merge' upstream of a pipe
  t5812: add 'test_i18ngrep's missing filename parameter
  t5541: add 'test_i18ngrep's missing filename parameter
This commit is contained in:
Junio C Hamano 2018-03-22 14:24:12 -07:00
Родитель d78b7eb2d5 63b1a175ee
Коммит dab684ff43
8 изменённых файлов: 72 добавлений и 43 удалений

Просмотреть файл

@ -134,11 +134,15 @@ test_expect_success 'favour same basenames over different ones' '
git rm path1 &&
mkdir subdir &&
git mv another-path subdir/path1 &&
git status | test_i18ngrep "renamed: .*path1 -> subdir/path1"'
git status >out &&
test_i18ngrep "renamed: .*path1 -> subdir/path1" out
'
test_expect_success 'favour same basenames even with minor differences' '
git show HEAD:path1 | sed "s/15/16/" > subdir/path1 &&
git status | test_i18ngrep "renamed: .*path1 -> subdir/path1"'
git status >out &&
test_i18ngrep "renamed: .*path1 -> subdir/path1" out
'
test_expect_success 'two files with same basename and same content' '
git reset --hard &&
@ -148,7 +152,8 @@ test_expect_success 'two files with same basename and same content' '
git add dir &&
git commit -m 2 &&
git mv dir other-dir &&
git status | test_i18ngrep "renamed: .*dir/A/file -> other-dir/A/file"
git status >out &&
test_i18ngrep "renamed: .*dir/A/file -> other-dir/A/file" out
'
test_expect_success 'setup for many rename source candidates' '

Просмотреть файл

@ -222,12 +222,9 @@ test_expect_success 'fetch uses remote ref names to describe new refs' '
(
cd descriptive &&
git fetch o 2>actual &&
grep " -> refs/crazyheads/descriptive-branch$" actual |
test_i18ngrep "new branch" &&
grep " -> descriptive-tag$" actual |
test_i18ngrep "new tag" &&
grep " -> crazy$" actual |
test_i18ngrep "new ref"
test_i18ngrep "new branch.* -> refs/crazyheads/descriptive-branch$" actual &&
test_i18ngrep "new tag.* -> descriptive-tag$" actual &&
test_i18ngrep "new ref.* -> crazy$" actual
) &&
git checkout master
'

Просмотреть файл

@ -22,7 +22,7 @@ verify_stderr () {
cat >expected &&
# We're not interested in the error
# "fatal: The remote end hung up unexpectedly":
test_i18ngrep -E '^(fatal|warning):' <error | grep -v 'hung up' >actual | sort &&
test_i18ngrep -E '^(fatal|warning):' error | grep -v 'hung up' >actual | sort &&
test_i18ncmp expected actual
}

Просмотреть файл

@ -234,7 +234,7 @@ test_expect_success TTY 'push --no-progress silences progress but not status' '
test_commit no-progress &&
test_terminal git push --no-progress >output 2>&1 &&
test_i18ngrep "^To http" output &&
test_i18ngrep ! "^Writing objects"
test_i18ngrep ! "^Writing objects" output
'
test_expect_success 'push --progress shows progress to non-tty' '

Просмотреть файл

@ -20,10 +20,7 @@ test_expect_success 'curl redirects respect whitelist' '
test_must_fail env GIT_ALLOW_PROTOCOL=http:https \
GIT_SMART_HTTP=0 \
git clone "$HTTPD_URL/ftp-redir/repo.git" 2>stderr &&
{
test_i18ngrep "ftp.*disabled" stderr ||
test_i18ngrep "your curl version is too old"
}
test_i18ngrep -E "(ftp.*disabled|your curl version is too old)" stderr
'
test_expect_success 'curl limits redirects' '

Просмотреть файл

@ -242,10 +242,12 @@ test_expect_success 'merge of identical changes in a renamed file' '
rm -f A M N &&
git reset --hard &&
git checkout change+rename &&
GIT_MERGE_VERBOSITY=3 git merge change | test_i18ngrep "^Skipped B" &&
GIT_MERGE_VERBOSITY=3 git merge change >out &&
test_i18ngrep "^Skipped B" out &&
git reset --hard HEAD^ &&
git checkout change &&
GIT_MERGE_VERBOSITY=3 git merge change+rename | test_i18ngrep "^Skipped B"
GIT_MERGE_VERBOSITY=3 git merge change+rename >out &&
test_i18ngrep "^Skipped B" out
'
test_expect_success 'setup for rename + d/f conflicts' '

Просмотреть файл

@ -705,6 +705,60 @@ test_cmp_bin() {
cmp "$@"
}
# Use this instead of test_cmp to compare files that contain expected and
# actual output from git commands that can be translated. When running
# under GETTEXT_POISON this pretends that the command produced expected
# results.
test_i18ncmp () {
test -n "$GETTEXT_POISON" || test_cmp "$@"
}
# Use this instead of "grep expected-string actual" to see if the
# output from a git command that can be translated either contains an
# expected string, or does not contain an unwanted one. When running
# under GETTEXT_POISON this pretends that the command produced expected
# results.
test_i18ngrep () {
eval "last_arg=\${$#}"
test -f "$last_arg" ||
error "bug in the test script: test_i18ngrep requires a file" \
"to read as the last parameter"
if test $# -lt 2 ||
{ test "x!" = "x$1" && test $# -lt 3 ; }
then
error "bug in the test script: too few parameters to test_i18ngrep"
fi
if test -n "$GETTEXT_POISON"
then
# pretend success
return 0
fi
if test "x!" = "x$1"
then
shift
! grep "$@" && return 0
echo >&2 "error: '! grep $@' did find a match in:"
else
grep "$@" && return 0
echo >&2 "error: 'grep $@' didn't find a match in:"
fi
if test -s "$last_arg"
then
cat >&2 "$last_arg"
else
echo >&2 "<File '$last_arg' is empty>"
fi
return 1
}
# Call any command "$@" but be more verbose about its
# failure. This is handy for commands like "test" which do
# not output anything when they fail.

Просмотреть файл

@ -1062,32 +1062,6 @@ else
test_set_prereq C_LOCALE_OUTPUT
fi
# Use this instead of test_cmp to compare files that contain expected and
# actual output from git commands that can be translated. When running
# under GETTEXT_POISON this pretends that the command produced expected
# results.
test_i18ncmp () {
test -n "$GETTEXT_POISON" || test_cmp "$@"
}
# Use this instead of "grep expected-string actual" to see if the
# output from a git command that can be translated either contains an
# expected string, or does not contain an unwanted one. When running
# under GETTEXT_POISON this pretends that the command produced expected
# results.
test_i18ngrep () {
if test -n "$GETTEXT_POISON"
then
: # pretend success
elif test "x!" = "x$1"
then
shift
! grep "$@"
else
grep "$@"
fi
}
test_lazy_prereq PIPE '
# test whether the filesystem supports FIFOs
test_have_prereq !MINGW,!CYGWIN &&