Skip to content

'test_i18ngrep'-related fixes and improvements

SZEDER Gábor git 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest9 patches 2 repliesIn review
  2. v110 patches 26 repliesSuperseded

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/9t5541: add 'test_i18ngrep's missing filename parametert/t5541-http-push-smart.sh+1 -10 replies
2/9t5812: add 'test_i18ngrep's missing filename parametert/t5812-proto-disable-http.sh+1 -40 replies
3/9t6022: don't run 'git merge' upstream of a pipet/t6022-merge-rename.sh+4 -20 replies
4/9t4001: don't run 'git status' upstream of a pipet/t4001-diff-rename.sh+8 -30 replies
5/9t5510: consolidate 'grep' and 'test_i18ngrep' patternst/t5510-fetch.sh+3 -60 replies
6/9t5536: let 'test_i18ngrep' read the file without redirectiont/t5536-fetch-conflicts.sh+1 -10 replies
7/9t: move 'test_i18ncmp' and 'test_i18ngrep' to 'test-lib-functions.sh't/test-lib-functions.sh t/test-lib.sh+26 -260 replies
8/9t: validate 'test_i18ngrep's parameterst/test-lib-functions.sh+12 -01 reply
9/9t: make 'test_i18ngrep' more informative on failuret/test-lib-functions.sh+20 -40 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 0/9] 'test_i18ngrep'-related fixes and improvements

This is the second version of 'sg/test-i18ngrep'.

To recap, this patch series fixes a couple of bogus 'test_i18ngrep' invocations (patches 1-4), tries to prevent similar bugs in the future (patch 8), teaches 'test_i18ngrep' to be more informative on failure (patch 9), and a bit of cleanups in between (patches 5-7).

Changes since the previous version [1]:

- Use Junio's "last parameter must be file" suggestion instead of trying to read stdin in patch 8.
- Squashed together the patches validating 'test_i18ngrep's parameters (patches 8 and 9), in the hope that this way I can better explain that the two checks are not redundant but complement each other.
- Followed Simon's suggestion and dropped the now unnecessary curly brackets in patch 2.
- Dropped a subshell in the last patch. I initially used it to prevent the variable $f from leaking into the tests, since we can't use the 'local' keyword (yet), but other test helper function don't seem to care.
- Fixed the placements of single quotes and '!' in error messages and redirected one more error message to stderr in the last patch.
- Fixed a couple of typos in commit messages (the one Eric pointed out, but later noticed maybe 2-3 more).

[1] - https://public-inbox.org/git/[email protected]/T/

SZEDER Gábor (9):
t5541: add 'test_i18ngrep's missing filename parameter
t5812: add 'test_i18ngrep's missing filename parameter
t6022: don't run 'git merge' upstream of a pipe
t4001: don't run 'git status' upstream of a pipe
t5510: consolidate 'grep' and 'test_i18ngrep' patterns
t5536: let 'test_i18ngrep' read the file without redirection
t: move 'test_i18ncmp' and 'test_i18ngrep' to 'test-lib-functions.sh'
t: validate 'test_i18ngrep's parameters
t: make 'test_i18ngrep' more informative on failure

 t/t4001-diff-rename.sh        | 11 ++++++---
 t/t5510-fetch.sh              |  9 +++-----
 t/t5536-fetch-conflicts.sh    |  2 +-
 t/t5541-http-push-smart.sh    |  2 +-
 t/t5812-proto-disable-http.sh |  5 +---
 t/t6022-merge-rename.sh       |  6 +++--
 t/test-lib-functions.sh       | 54 +++++++++++++++++++++++++++++++++++++++++++
 t/test-lib.sh                 | 26 ---------------------
 8 files changed, 72 insertions(+), 43 deletions(-)
Signature · 1 line
2.16.1.158.ge6451079d
t/t5812-proto-disable-http.sh +1 -3
index 226a4920cd..872788ac8c 100755
@@ -20,9 +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 -E "(ftp.*disabled|your curl version is too old)" stderr
-	}
+	test_i18ngrep -E "(ftp.*disabled|your curl version is too old)" stderr
 '
 
 test_expect_success 'curl limits redirects' '
t/test-lib-functions.sh +15 -14
index 1f1d89d7ad..d936ecc0a5 100644
@@ -719,9 +719,11 @@ test_i18ncmp () {
 # under GETTEXT_POISON this pretends that the command produced expected
 # results.
 test_i18ngrep () {
-	( read line ) &&
-	error "bug in the test script: data on test_i18ngrep's stdin;" \
-	      "perhaps a git command's output is piped into it?"
+	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 ; }
@@ -740,21 +742,20 @@ test_i18ngrep () {
 		shift
 		! grep "$@" && return 0
 
-		echo >&2 "error: grep '! $@' did find a match in:"
+		echo >&2 "error: '! grep $@' did find a match in:"
 	else
 		grep "$@" && return 0
 
-		echo >&2 "error: grep '$@' didn't find a match in:"
+		echo >&2 "error: 'grep $@' didn't find a match in:"
 	fi
-	(
-		eval "f=\"\${$#}\""
-		if test -s "$f"
-		then
-			cat >&2 "$f"
-		else
-			echo "<File '$f' is empty>"
-		fi
-	)
+
+	if test -s "$last_arg"
+	then
+		cat >&2 "$last_arg"
+	else
+		echo >&2 "<File '$last_arg' is empty>"
+	fi
+
 	return 1
 }