All of lore.kernel.org
 help / color / mirror / Atom feed
From: Felipe Contreras <felipe.contreras@gmail.com>
To: git@vger.kernel.org
Cc: "Junio C Hamano" <gitster@pobox.com>,
	"Carlo Marcelo Arenas Belón" <carenas@gmail.com>,
	"Felipe Contreras" <felipe.contreras@gmail.com>,
	"John Keeping" <john@keeping.me.uk>, "Jeff King" <peff@peff.net>,
	"Johannes Schindelin" <Johannes.Schindelin@gmx.de>
Subject: [PATCH] test: fix for TEST_OUTPUT_DIRECTORY
Date: Wed,  9 Jun 2021 12:05:20 -0500	[thread overview]
Message-ID: <20210609170520.67014-1-felipe.contreras@gmail.com> (raw)

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


             reply	other threads:[~2021-06-09 17:05 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-09 17:05 Felipe Contreras [this message]
2021-06-13  4:42 ` [PATCH] test: fix for TEST_OUTPUT_DIRECTORY Jeff King
2021-06-13 15:44   ` Felipe Contreras
2021-06-14  7:43     ` Jeff King
2021-06-14  8:39       ` Felipe Contreras
2021-06-14  9:33         ` Ævar Arnfjörð Bjarmason
2021-06-14 14:25           ` Jeff King
2021-06-14 16:55             ` Ævar Arnfjörð Bjarmason
2021-06-15 11:10               ` Jeff King
2021-06-15 11:21                 ` Bagas Sanjaya
2021-06-15 11:23                   ` Jeff King
2021-06-15 18:09                 ` Felipe Contreras
2021-06-15 17:45           ` Felipe Contreras

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210609170520.67014-1-felipe.contreras@gmail.com \
    --to=felipe.contreras@gmail.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=carenas@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=john@keeping.me.uk \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.