Skip to contentSkip to conversation

test-lib: whitelist GIT_TR2_* in the environment

PATCH In review Ævar Arnfjörð Bjarmason 2 participants 2 messages Mar 30, 2019 – Apr 10, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 test-lib: whitelist GIT_TR2_* in the environment

Add GIT_TR2_* to the whitelist of environment variables that we don't clear when running the test suite.

This allows us to use the test suite to produce trace2 test data, which is handy to e.g. write consumers that collate the trace data itself.

One caveat here is that we produce trace output for not *just* the tests, but also e.g. from this line in test-lib.sh:

    # It appears that people try to run tests without building...
    "${GIT_TEST_INSTALLED:-$GIT_BUILD_DIR}/git$X" >/dev/null
    [...]

I consider this not just OK but a feature. Let's log *all* the git commands we're going to execute, not just those within test_expect_*().

---
 t/test-lib.sh | 1 +
 1 file changed, 1 insertion(+)
t/test-lib.sh +1 -0
index 562c57e685..f6318c54c9 100644
@@ -379,6 +379,7 @@ unset VISUAL EMAIL LANGUAGE COLUMNS $("$PERL_PATH" -e '
 	my @env = keys %ENV;
 	my $ok = join("|", qw(
 		TRACE
+		TR2_
 		DEBUG
 		TEST
 		.*_TEST
Signature · 1 line
2.21.0.392.gf8f6787159e
#1 lore raw
Quoted 29 lines · Ævar Arnfjörð Bjarmason

Add GIT_TR2_* to the whitelist of environment variables that we don't clear when running the test suite.

This allows us to use the test suite to produce trace2 test data, which is handy to e.g. write consumers that collate the trace data itself.

One caveat here is that we produce trace output for not *just* the tests, but also e.g. from this line in test-lib.sh:

     # It appears that people try to run tests without building...
     "${GIT_TEST_INSTALLED:-$GIT_BUILD_DIR}/git$X" >/dev/null
     [...]

I consider this not just OK but a feature. Let's log *all* the git commands we're going to execute, not just those within test_expect_*().

---
  t/test-lib.sh | 1 +
  1 file changed, 1 insertion(+)
t/test-lib.sh +0 -0
index 562c57e685..f6318c54c9 100644

t/test-lib.sh unset VISUAL EMAIL LANGUAGE COLUMNS $("$PERL_PATH" -e ' · line 385

Quoted 7 lines
t/test-lib.sh +1 -0
@@ -379,6 +379,7 @@ unset VISUAL EMAIL LANGUAGE COLUMNS $("$PERL_PATH" -e '
  	my @env = keys %ENV;
  	my $ok = join("|", qw(
  		TRACE
+		TR2_
  		DEBUG
  		TEST
  		.*_TEST

I could go either way on this one. It would be nice to have telemetry for all of the commands run by the suite (and especially for perf tests) for our developer analysis purposes. But if your settings have you route that data to a DB, your DBA might not be happy with you....

Jeff