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

[PATCH] test: fix for TEST_OUTPUT_DIRECTORY

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
Jun 9, 2021, 17:05 UTC
Message-ID
<20210609170520.67014-1-felipe.contreras@gmail.com>

The test_atexit unit test relies on the specific location of the generated files.

When TEST_OUTPUT_DIRECTORY is unset, _run_sub_test_lib_test_common sets it to pwd, which is two levels under the pwd of the parent unit test, and the parent can find the generated files just fine.

But when TEST_OUTPUT_DIRECTORY is set, it's stored in GIT-BUILD-OPTIONS, and even though _run_sub_test_lib_test_common correctly overrides it, when the child script is run, it sources GIT-BUILD-OPTIONS, and TEST_OUTPUT_DIRECTORY is overridden.

Effectively both the parent and child scripts output to the same directory.

  make TEST_OUTPUT_DIRECTORY=/tmp/foobar GIT-BUILD-OPTIONS &&
  make -C t t0000-basic.sh

We could simply revert 2d14e13c56 (test output: respect $TEST_OUTPUT_DIRECTORY, 2013-04-29), but presumably it was done for some reason.

On the other hand we could follow the alternate path suggested in 6883047071 (t0000: set TEST_OUTPUT_DIRECTORY for sub-tests, 2013-12-28): pass the --root parameter to the child scripts.

The alternate solution works, so let's do that instead.

Presumably this was broken since 900721e15c (test-lib: introduce 'test_atexit', 2019-03-13).

Cc: John Keeping <john@keeping.me.uk>
Cc: Jeff King <peff@peff.net>
Cc: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 t/t0000-basic.sh | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh
index 705d62cc27..16b70ef940 100755
--- a/t/t0000-basic.sh
+++ b/t/t0000-basic.sh
@@ -93,14 +93,12 @@ _run_sub_test_lib_test_common () {
 		EOF
 		cat >>"$name.sh" &&
 		export TEST_DIRECTORY &&
-		TEST_OUTPUT_DIRECTORY=$(pwd) &&
-		export TEST_OUTPUT_DIRECTORY &&
 		sane_unset GIT_TEST_FAIL_PREREQS &&
 		if test -z "$neg"
 		then
-			./"$name.sh" "$@" >out 2>err
+			./"$name.sh" --root="$(pwd)" "$@" >out 2>err
 		else
-			! ./"$name.sh" "$@" >out 2>err
+			! ./"$name.sh" --root="$(pwd)" "$@" >out 2>err
 		fi
 	)
 }
-- 
2.32.0.2.g41be0a4e50
Next: Jeff King
Message 1 of 13 in “test: fix for TEST_OUTPUT_DIRECTORY”
  1. test: fix for TEST_OUTPUT_DIRECTORYFelipe Contreras, Jun 9, 2021
  2. Jeff KingJun 13, 2021
  3. Felipe ContrerasJun 13, 2021
  4. Jeff KingJun 14, 2021
  5. Felipe ContrerasJun 14, 2021
  6. Ævar Arnfjörð BjarmasonJun 14, 2021
  7. Jeff KingJun 14, 2021
  8. Ævar Arnfjörð BjarmasonJun 14, 2021
  9. Jeff KingJun 15, 2021
  10. Bagas SanjayaJun 15, 2021
  11. Jeff KingJun 15, 2021
  12. Felipe ContrerasJun 15, 2021
  13. Felipe ContrerasJun 15, 2021

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.