git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* t0000 failed
@ 2020-04-28  6:52 Son Luong Ngoc
  2020-04-28  8:14 ` [PATCH] t0000: disable GIT_TEST_FAIL_PREREQS in sub-tests Jeff King
  0 siblings, 1 reply; 3+ messages in thread
From: Son Luong Ngoc @ 2020-04-28  6:52 UTC (permalink / raw)
  To: git; +Cc: Jeff King, Junio C Hamano, Johannes Schindelin

Hey folks,

Running t0000 with GIT_TEST_FAIL_PREREQS=true is failing.

> GIT_TEST_FAIL_PREREQS=true ./t0000-basic.sh
t/./t0000-basic.sh:836: error: not ok 45 - lazy prereqs do not turn off tracing
#
#               run_sub_test_lib_test lazy-prereq-and-tracing
 'lazy prereqs and -x' -v -x <<-\EOF &&
#               test_lazy_prereq LAZY true
#
#               test_expect_success lazy 'test_have_prereq LAZY && echo trace'
#
#               test_done
#               EOF
#
#               grep 'echo trace' lazy-prereq-and-tracing/err
#

This was added recently with
https://public-inbox.org/git/f35830c0eba216b7b4f144409e302a87ff8b5c06.1585236929.git.gitgitgadget@gmail.com/
Is this intended?

Cheers,
Son Luong.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] t0000: disable GIT_TEST_FAIL_PREREQS in sub-tests
  2020-04-28  6:52 t0000 failed Son Luong Ngoc
@ 2020-04-28  8:14 ` Jeff King
  2020-05-01 20:56   ` Johannes Schindelin
  0 siblings, 1 reply; 3+ messages in thread
From: Jeff King @ 2020-04-28  8:14 UTC (permalink / raw)
  To: Son Luong Ngoc; +Cc: git, Junio C Hamano, Johannes Schindelin

On Tue, Apr 28, 2020 at 08:52:34AM +0200, Son Luong Ngoc wrote:

> Running t0000 with GIT_TEST_FAIL_PREREQS=true is failing.
> 
> > GIT_TEST_FAIL_PREREQS=true ./t0000-basic.sh
> t/./t0000-basic.sh:836: error: not ok 45 - lazy prereqs do not turn off tracing
> #
> #               run_sub_test_lib_test lazy-prereq-and-tracing
>  'lazy prereqs and -x' -v -x <<-\EOF &&
> #               test_lazy_prereq LAZY true
> #
> #               test_expect_success lazy 'test_have_prereq LAZY && echo trace'
> #
> #               test_done
> #               EOF
> #
> #               grep 'echo trace' lazy-prereq-and-tracing/err

I think the patch below is the right fix.

-- >8 --
Subject: [PATCH] t0000: disable GIT_TEST_FAIL_PREREQS in sub-tests

The test added by 477dcaddb6 (tests: do not let lazy prereqs inside
`test_expect_*` turn off tracing, 2020-03-26) runs a sub-test script
that traces a test with a lazy prereq, like:

  test_have_prereq LAZY && echo trace

That won't work if GIT_TEST_FAIL_PREREQS is set in the environment,
because our have_prereq will report failure, and we won't run the echo
at all.

We could work around this by avoiding the &&-chain, but we can
fix this and any future tests at once by unsetting that variable for our
sub-tests. These are meant to be controlled environments where we test
the test-suite itself; the outer test snippet should be in charge of the
sub-test environment, not whatever mode the user happens to be running
in.

Reported-by: Son Luong Ngoc <sluongng@gmail.com>
Signed-off-by: Jeff King <peff@peff.net>
---
 t/t0000-basic.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh
index b859721620..f58f3deaa8 100755
--- a/t/t0000-basic.sh
+++ b/t/t0000-basic.sh
@@ -98,6 +98,7 @@ _run_sub_test_lib_test_common () {
 		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
-- 
2.26.2.827.g3c1233342b


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] t0000: disable GIT_TEST_FAIL_PREREQS in sub-tests
  2020-04-28  8:14 ` [PATCH] t0000: disable GIT_TEST_FAIL_PREREQS in sub-tests Jeff King
@ 2020-05-01 20:56   ` Johannes Schindelin
  0 siblings, 0 replies; 3+ messages in thread
From: Johannes Schindelin @ 2020-05-01 20:56 UTC (permalink / raw)
  To: Jeff King; +Cc: Son Luong Ngoc, git, Junio C Hamano

Hi,

On Tue, 28 Apr 2020, Jeff King wrote:

> On Tue, Apr 28, 2020 at 08:52:34AM +0200, Son Luong Ngoc wrote:
>
> > Running t0000 with GIT_TEST_FAIL_PREREQS=true is failing.
> >
> > > GIT_TEST_FAIL_PREREQS=true ./t0000-basic.sh
> > t/./t0000-basic.sh:836: error: not ok 45 - lazy prereqs do not turn off tracing
> > #
> > #               run_sub_test_lib_test lazy-prereq-and-tracing
> >  'lazy prereqs and -x' -v -x <<-\EOF &&
> > #               test_lazy_prereq LAZY true
> > #
> > #               test_expect_success lazy 'test_have_prereq LAZY && echo trace'
> > #
> > #               test_done
> > #               EOF
> > #
> > #               grep 'echo trace' lazy-prereq-and-tracing/err
>
> I think the patch below is the right fix.
>
> -- >8 --
> Subject: [PATCH] t0000: disable GIT_TEST_FAIL_PREREQS in sub-tests
>
> The test added by 477dcaddb6 (tests: do not let lazy prereqs inside
> `test_expect_*` turn off tracing, 2020-03-26) runs a sub-test script
> that traces a test with a lazy prereq, like:
>
>   test_have_prereq LAZY && echo trace
>
> That won't work if GIT_TEST_FAIL_PREREQS is set in the environment,
> because our have_prereq will report failure, and we won't run the echo
> at all.
>
> We could work around this by avoiding the &&-chain, but we can
> fix this and any future tests at once by unsetting that variable for our
> sub-tests. These are meant to be controlled environments where we test
> the test-suite itself; the outer test snippet should be in charge of the
> sub-test environment, not whatever mode the user happens to be running
> in.

Thanks for fixing a bug I introduced! The fix looks good to me.

Thank you,
Dscho

>
> Reported-by: Son Luong Ngoc <sluongng@gmail.com>
> Signed-off-by: Jeff King <peff@peff.net>
> ---
>  t/t0000-basic.sh | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh
> index b859721620..f58f3deaa8 100755
> --- a/t/t0000-basic.sh
> +++ b/t/t0000-basic.sh
> @@ -98,6 +98,7 @@ _run_sub_test_lib_test_common () {
>  		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
> --
> 2.26.2.827.g3c1233342b
>
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-05-01 20:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-28  6:52 t0000 failed Son Luong Ngoc
2020-04-28  8:14 ` [PATCH] t0000: disable GIT_TEST_FAIL_PREREQS in sub-tests Jeff King
2020-05-01 20:56   ` Johannes Schindelin

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).