git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
SZEDER Gábor <szeder.dev@gmail.com>
Date
Feb 8, 2018, 15:56 UTC
Message-ID
<20180208155656.9831-1-szeder.dev@gmail.com>
In-Reply-To
<20180126123708.21722-1-szeder.dev@gmail.com>
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/20180126123708.21722-1-szeder.dev@gmail.com/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(-)
-- 
2.16.1.158.ge6451079d


diff --git a/t/t5812-proto-disable-http.sh b/t/t5812-proto-disable-http.sh
index 226a4920cd..872788ac8c 100755
--- a/t/t5812-proto-disable-http.sh
+++ b/t/t5812-proto-disable-http.sh
@@ -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' '
diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
index 1f1d89d7ad..d936ecc0a5 100644
--- a/t/test-lib-functions.sh
+++ b/t/test-lib-functions.sh
@@ -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
 }
 
Previous: Jeff KingNext: SZEDER Gábor
Message 38 of 49 in “'test_i18ngrep'-related fixes and improvements”
  1. 00/10 'test_i18ngrep'-related fixes and improvementsSZEDER Gábor, Jan 26, 2018
  2. 01/10 t5541: add 'test_i18ngrep's missing filename parameterSZEDER Gábor, Jan 26, 2018
  3. Jeff KingJan 26, 2018
  4. Jeff KingJan 26, 2018
  5. 04/10 t4001: don't run 'git status' upstream of a pipeSZEDER Gábor, Jan 26, 2018
  6. 07/10 t: move 'test_i18ncmp' and 'test_i18ngrep' to 'test-lib-functions.sh'SZEDER Gábor, Jan 26, 2018
  7. Junio C HamanoJan 26, 2018
  8. Jeff KingJan 26, 2018
  9. SZEDER GáborJan 26, 2018
  10. 10/10 t: make 'test_i18ngrep' more informative on failureSZEDER Gábor, Jan 26, 2018
  11. Jeff KingJan 26, 2018
  12. SZEDER GáborJan 26, 2018
  13. Jeff KingJan 26, 2018
  14. SZEDER GáborJan 26, 2018
  15. Jeff KingJan 26, 2018
  16. 06/10 t5536: let 'test_i18ngrep' read the file without redirectionSZEDER Gábor, Jan 26, 2018
  17. 09/10 t: make sure that 'test_i18ngrep' got enough parametersSZEDER Gábor, Jan 26, 2018
  18. Jeff KingJan 26, 2018
  19. Eric SunshineJan 26, 2018
  20. 05/10 t5510: consolidate 'grep' and 'test_i18ngrep' patternsSZEDER Gábor, Jan 26, 2018
  21. Junio C HamanoJan 26, 2018
  22. SZEDER GáborJan 26, 2018
  23. Junio C HamanoJan 26, 2018
  24. 08/10 t: forbid piping into 'test_i18ngrep'SZEDER Gábor, Jan 26, 2018
  25. Junio C HamanoJan 26, 2018
  26. Junio C HamanoJan 26, 2018
  27. Jeff KingJan 26, 2018
  28. SZEDER GáborJan 26, 2018
  29. Junio C HamanoJan 26, 2018
  30. Jeff KingJan 26, 2018
  31. 02/10 t5812: add 'test_i18ngrep's missing filename parameterSZEDER Gábor, Jan 26, 2018
  32. Jeff KingJan 26, 2018
  33. SZEDER GáborFeb 7, 2018
  34. Jeff KingFeb 7, 2018
  35. Simon RuderichJan 30, 2018
  36. 03/10 t6022: don't run 'git merge' upstream of a pipeSZEDER Gábor, Jan 26, 2018
  37. Jeff KingJan 26, 2018
  38. 0/9 'test_i18ngrep'-related fixes and improvementsSZEDER Gábor, Feb 8, 2018
  39. 1/9 t5541: add 'test_i18ngrep's missing filename parameterSZEDER Gábor, Feb 8, 2018
  40. 4/9 t4001: don't run 'git status' upstream of a pipeSZEDER Gábor, Feb 8, 2018
  41. 8/9 t: validate 'test_i18ngrep's parametersSZEDER Gábor, Feb 8, 2018
  42. Jeff KingFeb 8, 2018
  43. 9/9 t: make 'test_i18ngrep' more informative on failureSZEDER Gábor, Feb 8, 2018
  44. 5/9 t5510: consolidate 'grep' and 'test_i18ngrep' patternsSZEDER Gábor, Feb 8, 2018
  45. 6/9 t5536: let 'test_i18ngrep' read the file without redirectionSZEDER Gábor, Feb 8, 2018
  46. 7/9 t: move 'test_i18ncmp' and 'test_i18ngrep' to 'test-lib-functions.sh'SZEDER Gábor, Feb 8, 2018
  47. 2/9 t5812: add 'test_i18ngrep's missing filename parameterSZEDER Gábor, Feb 8, 2018
  48. 3/9 t6022: don't run 'git merge' upstream of a pipeSZEDER Gábor, Feb 8, 2018
  49. Jeff KingFeb 8, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.