git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2] test-lib: unset trace2 parent envvars

From
Josh Steadmon <steadmon@google.com>
Date
Jan 26, 2022, 22:10 UTC
Message-ID
<2b5e573c22f226cbdb07d931d470a37bca7ffe2b.1643234866.git.steadmon@google.com>
In-Reply-To
<82e51a52e20fbe13a5a898a0a2f6dbe1188e3fa3.1642116539.git.steadmon@google.com>

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
Previous: Taylor BlauNext: Ævar Arnfjörð Bjarmason
Message 7 of 10 in “test-lib: unset trace2 parent envvars”
  1. test-lib: unset trace2 parent envvarsJosh Steadmon, Jan 14, 2022
  2. Junio C HamanoJan 14, 2022
  3. Josh SteadmonJan 18, 2022
  4. Junio C HamanoJan 18, 2022
  5. Josh SteadmonJan 26, 2022
  6. Taylor BlauJan 18, 2022
  7. test-lib: unset trace2 parent envvarsJosh Steadmon, Jan 26, 2022
  8. Ævar Arnfjörð BjarmasonJan 27, 2022
  9. Junio C HamanoJan 27, 2022
  10. Josh SteadmonFeb 1, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.