git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH/RFC 1/7] i18n: mark init-db messages for translation
Date: Tue, 12 Apr 2011 16:04:56 -0700	[thread overview]
Message-ID: <7v1v17nk9z.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <7v62qjnkpe.fsf@alter.siamese.dyndns.org> (Junio C. Hamano's message of "Tue, 12 Apr 2011 15:55:41 -0700")

Junio C Hamano <gitster@pobox.com> 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' '

  reply	other threads:[~2011-04-12 23:05 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-10 19:34 [PATCH/RFC 0/7] i18n: mark missing C messages Ævar Arnfjörð Bjarmason
2011-04-10 19:34 ` [PATCH/RFC 1/7] i18n: mark init-db messages for translation Ævar Arnfjörð Bjarmason
2011-04-12  7:12   ` Junio C Hamano
2011-04-12  7:15     ` Junio C Hamano
2011-04-12  7:44       ` Ævar Arnfjörð Bjarmason
2011-04-12 18:20         ` Junio C Hamano
2011-04-12 22:55           ` Junio C Hamano
2011-04-12 23:04             ` Junio C Hamano [this message]
2011-04-14 20:56               ` [PATCH] i18n: use test_i18n{grep,cmp} in t7508 Junio C Hamano
2011-04-10 19:34 ` [PATCH/RFC 2/7] i18n: mark merge "Could not read from" message for translation Ævar Arnfjörð Bjarmason
2011-04-10 19:34 ` [PATCH/RFC 3/7] i18n: mark merge "upstream" messages " Ævar Arnfjörð Bjarmason
2011-04-10 19:34 ` [PATCH/RFC 4/7] i18n: mark merge CHERRY_PICK_HEAD " Ævar Arnfjörð Bjarmason
2011-04-10 19:34 ` [PATCH/RFC 5/7] i18n: mark clone nonexistent repository message " Ævar Arnfjörð Bjarmason
2011-04-10 19:34 ` [PATCH/RFC 6/7] i18n: mark checkout --detach messages " Ævar Arnfjörð Bjarmason
2011-04-10 19:34 ` [PATCH/RFC 7/7] i18n: mark checkout plural warning " Ævar Arnfjörð Bjarmason
2011-04-12  7:19   ` Junio C Hamano
2011-04-12  7:54     ` Ævar Arnfjörð Bjarmason
2011-04-12 20:57       ` Junio C Hamano
2011-04-13  8:30         ` Ævar Arnfjörð Bjarmason
2011-04-13 15:55           ` Junio C Hamano
2011-04-12  7:27 ` [PATCH/RFC 0/7] i18n: mark missing C messages Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7v1v17nk9z.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).