git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: "SZEDER Gábor" <szeder.dev@gmail.com>
Cc: git@vger.kernel.org, "Junio C Hamano" <gitster@pobox.com>,
	"Jeff King" <peff@peff.net>,
	"Vasco Almeida" <vascomalmeida@sapo.pt>,
	"Jiang Xin" <worldhello.net@gmail.com>,
	"Johannes Schindelin" <Johannes.Schindelin@gmx.de>,
	"Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: Re: [PATCH v3] i18n: make GETTEXT_POISON a runtime option
Date: Thu, 08 Nov 2018 21:26:19 +0100	[thread overview]
Message-ID: <87muqj5n9w.fsf@evledraar.gmail.com> (raw)
In-Reply-To: <20181102163725.GY30222@szeder.dev>


On Fri, Nov 02 2018, SZEDER Gábor wrote:

> On Thu, Nov 01, 2018 at 07:31:15PM +0000, Ævar Arnfjörð Bjarmason wrote:
>> Change the GETTEXT_POISON compile-time + runtime GIT_GETTEXT_POISON
>> test parameter to only be a GIT_TEST_GETTEXT_POISON=<non-empty?>
>> runtime parameter, to be consistent with other parameters documented
>> in "Running tests with special setups" in t/README.
>>
>> When I added GETTEXT_POISON in bb946bba76 ("i18n: add GETTEXT_POISON
>> to simulate unfriendly translator", 2011-02-22) I was concerned with
>> ensuring that the _() function would get constant folded if NO_GETTEXT
>> was defined, and likewise that GETTEXT_POISON would be compiled out
>> unless it was defined.
>>
>> But as the benchmark in my [1] shows doing a one-off runtime
>> getenv("GIT_TEST_[...]") is trivial, and since GETTEXT_POISON was
>> originally added the GIT_TEST_* env variables have become the common
>> idiom for turning on special test setups.
>>
>> So change GETTEXT_POISON to work the same way. Now the
>> GETTEXT_POISON=YesPlease compile-time option is gone, and running the
>> tests with GIT_TEST_GETTEXT_POISON=[YesPlease|] can be toggled on/off
>> without recompiling.
>>
>> This allows for conditionally amending tests to test with/without
>> poison, similar to what 859fdc0c3c ("commit-graph: define
>> GIT_TEST_COMMIT_GRAPH", 2018-08-29) did for GIT_TEST_COMMIT_GRAPH. Do
>> some of that, now we e.g. always run the t0205-gettext-poison.sh test.
>>
>> I did enough there to remove the GETTEXT_POISON prerequisite, but its
>> inverse C_LOCALE_OUTPUT is still around, and surely some tests using
>> it can be converted to e.g. always set GIT_TEST_GETTEXT_POISON=.
>>
>> Notes on the implementation:
>>
>>  * We still compile a dedicated GETTEXT_POISON build in Travis CI.
>>    This is probably the wrong thing to do and should be followed-up
>>    with something similar to ae59a4e44f ("travis: run tests with
>>    GIT_TEST_SPLIT_INDEX", 2018-01-07) to re-use an existing test setup
>>    for running in the GIT_TEST_GETTEXT_POISON mode.
>
> I'm of two minds about this.  Sure, now it's not a compile time
> option, so we can spare a dedicated compilation, and sparing resources
> is good, of course.
>
> However, checking test failures in the 'linux-gcc' build job is always
> a bit of a hassle, because it's not enough to look at the output of
> the failed test, but I also have to check which one of the two test
> runs failed (i.e. the "regular" or one with all the GIT_TEST_* knobs
> turned on).  Adding a second test run with GIT_TEST_GETTEXT_POISON
> enabled to an other build job (e.g. 'linux-clang') would then bring
> this hassle to that build job as well.
>
> Furthermore, occasionally a build job is slower than usual (whatever
> the reason might be), which can be an issue when running the test
> suite twice, as it can exceed the time limit.
>
> Anyway, we can think about this later.
>
> In any case, GIT_TEST_GETTEXT_POISON definitely should not be enabled
> in the same "catch-all" test run with all other GIT_TEST_* variables,
> because it would mess up any translated error messages that might pop
> up in a test failure, and then we wouldn't have any idea about what
> went wrong.

Will clarify this in v3. I.e. "let's think about this...".

>>  * We now skip a test in t0000-basic.sh under
>>    GIT_TEST_GETTEXT_POISON=YesPlease that wasn't skipped before. This
>>    test relies on C locale output, but due to an edge case in how the
>>    previous implementation of GETTEXT_POISON worked (reading it from
>>    GIT-BUILD-OPTIONS) wasn't enabling poison correctly. Now it does,
>>    and needs to be skipped.
>>
>>  * The getenv() function is not reentrant, so out of paranoia about
>>    code of the form:
>>
>>        printf(_("%s"), getenv("some-env"));
>>
>>    call use_gettext_poison() in our early setup in git_setup_gettext()
>>    so we populate the "poison_requested" variable in a codepath that's
>>    won't suffer from that race condition.
>>
>> See also [3] for more on the motivation behind this patch, and the
>> history of the GETTEXT_POISON facility.
>>
>> 1. https://public-inbox.org/git/871s8gd32p.fsf@evledraar.gmail.com/
>> 2. https://public-inbox.org/git/87woq7b58k.fsf@evledraar.gmail.com/
>> 3. https://public-inbox.org/git/878t2pd6yu.fsf@evledraar.gmail.com/
>>
>> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
>> ---
>>
>> Now:
>>
>>  * The new i18n helper is gone. We just use "test -n" semantics for
>>    $GIT_TEST_GETTEXT_POISON
>>
>>  * We error out in the Makefile if you're still saying
>>    GETTEXT_POISON=YesPlease.
>>
>>    This makes more sense than just making it a synonym since now this
>>    also needs to be defined at runtime.
>
> OK, I think erroring out is better than silently ignoring
> GETTEXT_POISON=YesPlease.  However, the commit message only mentions
> that GETTEXT_POISON is gone, but perhaps this should be mentioned
> there as well.

Will mention.

>>  * The caveat with avoiding test_lazy_prereq is gone (although there's
>>    still some unrelated bug there worth looking into).
>>
>>  * We call use_gettext_poison() really early to avoid any reentrancy
>>    issue with getenv().
>
>> diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh
>> index 175f83d704..3c6b185b60 100755
>> --- a/t/t9902-completion.sh
>> +++ b/t/t9902-completion.sh
>> @@ -1697,7 +1697,8 @@ test_expect_success 'sourcing the completion script clears cached commands' '
>>  	verbose test -z "$__git_all_commands"
>>  '
>>
>> -test_expect_success !GETTEXT_POISON 'sourcing the completion script clears cached merge strategies' '
>> +test_expect_success 'sourcing the completion script clears cached merge strategies' '
>> +	GIT_TEST_GETTEXT_POISON= &&
>>  	__git_compute_merge_strategies &&
>
> OK, makes sense.
>
>>  	verbose test -n "$__git_merge_strategies" &&
>>  	. "$GIT_BUILD_DIR/contrib/completion/git-completion.bash" &&
>
>> diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
>> index 78d8c3783b..2f42b3653c 100644
>> --- a/t/test-lib-functions.sh
>> +++ b/t/test-lib-functions.sh
>> @@ -755,16 +755,16 @@ test_cmp_bin() {
>>
>>  # Use this instead of test_cmp to compare files that contain expected and
>>  # actual output from git commands that can be translated.  When running
>> -# under GETTEXT_POISON this pretends that the command produced expected
>> +# under GIT_TEST_GETTEXT_POISON this pretends that the command produced expected
>>  # results.
>>  test_i18ncmp () {
>> -	test -n "$GETTEXT_POISON" || test_cmp "$@"
>> +	! test_have_prereq C_LOCALE_OUTPUT || test_cmp "$@"
>>  }
>
>>  test_i18ngrep () {
>>  	eval "last_arg=\${$#}"
>> @@ -779,7 +779,7 @@ test_i18ngrep () {
>>  		error "bug in the test script: too few parameters to test_i18ngrep"
>>  	fi
>>
>> -	if test -n "$GETTEXT_POISON"
>> +	if test_have_prereq !C_LOCALE_OUTPUT
>
> Why do these two helper functions call test_have_prereq (a function
> that doesn't even fit on my screen) instead of a simple
>
>   test -n "$GIT_TEST_GETTEXT_POISON"

I'm going to keep the call to test_have_prereq, it's consistent with
other use of the helper in the test lib, and doesn't confuse the reader
by giving the impression that we're in some really early setup where we
haven't set the prereq at this point (we have).

>>  	then
>>  		# pretend success
>>  		return 0
>> diff --git a/t/test-lib.sh b/t/test-lib.sh
>> index 897e6fcc94..370a4821e1 100644
>> --- a/t/test-lib.sh
>> +++ b/t/test-lib.sh
>> @@ -1105,12 +1105,8 @@ test -n "$USE_LIBPCRE2" && test_set_prereq LIBPCRE2
>>  test -z "$NO_GETTEXT" && test_set_prereq GETTEXT
>>
>>  # Can we rely on git's output in the C locale?
>> -if test -n "$GETTEXT_POISON"
>> +if test -z "$GIT_TEST_GETTEXT_POISON"
>>  then
>> -	GIT_GETTEXT_POISON=YesPlease
>> -	export GIT_GETTEXT_POISON
>> -	test_set_prereq GETTEXT_POISON
>> -else
>>  	test_set_prereq C_LOCALE_OUTPUT
>>  fi
>
> GIT_TEST_GETTEXT_POISON=1 will influence even those git commands that
> are executed during initialization of test-lib and the test repo:
>
>   $ GIT_TEST_GETTEXT_POISON=1 ./t0000-basic.sh -v
>   # GETTEXT POISON #expecting success:
>   <....>
>
> It should say:
>
>   Initialized empty Git repository in <... path ...>
>   expecting success:
>
> See https://public-inbox.org/git/20181022202241.18629-2-szeder.dev@gmail.com/
> for a bit of code that you might find worthy to steal.

Thanks. Fixing.

  reply	other threads:[~2018-11-08 20:26 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-22 15:36 [PATCH] Poison gettext with the Ook language Nguyễn Thái Ngọc Duy
2018-10-22 20:22 ` SZEDER Gábor
2018-10-22 20:22   ` [PATCH 1/8] test-lib.sh: preserve GIT_GETTEXT_POISON from the environment SZEDER Gábor
2018-10-22 20:22   ` [PATCH 2/8] gettext: don't poison if GIT_GETTEXT_POISON is set but empty SZEDER Gábor
2018-10-22 20:38     ` Ævar Arnfjörð Bjarmason
2018-10-22 20:22   ` [PATCH 3/8] lib-rebase: loosen GETTEXT_POISON check in fake editor SZEDER Gábor
2018-10-22 20:22   ` [PATCH 4/8] gettext: #ifdef away GETTEXT POISON-related code from _() and Q_() SZEDER Gábor
2018-10-22 20:22   ` [PATCH 5/8] gettext: put "# GETTEXT POISON #" string literal into a macro SZEDER Gábor
2018-10-22 20:22   ` [PATCH 6/8] gettext: use an enum for the mode of GETTEXT POISONing SZEDER Gábor
2018-10-22 20:22   ` [PATCH 7/8] gettext: introduce GIT_GETTEXT_POISON=scrambled SZEDER Gábor
2018-10-23 14:44     ` Duy Nguyen
2018-10-22 20:22   ` [PATCH 8/8] travis-ci: run GETTEXT POISON build job in scrambled mode, too SZEDER Gábor
2018-10-23 14:37   ` [PATCH] Poison gettext with the Ook language Duy Nguyen
2018-10-27 10:11   ` Jakub Narebski
2018-10-22 20:52 ` Johannes Schindelin
2018-10-22 21:09 ` Ævar Arnfjörð Bjarmason
2018-10-22 21:46   ` Ævar Arnfjörð Bjarmason
2018-10-22 23:04   ` Junio C Hamano
2018-10-23 21:01     ` [PATCH] i18n: make GETTEXT_POISON a runtime option Ævar Arnfjörð Bjarmason
2018-10-24  5:45       ` Junio C Hamano
2018-10-24  7:44         ` Jeff King
2018-10-25  1:00           ` Junio C Hamano
2018-10-25  1:09             ` Jeff King
2018-10-25  1:24               ` Ramsay Jones
2018-10-25 21:23                 ` Jeff King
2018-10-26 19:20                   ` Ævar Arnfjörð Bjarmason
2018-10-27  6:59                     ` Jeff King
2018-10-27 10:42                       ` Ævar Arnfjörð Bjarmason
2018-10-24 11:47         ` [PATCH v2] " Ævar Arnfjörð Bjarmason
2018-11-01 19:31           ` [PATCH v3] " Ævar Arnfjörð Bjarmason
2018-11-02  3:11             ` Junio C Hamano
2018-11-02 16:37             ` SZEDER Gábor
2018-11-08 20:26               ` Ævar Arnfjörð Bjarmason [this message]
2018-11-08 20:51                 ` SZEDER Gábor
2018-11-08  3:24             ` Junio C Hamano
2018-11-08 19:12               ` Eric Sunshine
2018-11-08 21:15             ` [PATCH v4 0/2] " Ævar Arnfjörð Bjarmason
2018-11-08 21:15             ` [PATCH v4 1/2] " Ævar Arnfjörð Bjarmason
2018-11-08 21:15             ` [PATCH v4 2/2] Makefile: ease dynamic-gettext-poison transition Ævar Arnfjörð Bjarmason
2018-10-23  9:30   ` [PATCH] Poison gettext with the Ook language Johannes Schindelin
2018-10-23 10:17     ` Ævar Arnfjörð Bjarmason
2018-10-23 11:07       ` Johannes Schindelin
2018-10-23 15:00       ` Duy Nguyen
2018-10-23 16:45         ` Ævar Arnfjörð Bjarmason
2018-10-24 14:41           ` Duy Nguyen
2018-10-24 17:54             ` Ævar Arnfjörð Bjarmason
2018-10-25  3:52             ` Junio C Hamano
2018-10-25  6:20               ` Jeff King
2018-10-27  6:55                 ` 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=87muqj5n9w.fsf@evledraar.gmail.com \
    --to=avarab@gmail.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=pclouds@gmail.com \
    --cc=peff@peff.net \
    --cc=szeder.dev@gmail.com \
    --cc=vascomalmeida@sapo.pt \
    --cc=worldhello.net@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.
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).