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

[RFC/PATCH 2/2] tests: scrub environment of GIT_* variables

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Mar 15, 2011, 10:10 UTC
Message-ID
<20110315101045.GD3923@elie>
In-Reply-To
<20110315100846.GB3923@elie>

Variables from the inherited environment that are meaningful to git can break tests in undesirable ways. For example,

	GIT_PAGER=more sh t5400-send-pack.sh -v -i

hangs. So unset all environment variables in the GIT_ namespace in test-lib, with a few exceptions:

- GIT_TRACE* are useful for tracking down bugs exhibited by a failing
  test;
- GIT_DEBUG* are GIT_TRACE variables by another name, practically
  speaking.  They should probably be tweaked to follow the
  GIT_TRACE_foo scheme and use trace_printf machinery some time.
- GIT_USE_LOOKUP from v1.5.6-rc0~134^2~1 (sha1-lookup: more memory
  efficient search in sorted list of SHA-1, 2007-12-29) is about
  trying an alternate implementation strategy rather than changing
  semantics and it can be useful to compare performance with and
  without it set.
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
Thanks again.
 t/test-lib.sh |   23 +++++------------------
 1 files changed, 5 insertions(+), 18 deletions(-)
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 8893406..8aac727 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -43,29 +43,16 @@ TERM=dumb
 export LANG LC_ALL PAGER TERM TZ
 EDITOR=:
 unset VISUAL
-unset GIT_EDITOR
 unset EMAIL
-unset GIT_ALTERNATE_OBJECT_DIRECTORIES
-unset GIT_AUTHOR_DATE
+unset $(perl -e '
+	my @env = keys %ENV;
+	my @vars = grep(/^GIT_/ && !/^GIT_(TRACE|DEBUG|USE_LOOKUP)/, @env);
+	print join("\n", @vars);
+')
 GIT_AUTHOR_EMAIL=author@example.com
 GIT_AUTHOR_NAME='A U Thor'
-unset GIT_COMMITTER_DATE
 GIT_COMMITTER_EMAIL=committer@example.com
 GIT_COMMITTER_NAME='C O Mitter'
-unset GIT_DIFF_OPTS
-unset GIT_DIR
-unset GIT_WORK_TREE
-unset GIT_EXTERNAL_DIFF
-unset GIT_INDEX_FILE
-unset GIT_OBJECT_DIRECTORY
-unset GIT_CEILING_DIRECTORIES
-unset GIT_NOTES_REF
-unset GIT_NOTES_DISPLAY_REF
-unset GIT_NOTES_REWRITE_REF
-unset GIT_NOTES_REWRITE_MODE
-unset GIT_REFLOG_ACTION
-unset GIT_CHERRY_PICK_HELP
-unset GIT_QUIET
 GIT_MERGE_VERBOSITY=5
 export GIT_MERGE_VERBOSITY
 export GIT_AUTHOR_EMAIL GIT_AUTHOR_NAME
-- 
1.7.4.1
Previous: Jonathan NiederNext: Junio C Hamano
Message 13 of 15 in “tests: unsetting variables that influence the outcome”
  1. 0/3 tests: unsetting variables that influence the outcomeJonathan Nieder, Mar 15, 2011
  2. 1/3 tests: protect against GIT_ATTR_NOGLOBAL from environmentJonathan Nieder, Mar 15, 2011
  3. 2/3 tests: suppress global and system gitattributesJonathan Nieder, Mar 15, 2011
  4. Jeff KingMar 15, 2011
  5. 2/3 Re: tests: suppress global and system gitattributesJonathan Nieder, Mar 15, 2011
  6. 1/3 gitattributes: drop support for GIT_ATTR_NOGLOBALJonathan Nieder, Mar 15, 2011
  7. 2/3 config: drop support for GIT_CONFIG_NOGLOBALJonathan Nieder, Mar 15, 2011
  8. 3/3 tests: suppress system gitattributesJonathan Nieder, Mar 15, 2011
  9. 3/3 tests: scrub environment of GIT_* variablesJonathan Nieder, Mar 15, 2011
  10. Jeff KingMar 15, 2011
  11. 0/2 tests: stop hard-coding the list of GIT_* vars to scrubJonathan Nieder, Mar 15, 2011
  12. 1/2 tests: stop worrying about obsolete environment variablesJonathan Nieder, Mar 15, 2011
  13. 2/2 tests: scrub environment of GIT_* variablesJonathan Nieder, Mar 15, 2011
  14. Junio C HamanoMar 15, 2011
  15. Jeff KingMar 15, 2011

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.