File tree Expand file tree Collapse file tree 8 files changed +72
-43
lines changed
Expand file tree Collapse file tree 8 files changed +72
-43
lines changed Original file line number Diff line number Diff line change @@ -134,11 +134,15 @@ test_expect_success 'favour same basenames over different ones' '
134134 git rm path1 &&
135135 mkdir subdir &&
136136 git mv another-path subdir/path1 &&
137- git status | test_i18ngrep "renamed: .*path1 -> subdir/path1"'
137+ git status >out &&
138+ test_i18ngrep "renamed: .*path1 -> subdir/path1" out
139+ '
138140
139141test_expect_success ' favour same basenames even with minor differences' '
140142 git show HEAD:path1 | sed "s/15/16/" > subdir/path1 &&
141- git status | test_i18ngrep "renamed: .*path1 -> subdir/path1"'
143+ git status >out &&
144+ test_i18ngrep "renamed: .*path1 -> subdir/path1" out
145+ '
142146
143147test_expect_success ' two files with same basename and same content' '
144148 git reset --hard &&
@@ -148,7 +152,8 @@ test_expect_success 'two files with same basename and same content' '
148152 git add dir &&
149153 git commit -m 2 &&
150154 git mv dir other-dir &&
151- git status | test_i18ngrep "renamed: .*dir/A/file -> other-dir/A/file"
155+ git status >out &&
156+ test_i18ngrep "renamed: .*dir/A/file -> other-dir/A/file" out
152157'
153158
154159test_expect_success ' setup for many rename source candidates' '
Original file line number Diff line number Diff line change @@ -222,12 +222,9 @@ test_expect_success 'fetch uses remote ref names to describe new refs' '
222222 (
223223 cd descriptive &&
224224 git fetch o 2>actual &&
225- grep " -> refs/crazyheads/descriptive-branch$" actual |
226- test_i18ngrep "new branch" &&
227- grep " -> descriptive-tag$" actual |
228- test_i18ngrep "new tag" &&
229- grep " -> crazy$" actual |
230- test_i18ngrep "new ref"
225+ test_i18ngrep "new branch.* -> refs/crazyheads/descriptive-branch$" actual &&
226+ test_i18ngrep "new tag.* -> descriptive-tag$" actual &&
227+ test_i18ngrep "new ref.* -> crazy$" actual
231228 ) &&
232229 git checkout master
233230'
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ verify_stderr () {
2222 cat > expected &&
2323 # We're not interested in the error
2424 # "fatal: The remote end hung up unexpectedly":
25- test_i18ngrep -E ' ^(fatal|warning):' < error | grep -v ' hung up' > actual | sort &&
25+ test_i18ngrep -E ' ^(fatal|warning):' error | grep -v ' hung up' > actual | sort &&
2626 test_i18ncmp expected actual
2727}
2828
Original file line number Diff line number Diff line change @@ -234,7 +234,7 @@ test_expect_success TTY 'push --no-progress silences progress but not status' '
234234 test_commit no-progress &&
235235 test_terminal git push --no-progress >output 2>&1 &&
236236 test_i18ngrep "^To http" output &&
237- test_i18ngrep ! "^Writing objects"
237+ test_i18ngrep ! "^Writing objects" output
238238'
239239
240240test_expect_success ' push --progress shows progress to non-tty' '
Original file line number Diff line number Diff line change @@ -20,10 +20,7 @@ test_expect_success 'curl redirects respect whitelist' '
2020 test_must_fail env GIT_ALLOW_PROTOCOL=http:https \
2121 GIT_SMART_HTTP=0 \
2222 git clone "$HTTPD_URL/ftp-redir/repo.git" 2>stderr &&
23- {
24- test_i18ngrep "ftp.*disabled" stderr ||
25- test_i18ngrep "your curl version is too old"
26- }
23+ test_i18ngrep -E "(ftp.*disabled|your curl version is too old)" stderr
2724'
2825
2926test_expect_success ' curl limits redirects' '
Original file line number Diff line number Diff line change @@ -242,10 +242,12 @@ test_expect_success 'merge of identical changes in a renamed file' '
242242 rm -f A M N &&
243243 git reset --hard &&
244244 git checkout change+rename &&
245- GIT_MERGE_VERBOSITY=3 git merge change | test_i18ngrep "^Skipped B" &&
245+ GIT_MERGE_VERBOSITY=3 git merge change >out &&
246+ test_i18ngrep "^Skipped B" out &&
246247 git reset --hard HEAD^ &&
247248 git checkout change &&
248- GIT_MERGE_VERBOSITY=3 git merge change+rename | test_i18ngrep "^Skipped B"
249+ GIT_MERGE_VERBOSITY=3 git merge change+rename >out &&
250+ test_i18ngrep "^Skipped B" out
249251'
250252
251253test_expect_success ' setup for rename + d/f conflicts' '
Original file line number Diff line number Diff line change @@ -705,6 +705,60 @@ test_cmp_bin() {
705705 cmp " $@ "
706706}
707707
708+ # Use this instead of test_cmp to compare files that contain expected and
709+ # actual output from git commands that can be translated. When running
710+ # under GETTEXT_POISON this pretends that the command produced expected
711+ # results.
712+ test_i18ncmp () {
713+ test -n " $GETTEXT_POISON " || test_cmp " $@ "
714+ }
715+
716+ # Use this instead of "grep expected-string actual" to see if the
717+ # output from a git command that can be translated either contains an
718+ # expected string, or does not contain an unwanted one. When running
719+ # under GETTEXT_POISON this pretends that the command produced expected
720+ # results.
721+ test_i18ngrep () {
722+ eval " last_arg=\$ {$# }"
723+
724+ test -f " $last_arg " ||
725+ error " bug in the test script: test_i18ngrep requires a file" \
726+ " to read as the last parameter"
727+
728+ if test $# -lt 2 ||
729+ { test " x!" = " x$1 " && test $# -lt 3 ; }
730+ then
731+ error " bug in the test script: too few parameters to test_i18ngrep"
732+ fi
733+
734+ if test -n " $GETTEXT_POISON "
735+ then
736+ # pretend success
737+ return 0
738+ fi
739+
740+ if test " x!" = " x$1 "
741+ then
742+ shift
743+ ! grep " $@ " && return 0
744+
745+ echo >&2 " error: '! grep $@ ' did find a match in:"
746+ else
747+ grep " $@ " && return 0
748+
749+ echo >&2 " error: 'grep $@ ' didn't find a match in:"
750+ fi
751+
752+ if test -s " $last_arg "
753+ then
754+ cat >&2 " $last_arg "
755+ else
756+ echo >&2 " <File '$last_arg ' is empty>"
757+ fi
758+
759+ return 1
760+ }
761+
708762# Call any command "$@" but be more verbose about its
709763# failure. This is handy for commands like "test" which do
710764# not output anything when they fail.
Original file line number Diff line number Diff line change @@ -1062,32 +1062,6 @@ else
10621062 test_set_prereq C_LOCALE_OUTPUT
10631063fi
10641064
1065- # Use this instead of test_cmp to compare files that contain expected and
1066- # actual output from git commands that can be translated. When running
1067- # under GETTEXT_POISON this pretends that the command produced expected
1068- # results.
1069- test_i18ncmp () {
1070- test -n " $GETTEXT_POISON " || test_cmp " $@ "
1071- }
1072-
1073- # Use this instead of "grep expected-string actual" to see if the
1074- # output from a git command that can be translated either contains an
1075- # expected string, or does not contain an unwanted one. When running
1076- # under GETTEXT_POISON this pretends that the command produced expected
1077- # results.
1078- test_i18ngrep () {
1079- if test -n " $GETTEXT_POISON "
1080- then
1081- : # pretend success
1082- elif test " x!" = " x$1 "
1083- then
1084- shift
1085- ! grep " $@ "
1086- else
1087- grep " $@ "
1088- fi
1089- }
1090-
10911065test_lazy_prereq PIPE '
10921066 # test whether the filesystem supports FIFOs
10931067 test_have_prereq !MINGW,!CYGWIN &&
You can’t perform that action at this time.
0 commit comments