From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: git@vger.kernel.org
Cc: "Junio C Hamano" <gitster@pobox.com>,
"Ævar Arnfjörð" <avarab@gmail.com>,
"Jonathan Nieder" <jrnieder@gmail.com>,
"Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH] Build in gettext poison feature unconditionally
Date: Tue, 21 Aug 2012 11:39:30 +0700 [thread overview]
Message-ID: <1345523970-14914-1-git-send-email-pclouds@gmail.com> (raw)
Making gettext poison second citizen makes it easy to forget to run
the test suite with it. This is step one to running test suite with
gettext poison by default.
The runtime cost should be small. "gcc -O2" inlines _() and
use_gettext_poison(). But even if it does not, performance should not
be impacted as _() calls are usually not on critical path. If some of
them are, we better fix there as gettext() may or may not be cheap
anyway.
A new target is added to run test with poisoned gettext: test-poison
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
I don't know the story behind this compile-time switch. The series [1]
that introduces it does not say much.
This at least makes it easier for me to run poison tests instead of
building another binary, if I remember it. Next step could be make
"make test" run both normal and poison modes, but I'm not sure how to
do it nicely yet.
[1] http://thread.gmane.org/gmane.comp.version-control.git/167307/focus=167438
Makefile | 12 +++---------
gettext.c | 10 ----------
gettext.h | 12 +++++++-----
po/README | 13 ++++---------
4 files changed, 14 insertions(+), 33 deletions(-)
diff --git a/Makefile b/Makefile
index 6b0c961..8255fb9 100644
--- a/Makefile
+++ b/Makefile
@@ -258,11 +258,6 @@ all::
# Define HAVE_DEV_TTY if your system can open /dev/tty to interact with the
# user.
#
-# Define GETTEXT_POISON if you are debugging the choice of strings marked
-# for translation. In a GETTEXT_POISON build, you can turn all strings marked
-# for translation into gibberish by setting the GIT_GETTEXT_POISON variable
-# (to any value) in your environment.
-#
# Define JSMIN to point to JavaScript minifier that functions as
# a filter to have gitweb.js minified.
#
@@ -1594,9 +1589,6 @@ endif
ifdef NO_SYMLINK_HEAD
BASIC_CFLAGS += -DNO_SYMLINK_HEAD
endif
-ifdef GETTEXT_POISON
- BASIC_CFLAGS += -DGETTEXT_POISON
-endif
ifdef NO_GETTEXT
BASIC_CFLAGS += -DNO_GETTEXT
USE_GETTEXT_SCHEME ?= fallthrough
@@ -2497,7 +2489,6 @@ ifdef GIT_TEST_CMP_USE_COPIED_CONTEXT
@echo GIT_TEST_CMP_USE_COPIED_CONTEXT=YesPlease >>$@
endif
@echo NO_GETTEXT=\''$(subst ','\'',$(subst ','\'',$(NO_GETTEXT)))'\' >>$@
- @echo GETTEXT_POISON=\''$(subst ','\'',$(subst ','\'',$(GETTEXT_POISON)))'\' >>$@
ifdef GIT_PERF_REPEAT_COUNT
@echo GIT_PERF_REPEAT_COUNT=\''$(subst ','\'',$(subst ','\'',$(GIT_PERF_REPEAT_COUNT)))'\' >>$@
endif
@@ -2545,6 +2536,9 @@ export NO_SVN_TESTS
test: all
$(MAKE) -C t/ all
+poison-test: all
+ $(MAKE) POISON_GETTEXT=YesPlease -C t/ all
+
perf: all
$(MAKE) -C t/perf/ all
diff --git a/gettext.c b/gettext.c
index f75bca7..6aa822c 100644
--- a/gettext.c
+++ b/gettext.c
@@ -16,16 +16,6 @@
# endif
#endif
-#ifdef GETTEXT_POISON
-int use_gettext_poison(void)
-{
- static int poison_requested = -1;
- if (poison_requested == -1)
- poison_requested = getenv("GIT_GETTEXT_POISON") ? 1 : 0;
- return poison_requested;
-}
-#endif
-
#ifndef NO_GETTEXT
static void init_gettext_charset(const char *domain)
{
diff --git a/gettext.h b/gettext.h
index 57ba8bb..a77554f 100644
--- a/gettext.h
+++ b/gettext.h
@@ -36,11 +36,13 @@ static inline void git_setup_gettext(void)
}
#endif
-#ifdef GETTEXT_POISON
-extern int use_gettext_poison(void);
-#else
-#define use_gettext_poison() 0
-#endif
+static inline int use_gettext_poison(void)
+{
+ static int poison_requested = -1;
+ if (poison_requested == -1)
+ poison_requested = getenv("GIT_GETTEXT_POISON") ? 1 : 0;
+ return poison_requested;
+}
static inline FORMAT_PRESERVING(1) const char *_(const char *msgid)
{
diff --git a/po/README b/po/README
index c1520e8..e25752b 100644
--- a/po/README
+++ b/po/README
@@ -270,16 +270,11 @@ something in the test suite might still depend on the US English
version of the strings, e.g. to grep some error message or other
output.
-To smoke out issues like these Git can be compiled with gettext poison
-support, at the top-level:
+To smoke out issues like these you should run the test suite with
+gettext poison support, which emits gibberish on every call to
+gettext:
- make GETTEXT_POISON=YesPlease
-
-That'll give you a git which emits gibberish on every call to
-gettext. It's obviously not meant to be installed, but you should run
-the test suite with it:
-
- cd t && prove -j 9 ./t[0-9]*.sh
+ cd t && GETTEXT_POISON=YesPlease prove -j 9 ./t[0-9]*.sh
If tests break with it you should inspect them manually and see if
what you're translating is sane, i.e. that you're not translating
--
1.7.12.rc2
next reply other threads:[~2012-08-21 4:39 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-21 4:39 Nguyễn Thái Ngọc Duy [this message]
2012-08-21 5:24 ` [PATCH] Build in gettext poison feature unconditionally Jonathan Nieder
2012-08-21 16:37 ` Junio C Hamano
2012-08-22 5:27 ` [PATCH] Support generate poison .mo files for testing Nguyễn Thái Ngọc Duy
2012-08-22 11:13 ` Junio C Hamano
2012-08-22 12:37 ` Nguyen Thai Ngoc Duy
2012-08-22 16:22 ` Junio C Hamano
2012-08-23 10:53 ` Nguyen Thai Ngoc Duy
2012-08-22 16:43 ` Junio C Hamano
2012-08-23 11:00 ` Nguyen Thai Ngoc Duy
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1345523970-14914-1-git-send-email-pclouds@gmail.com \
--to=pclouds@gmail.com \
--cc=avarab@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jrnieder@gmail.com \
/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.
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 NNTP newsgroup(s).