git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] test-lib: unset trace2 parent envvars
@ 2022-01-14  3:33 Josh Steadmon
  2022-01-14  6:01 ` Junio C Hamano
  2022-01-26 22:10 ` [PATCH v2] " Josh Steadmon
  0 siblings, 2 replies; 10+ messages in thread
From: Josh Steadmon @ 2022-01-14  3:33 UTC (permalink / raw)
  To: git

The trace2 subsystem can inherit certain information from parent
processes via environment variables; e.g., the parent command name and
session ID. This allows trace2 to note when a command is the child
process of another Git process, and to adjust various pieces of output
accordingly.

This behavior breaks certain tests that examine trace2 output when the
tests run as a child of another git process, such as in `git rebase -x
"make test"`.

While we could fix this by unsetting the relevant variables in the
affected tests (currently t0210, t0211, t0212, and t6421), this would
leave other tests vulnerable to similar breakage if new test cases are
added which inspect trace2 output. So fix this in general by unsetting
GIT_TRACE2_PARENT_NAME and GIT_TRACE2_PARENT_SID in test-lib.sh.

Reported-by: Emily Shaffer <emilyshaffer@google.com>
Helped-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Josh Steadmon <steadmon@google.com>
---
 t/test-lib.sh | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/t/test-lib.sh b/t/test-lib.sh
index 0f7a137c7d..e4716b0b86 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -449,6 +449,8 @@ unset VISUAL EMAIL LANGUAGE $("$PERL_PATH" -e '
 unset XDG_CACHE_HOME
 unset XDG_CONFIG_HOME
 unset GITPERLLIB
+unset GIT_TRACE2_PARENT_NAME
+unset GIT_TRACE2_PARENT_SID
 TEST_AUTHOR_LOCALNAME=author
 TEST_AUTHOR_DOMAIN=example.com
 GIT_AUTHOR_EMAIL=${TEST_AUTHOR_LOCALNAME}@${TEST_AUTHOR_DOMAIN}

base-commit: dcc0cd074f0c639a0df20461a301af6d45bd582e
-- 
2.34.1.703.g22d0c6ccf7-goog


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH] test-lib: unset trace2 parent envvars
  2022-01-14  3:33 [PATCH] test-lib: unset trace2 parent envvars Josh Steadmon
@ 2022-01-14  6:01 ` Junio C Hamano
  2022-01-18 21:23   ` Josh Steadmon
  2022-01-18 21:29   ` Taylor Blau
  2022-01-26 22:10 ` [PATCH v2] " Josh Steadmon
  1 sibling, 2 replies; 10+ messages in thread
From: Junio C Hamano @ 2022-01-14  6:01 UTC (permalink / raw)
  To: Josh Steadmon, Jeff Hostetler; +Cc: git

Josh Steadmon <steadmon@google.com> writes:

> This behavior breaks certain tests that examine trace2 output when the
> tests run as a child of another git process, such as in `git rebase -x
> "make test"`.

Well explained.  The paragraph makes it clear how easy to trigger
and get bitten by this problem.

> While we could fix this by unsetting the relevant variables in the
> affected tests (currently t0210, t0211, t0212, and t6421), this would
> leave other tests vulnerable to similar breakage if new test cases are
> added which inspect trace2 output. So fix this in general by unsetting
> GIT_TRACE2_PARENT_NAME and GIT_TRACE2_PARENT_SID in test-lib.sh.

This probably makes sense, but I wonder how it interacts with a user
who runs "cd t && GIT_TRACE2=blah ./t0987-test-this.sh" to trace the
entire test script, though.

> Reported-by: Emily Shaffer <emilyshaffer@google.com>
> Helped-by: Jonathan Tan <jonathantanmy@google.com>
> Signed-off-by: Josh Steadmon <steadmon@google.com>
> ---
>  t/test-lib.sh | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/t/test-lib.sh b/t/test-lib.sh
> index 0f7a137c7d..e4716b0b86 100644
> --- a/t/test-lib.sh
> +++ b/t/test-lib.sh
> @@ -449,6 +449,8 @@ unset VISUAL EMAIL LANGUAGE $("$PERL_PATH" -e '
>  unset XDG_CACHE_HOME
>  unset XDG_CONFIG_HOME
>  unset GITPERLLIB
> +unset GIT_TRACE2_PARENT_NAME
> +unset GIT_TRACE2_PARENT_SID

Hmph.  Have you noticed the more generic "We want to unset almost
everything that begins with GIT_, other than those selected few that
are designed to be used to affect the tests" above the part you
touched?

I am wondering if we should tweak the list there, instead of special
casing these two and these two only. There is a pattern that allows
anything that match "^GIT_(other|TRACE|things)", and I suspect that
the pattern is way too loose (i.e. it allows any garbage to follow,
and by allowing "TRACE", it also catches "TRACE2" because the former
is a prefix of the latter), which is a problem.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] test-lib: unset trace2 parent envvars
  2022-01-14  6:01 ` Junio C Hamano
@ 2022-01-18 21:23   ` Josh Steadmon
  2022-01-18 21:50     ` Junio C Hamano
  2022-01-18 21:29   ` Taylor Blau
  1 sibling, 1 reply; 10+ messages in thread
From: Josh Steadmon @ 2022-01-18 21:23 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Jeff Hostetler, git

On 2022.01.13 22:01, Junio C Hamano wrote:
> Josh Steadmon <steadmon@google.com> writes:
> 
> > This behavior breaks certain tests that examine trace2 output when the
> > tests run as a child of another git process, such as in `git rebase -x
> > "make test"`.
> 
> Well explained.  The paragraph makes it clear how easy to trigger
> and get bitten by this problem.
> 
> > While we could fix this by unsetting the relevant variables in the
> > affected tests (currently t0210, t0211, t0212, and t6421), this would
> > leave other tests vulnerable to similar breakage if new test cases are
> > added which inspect trace2 output. So fix this in general by unsetting
> > GIT_TRACE2_PARENT_NAME and GIT_TRACE2_PARENT_SID in test-lib.sh.
> 
> This probably makes sense, but I wonder how it interacts with a user
> who runs "cd t && GIT_TRACE2=blah ./t0987-test-this.sh" to trace the
> entire test script, though.

There shouldn't be any problems with this specific use case. I don't see
a valid reason for a test runner to fake GIT_TRACE2_PARENT_{NAME,SID}
though. None of the TRACE2 modes require using any of the PARENT
variables.


> > Reported-by: Emily Shaffer <emilyshaffer@google.com>
> > Helped-by: Jonathan Tan <jonathantanmy@google.com>
> > Signed-off-by: Josh Steadmon <steadmon@google.com>
> > ---
> >  t/test-lib.sh | 2 ++
> >  1 file changed, 2 insertions(+)
> >
> > diff --git a/t/test-lib.sh b/t/test-lib.sh
> > index 0f7a137c7d..e4716b0b86 100644
> > --- a/t/test-lib.sh
> > +++ b/t/test-lib.sh
> > @@ -449,6 +449,8 @@ unset VISUAL EMAIL LANGUAGE $("$PERL_PATH" -e '
> >  unset XDG_CACHE_HOME
> >  unset XDG_CONFIG_HOME
> >  unset GITPERLLIB
> > +unset GIT_TRACE2_PARENT_NAME
> > +unset GIT_TRACE2_PARENT_SID
> 
> Hmph.  Have you noticed the more generic "We want to unset almost
> everything that begins with GIT_, other than those selected few that
> are designed to be used to affect the tests" above the part you
> touched?
> 
> I am wondering if we should tweak the list there, instead of special
> casing these two and these two only. There is a pattern that allows
> anything that match "^GIT_(other|TRACE|things)", and I suspect that
> the pattern is way too loose (i.e. it allows any garbage to follow,
> and by allowing "TRACE", it also catches "TRACE2" because the former
> is a prefix of the latter), which is a problem.

Yes, due to the number of different TRACE2 modes, I figured it was
cleaner to allow them by default and then explicitly unset the ones that
cause trouble for trace parsing tests. But if you prefer to lock down
the list, I can send an alternate fix.


Thanks,
Josh

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] test-lib: unset trace2 parent envvars
  2022-01-14  6:01 ` Junio C Hamano
  2022-01-18 21:23   ` Josh Steadmon
@ 2022-01-18 21:29   ` Taylor Blau
  1 sibling, 0 replies; 10+ messages in thread
From: Taylor Blau @ 2022-01-18 21:29 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Josh Steadmon, Jeff Hostetler, git

On Thu, Jan 13, 2022 at 10:01:07PM -0800, Junio C Hamano wrote:
> Josh Steadmon <steadmon@google.com> writes:
>
> > This behavior breaks certain tests that examine trace2 output when the
> > tests run as a child of another git process, such as in `git rebase -x
> > "make test"`.
>
> Well explained.  The paragraph makes it clear how easy to trigger
> and get bitten by this problem.
>
> > While we could fix this by unsetting the relevant variables in the
> > affected tests (currently t0210, t0211, t0212, and t6421), this would
> > leave other tests vulnerable to similar breakage if new test cases are
> > added which inspect trace2 output. So fix this in general by unsetting
> > GIT_TRACE2_PARENT_NAME and GIT_TRACE2_PARENT_SID in test-lib.sh.
>
> This probably makes sense, but I wonder how it interacts with a user
> who runs "cd t && GIT_TRACE2=blah ./t0987-test-this.sh" to trace the
> entire test script, though.
>
> > Reported-by: Emily Shaffer <emilyshaffer@google.com>
> > Helped-by: Jonathan Tan <jonathantanmy@google.com>
> > Signed-off-by: Josh Steadmon <steadmon@google.com>
> > ---
> >  t/test-lib.sh | 2 ++
> >  1 file changed, 2 insertions(+)
> >
> > diff --git a/t/test-lib.sh b/t/test-lib.sh
> > index 0f7a137c7d..e4716b0b86 100644
> > --- a/t/test-lib.sh
> > +++ b/t/test-lib.sh
> > @@ -449,6 +449,8 @@ unset VISUAL EMAIL LANGUAGE $("$PERL_PATH" -e '
> >  unset XDG_CACHE_HOME
> >  unset XDG_CONFIG_HOME
> >  unset GITPERLLIB
> > +unset GIT_TRACE2_PARENT_NAME
> > +unset GIT_TRACE2_PARENT_SID
>
> Hmph.  Have you noticed the more generic "We want to unset almost
> everything that begins with GIT_, other than those selected few that
> are designed to be used to affect the tests" above the part you
> touched?
>
> I am wondering if we should tweak the list there, instead of special
> casing these two and these two only. There is a pattern that allows
> anything that match "^GIT_(other|TRACE|things)", and I suspect that
> the pattern is way too loose (i.e. it allows any garbage to follow,
> and by allowing "TRACE", it also catches "TRACE2" because the former
> is a prefix of the latter), which is a problem.

I was thinking the same thing, but I suspect that this may truly be
different. That list says we should be able to keep anything that looks
like GIT_TRACE in our environment. So the same should be true of
TRACE2-related variables, I'd think.

But the PARENT_NAME and PARENT_SID variables are (as far as I can tell
from reading around) internal variables that help us piece together the
names of the Git commands we ran.

In other words, excluding all TRACE2 variables goes too far since it
prevents us from being able to `GIT_TRACE2=1 make test`. But we would
want to clear out any internal TRACE2 variables such as PARENT_NAME and
PARENT_SID.

Thanks,
Taylor

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] test-lib: unset trace2 parent envvars
  2022-01-18 21:23   ` Josh Steadmon
@ 2022-01-18 21:50     ` Junio C Hamano
  2022-01-26 22:11       ` Josh Steadmon
  0 siblings, 1 reply; 10+ messages in thread
From: Junio C Hamano @ 2022-01-18 21:50 UTC (permalink / raw)
  To: Josh Steadmon; +Cc: Jeff Hostetler, git

Josh Steadmon <steadmon@google.com> writes:

> Yes, due to the number of different TRACE2 modes, I figured it was
> cleaner to allow them by default and then explicitly unset the ones that
> cause trouble for trace parsing tests.

I think I would agree that it is a better solution, and the design
behind it (which makes me say it is better) should be recorded in
the log message (and possibly in-code comment near the place we
reset them) to help future developers who may add more TRACE2
variables.

Thanks.




^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v2] test-lib: unset trace2 parent envvars
  2022-01-14  3:33 [PATCH] test-lib: unset trace2 parent envvars Josh Steadmon
  2022-01-14  6:01 ` Junio C Hamano
@ 2022-01-26 22:10 ` Josh Steadmon
  2022-01-27  3:23   ` Ævar Arnfjörð Bjarmason
  1 sibling, 1 reply; 10+ messages in thread
From: Josh Steadmon @ 2022-01-26 22:10 UTC (permalink / raw)
  To: git; +Cc: gitster, me, jeffhost

The trace2 subsystem can inherit certain information from parent
processes via environment variables; e.g., the parent command name and
session ID. This allows trace2 to note when a command is the child
process of another Git process, and to adjust various pieces of output
accordingly.

This behavior breaks certain tests that examine trace2 output when the
tests run as a child of another git process, such as in `git rebase -x
"make test"`.

While we could fix this by unsetting the relevant variables in the
affected tests (currently t0210, t0211, t0212, and t6421), this would
leave other tests vulnerable to similar breakage if new test cases are
added which inspect trace2 output.

In t/test-lib.sh, we keep a pattern of permitted GIT_* environment
variables. Variables matching /^GIT_TRACE.*/ are currently allowed via
this pattern. We want to preserve this behavior, because it can be
useful to collect trace output over the entire test suite. Instead of
modifying the allow-pattern, we instead fix this issue by unsetting only
the GIT_TRACE2_PARENT_NAME and GIT_TRACE2_PARENT_SID in t/test-lib.sh.

Reported-by: Emily Shaffer <emilyshaffer@google.com>
Signed-off-by: Josh Steadmon <steadmon@google.com>
---
Updated commit message and added code comments to explain why we keep
"TRACE" in the allow pattern.

 t/test-lib.sh | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/t/test-lib.sh b/t/test-lib.sh
index 0f7a137c7d..faf25ba1b2 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -432,7 +432,7 @@ EDITOR=:
 unset VISUAL EMAIL LANGUAGE $("$PERL_PATH" -e '
 	my @env = keys %ENV;
 	my $ok = join("|", qw(
-		TRACE
+		TRACE	# Allow tracing in general, but see unsets below.
 		DEBUG
 		TEST
 		.*_TEST
@@ -449,6 +449,10 @@ unset VISUAL EMAIL LANGUAGE $("$PERL_PATH" -e '
 unset XDG_CACHE_HOME
 unset XDG_CONFIG_HOME
 unset GITPERLLIB
+# Unset trace environment variables that can interfere with trace output used in
+# certain tests.
+unset GIT_TRACE2_PARENT_NAME
+unset GIT_TRACE2_PARENT_SID
 TEST_AUTHOR_LOCALNAME=author
 TEST_AUTHOR_DOMAIN=example.com
 GIT_AUTHOR_EMAIL=${TEST_AUTHOR_LOCALNAME}@${TEST_AUTHOR_DOMAIN}

base-commit: dcc0cd074f0c639a0df20461a301af6d45bd582e
-- 
2.35.0.rc0.227.g00780c9af4-goog


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH] test-lib: unset trace2 parent envvars
  2022-01-18 21:50     ` Junio C Hamano
@ 2022-01-26 22:11       ` Josh Steadmon
  0 siblings, 0 replies; 10+ messages in thread
From: Josh Steadmon @ 2022-01-26 22:11 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Jeff Hostetler, git

On 2022.01.18 13:50, Junio C Hamano wrote:
> Josh Steadmon <steadmon@google.com> writes:
> 
> > Yes, due to the number of different TRACE2 modes, I figured it was
> > cleaner to allow them by default and then explicitly unset the ones that
> > cause trouble for trace parsing tests.
> 
> I think I would agree that it is a better solution, and the design
> behind it (which makes me say it is better) should be recorded in
> the log message (and possibly in-code comment near the place we
> reset them) to help future developers who may add more TRACE2
> variables.
> 
> Thanks.

Fixed in V2. Thanks!

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2] test-lib: unset trace2 parent envvars
  2022-01-26 22:10 ` [PATCH v2] " Josh Steadmon
@ 2022-01-27  3:23   ` Ævar Arnfjörð Bjarmason
  2022-01-27 18:29     ` Junio C Hamano
  2022-02-01 21:22     ` Josh Steadmon
  0 siblings, 2 replies; 10+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2022-01-27  3:23 UTC (permalink / raw)
  To: Josh Steadmon; +Cc: git, gitster, me, jeffhost


On Wed, Jan 26 2022, Josh Steadmon wrote:

> The trace2 subsystem can inherit certain information from parent
> processes via environment variables; e.g., the parent command name and
> session ID. This allows trace2 to note when a command is the child
> process of another Git process, and to adjust various pieces of output
> accordingly.
>
> This behavior breaks certain tests that examine trace2 output when the
> tests run as a child of another git process, such as in `git rebase -x
> "make test"`.
>
> While we could fix this by unsetting the relevant variables in the
> affected tests (currently t0210, t0211, t0212, and t6421), this would
> leave other tests vulnerable to similar breakage if new test cases are
> added which inspect trace2 output.
>
> In t/test-lib.sh, we keep a pattern of permitted GIT_* environment
> variables. Variables matching /^GIT_TRACE.*/ are currently allowed via
> this pattern. We want to preserve this behavior, because it can be
> useful to collect trace output over the entire test suite. Instead of
> modifying the allow-pattern, we instead fix this issue by unsetting only
> the GIT_TRACE2_PARENT_NAME and GIT_TRACE2_PARENT_SID in t/test-lib.sh.
>
> Reported-by: Emily Shaffer <emilyshaffer@google.com>
> Signed-off-by: Josh Steadmon <steadmon@google.com>
> ---
> Updated commit message and added code comments to explain why we keep
> "TRACE" in the allow pattern.
>
>  t/test-lib.sh | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/t/test-lib.sh b/t/test-lib.sh
> index 0f7a137c7d..faf25ba1b2 100644
> --- a/t/test-lib.sh
> +++ b/t/test-lib.sh
> @@ -432,7 +432,7 @@ EDITOR=:
>  unset VISUAL EMAIL LANGUAGE $("$PERL_PATH" -e '
>  	my @env = keys %ENV;
>  	my $ok = join("|", qw(
> -		TRACE
> +		TRACE	# Allow tracing in general, but see unsets below.

I think it would be good to turn that -e into a -we, which would tell
you why this doesn't work the way you think:

    Possible attempt to put comments in qw() list at -e line 14.
    Possible attempt to separate words with commas at -e line 14.

I.e. you added one string "#" to the array, and a string "Allow" etc.

I think replacing it with this would be clearer, and means that...

diff --git a/t/test-lib.sh b/t/test-lib.sh
index 0f7a137c7d8..9a7611f412f 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -432,7 +432,7 @@ EDITOR=:
 unset VISUAL EMAIL LANGUAGE $("$PERL_PATH" -e '
 	my @env = keys %ENV;
 	my $ok = join("|", qw(
-		TRACE
+		TRACE(?!2_(?:PARENT_NAME|PARENT_SID)$)
 		DEBUG
 		TEST
 		.*_TEST


>  		DEBUG
>  		TEST
>  		.*_TEST
> @@ -449,6 +449,10 @@ unset VISUAL EMAIL LANGUAGE $("$PERL_PATH" -e '
>  unset XDG_CACHE_HOME
>  unset XDG_CONFIG_HOME
>  unset GITPERLLIB
> +# Unset trace environment variables that can interfere with trace output used in
> +# certain tests.
> +unset GIT_TRACE2_PARENT_NAME
> +unset GIT_TRACE2_PARENT_SID
>  TEST_AUTHOR_LOCALNAME=author
>  TEST_AUTHOR_DOMAIN=example.com
>  GIT_AUTHOR_EMAIL=${TEST_AUTHOR_LOCALNAME}@${TEST_AUTHOR_DOMAIN}
>
> base-commit: dcc0cd074f0c639a0df20461a301af6d45bd582e

...you won't need this hunk, since it'll be obvious that we're
specifically excluding those variables.

But more generally I think it's best to replace this with the below,
i.e. to also fold the nearby "unset" into this command which'll find
everything we need to unset for us, since it was doing most of the work
anyway.

diff --git a/t/test-lib.sh b/t/test-lib.sh
index 0f7a137c7d8..ff4d4a553be 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -426,13 +426,12 @@ export LANG LC_ALL PAGER TZ COLUMNS
 EDITOR=:
 
 # A call to "unset" with no arguments causes at least Solaris 10
-# /usr/xpg4/bin/sh and /bin/ksh to bail out.  So keep the unsets
-# deriving from the command substitution clustered with the other
-# ones.
-unset VISUAL EMAIL LANGUAGE $("$PERL_PATH" -e '
+# /usr/xpg4/bin/sh and /bin/ksh to bail out.  So we'll need at least
+# one unconditional variable here, which might as well be VISUAL.
+unset VISUAL $("$PERL_PATH" -we '
 	my @env = keys %ENV;
 	my $ok = join("|", qw(
-		TRACE
+		TRACE(?!2_(?:PARENT_NAME|PARENT_SID)$)
 		DEBUG
 		TEST
 		.*_TEST
@@ -444,11 +443,20 @@ unset VISUAL EMAIL LANGUAGE $("$PERL_PATH" -e '
 		TRACE_CURL
 	));
 	my @vars = grep(/^GIT_/ && !/^GIT_($ok)/o, @env);
+	my @nongit = qw(
+		CDPATH
+		EMAIL
+		GITPERLLIB
+		GREP_OPTIONS
+		LANGUAGE
+		UNZIP
+		XDG_CACHE_HOME
+		XDG_CONFIG_HOME
+	);
+	push @vars => grep { exists $ENV{$_} } @nongit;
 	print join("\n", @vars);
 ')
-unset XDG_CACHE_HOME
-unset XDG_CONFIG_HOME
-unset GITPERLLIB
+
 TEST_AUTHOR_LOCALNAME=author
 TEST_AUTHOR_DOMAIN=example.com
 GIT_AUTHOR_EMAIL=${TEST_AUTHOR_LOCALNAME}@${TEST_AUTHOR_DOMAIN}
@@ -524,13 +532,6 @@ else
 	}
 fi
 
-# Protect ourselves from common misconfiguration to export
-# CDPATH into the environment
-unset CDPATH
-
-unset GREP_OPTIONS
-unset UNZIP
-
 case $(echo $GIT_TRACE |tr "[A-Z]" "[a-z]") in
 1|2|true)
 	GIT_TRACE=4

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH v2] test-lib: unset trace2 parent envvars
  2022-01-27  3:23   ` Ævar Arnfjörð Bjarmason
@ 2022-01-27 18:29     ` Junio C Hamano
  2022-02-01 21:22     ` Josh Steadmon
  1 sibling, 0 replies; 10+ messages in thread
From: Junio C Hamano @ 2022-01-27 18:29 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason; +Cc: Josh Steadmon, git, me, jeffhost

Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:

>> diff --git a/t/test-lib.sh b/t/test-lib.sh
>> index 0f7a137c7d..faf25ba1b2 100644
>> --- a/t/test-lib.sh
>> +++ b/t/test-lib.sh
>> @@ -432,7 +432,7 @@ EDITOR=:
>>  unset VISUAL EMAIL LANGUAGE $("$PERL_PATH" -e '
>>  	my @env = keys %ENV;
>>  	my $ok = join("|", qw(
>> -		TRACE
>> +		TRACE	# Allow tracing in general, but see unsets below.
>
> I think it would be good to turn that -e into a -we, which would tell
> you why this doesn't work the way you think:
>
>     Possible attempt to put comments in qw() list at -e line 14.
>     Possible attempt to separate words with commas at -e line 14.
>
> I.e. you added one string "#" to the array, and a string "Allow" etc.

Having an expert who can spot these things at first glance is handy
;-).  Very much appreciated.

In any case, the previous iteration has been in 'next' long enough
without causing trouble for those who use a variant based on 'next'
at $DAYJOB, I presume, so my recommendation is to just let it
graduate first, and pursue your suggestion to do more things in this
scriptlet (below, omitted) as a "further improvement" on top.

Thanks.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2] test-lib: unset trace2 parent envvars
  2022-01-27  3:23   ` Ævar Arnfjörð Bjarmason
  2022-01-27 18:29     ` Junio C Hamano
@ 2022-02-01 21:22     ` Josh Steadmon
  1 sibling, 0 replies; 10+ messages in thread
From: Josh Steadmon @ 2022-02-01 21:22 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason; +Cc: git, gitster, me, jeffhost

On 2022.01.27 04:23, Ævar Arnfjörð Bjarmason wrote:
> 
> On Wed, Jan 26 2022, Josh Steadmon wrote:
> 
> > The trace2 subsystem can inherit certain information from parent
> > processes via environment variables; e.g., the parent command name and
> > session ID. This allows trace2 to note when a command is the child
> > process of another Git process, and to adjust various pieces of output
> > accordingly.
> >
> > This behavior breaks certain tests that examine trace2 output when the
> > tests run as a child of another git process, such as in `git rebase -x
> > "make test"`.
> >
> > While we could fix this by unsetting the relevant variables in the
> > affected tests (currently t0210, t0211, t0212, and t6421), this would
> > leave other tests vulnerable to similar breakage if new test cases are
> > added which inspect trace2 output.
> >
> > In t/test-lib.sh, we keep a pattern of permitted GIT_* environment
> > variables. Variables matching /^GIT_TRACE.*/ are currently allowed via
> > this pattern. We want to preserve this behavior, because it can be
> > useful to collect trace output over the entire test suite. Instead of
> > modifying the allow-pattern, we instead fix this issue by unsetting only
> > the GIT_TRACE2_PARENT_NAME and GIT_TRACE2_PARENT_SID in t/test-lib.sh.
> >
> > Reported-by: Emily Shaffer <emilyshaffer@google.com>
> > Signed-off-by: Josh Steadmon <steadmon@google.com>
> > ---
> > Updated commit message and added code comments to explain why we keep
> > "TRACE" in the allow pattern.
> >
> >  t/test-lib.sh | 6 +++++-
> >  1 file changed, 5 insertions(+), 1 deletion(-)
> >
> > diff --git a/t/test-lib.sh b/t/test-lib.sh
> > index 0f7a137c7d..faf25ba1b2 100644
> > --- a/t/test-lib.sh
> > +++ b/t/test-lib.sh
> > @@ -432,7 +432,7 @@ EDITOR=:
> >  unset VISUAL EMAIL LANGUAGE $("$PERL_PATH" -e '
> >  	my @env = keys %ENV;
> >  	my $ok = join("|", qw(
> > -		TRACE
> > +		TRACE	# Allow tracing in general, but see unsets below.
> 
> I think it would be good to turn that -e into a -we, which would tell
> you why this doesn't work the way you think:
> 
>     Possible attempt to put comments in qw() list at -e line 14.
>     Possible attempt to separate words with commas at -e line 14.
> 
> I.e. you added one string "#" to the array, and a string "Allow" etc.

Whoops, yeah, thanks for the catch. I've forgotten most of the Perl I
ever knew but should have seen that.

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-02-01 21:23 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-14  3:33 [PATCH] test-lib: unset trace2 parent envvars Josh Steadmon
2022-01-14  6:01 ` Junio C Hamano
2022-01-18 21:23   ` Josh Steadmon
2022-01-18 21:50     ` Junio C Hamano
2022-01-26 22:11       ` Josh Steadmon
2022-01-18 21:29   ` Taylor Blau
2022-01-26 22:10 ` [PATCH v2] " Josh Steadmon
2022-01-27  3:23   ` Ævar Arnfjörð Bjarmason
2022-01-27 18:29     ` Junio C Hamano
2022-02-01 21:22     ` Josh Steadmon

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).