Thread (1 message) 1 message, 1 author, 2016-06-15

Re: [PATCH/RFC 1/7] i18n: mark init-db messages for translation

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:51:02
Subsystem: the rest · Maintainer: Linus Torvalds

Possibly related (same subject, not in this thread)

Junio C Hamano [off-list ref] writes:
+# Use this instead of "grep expected-string actual" to see if the
+# output from a git command that acn be translated contains an
+# expected string.  When running under GETTEXT_POISON this pretends
+# that the command produced expected results.
+test_i18ngrep () {
+	test -n "$GETTEXT_POISON" || grep "$@"
+}
+
I spoke too early.

The common pattern is either to ensure that the actual output has an
expected string, of to ensure that the actual output does not have an
unwanted string.  So this has to be something like:
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 3e7c2bb..874bcc5 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -1085,6 +1085,23 @@ 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 contains (or does
+# not contain) an expected string.  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 whether the filesystem supports symbolic links
 ln -s x y 2>/dev/null && test -h y 2>/dev/null && test_set_prereq SYMLINKS
 rm -f y
diff --git a/t/t2019-checkout-ambiguous-ref.sh b/t/t2019-checkout-ambiguous-ref.sh
index cc34e55..30c2225 100755
--- a/t/t2019-checkout-ambiguous-ref.sh
+++ b/t/t2019-checkout-ambiguous-ref.sh
@@ -29,9 +29,9 @@ test_expect_success 'checkout chooses branch over tag' '
 	test_cmp expect file
 '
 
-test_expect_success C_LOCALE_OUTPUT 'checkout reports switch to branch' '
-	grep "Switched to branch" stderr &&
-	! grep "^HEAD is now at" stderr
+test_expect_success 'checkout reports switch to branch' '
+	test_i18ngrep "Switched to branch" stderr &&
+	test_i18ngrep ! "^HEAD is now at" stderr
 '
 
 test_expect_success 'checkout vague ref succeeds' '
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help