Skip to contentSkip to conversation

t5516: fail to run in verbose mode

PATCH In review Jiang Xin 4 participants 8 messages Nov 21, 2022 – Nov 28, 2022

lore
Share & tools
lore

Jiang Xin

author
#0 lore raw

PATCH 1/1 t5516: fail to run in verbose mode

From: Jiang Xin <[email protected]>

The test case "push with config push.useBitmap" of t5516 was introduced in commit 82f67ee13f (send-pack.c: add config push.useBitmaps, 2022-06-17). It won't work in verbose mode, e.g.:

    $ sh t5516-fetch-push.sh --run='1,115' -v

This is because "git-push" will run in a tty in this case, and the subcommand "git pack-objects" will contain an argument "--progress" instead of "-q". Adding a specific option "--quiet" to "git push" will get a stable result for t5516.

---
 t/t5516-fetch-push.sh | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
t/t5516-fetch-push.sh +3 -3
index 4f2bfaf005..98a27a2948 100755
@@ -1858,19 +1858,19 @@ test_expect_success 'push with config push.useBitmaps' '
 	git checkout main &&
 	test_unconfig push.useBitmaps &&
 	GIT_TRACE2_EVENT="$PWD/default" \
-	git push testrepo main:test &&
+	git push --quiet testrepo main:test &&
 	test_subcommand git pack-objects --all-progress-implied --revs --stdout \
 		--thin --delta-base-offset -q <default &&
 
 	test_config push.useBitmaps true &&
 	GIT_TRACE2_EVENT="$PWD/true" \
-	git push testrepo main:test2 &&
+	git push --quiet testrepo main:test2 &&
 	test_subcommand git pack-objects --all-progress-implied --revs --stdout \
 		--thin --delta-base-offset -q <true &&
 
 	test_config push.useBitmaps false &&
 	GIT_TRACE2_EVENT="$PWD/false" \
-	git push testrepo main:test3 &&
+	git push --quiet testrepo main:test3 &&
 	test_subcommand git pack-objects --all-progress-implied --revs --stdout \
 		--thin --delta-base-offset -q --no-use-bitmap-index <false
 '
Signature · 1 line
2.38.1.420.g319605f8f0
#1 lore raw
Quoted 11 lines

The test case "push with config push.useBitmap" of t5516 was introduced in commit 82f67ee13f (send-pack.c: add config push.useBitmaps, 2022-06-17). It won't work in verbose mode, e.g.:

    $ sh t5516-fetch-push.sh --run='1,115' -v

This is because "git-push" will run in a tty in this case, and the subcommand "git pack-objects" will contain an argument "--progress"
instead of "-q". Adding a specific option "--quiet" to "git push" will get a stable result for t5516.

That's true. Thanks for noticing and fixing.

I didn't consider this usage of test case, and it works after your patch.

Thanks,
Kyle

#2 lore raw
In reply to Jiang Xin
Quoted 9 lines · Jiang Xin

From: Jiang Xin <[email protected]>

The test case "push with config push.useBitmap" of t5516 was introduced in commit 82f67ee13f (send-pack.c: add config push.useBitmaps, 2022-06-17). It won't work in verbose mode, e.g.:

    $ sh t5516-fetch-push.sh --run='1,115' -v

This is because "git-push" will run in a tty in this case, and the

Right. "-v" involves redirecting the stdout/stderr of the commands being run in the test to stdout/stderr in the environment the tests are run, so

    $ sh t5516-fetch-push.sh --run='1,115' -v >log 2>&1

would have succeeded correctly. Forcing the behaviour with the "--quiet" option is certainly a good way to gain stability.

#3 lore raw
Quoted 12 lines · Junio C Hamano
Quoted 9 lines · Jiang Xin

From: Jiang Xin <[email protected]>

The test case "push with config push.useBitmap" of t5516 was introduced in commit 82f67ee13f (send-pack.c: add config push.useBitmaps, 2022-06-17). It won't work in verbose mode, e.g.:

    $ sh t5516-fetch-push.sh --run='1,115' -v

This is because "git-push" will run in a tty in this case, and the

Quoted 8 lines

Right. "-v" involves redirecting the stdout/stderr of the commands being run in the test to stdout/stderr in the environment the tests are run, so

    $ sh t5516-fetch-push.sh --run='1,115' -v >log 2>&1

would have succeeded correctly. Forcing the behaviour with the "--quiet" option is certainly a good way to gain stability.

I agree this is a good fix for now, but I wonder philosophically what it means. That is, I could see two arguments:

1. Our tests sometimes run with stderr connected to a tty and sometimes not. This means the test environment isn't consistent, and perhaps we should be piping all "-v" tests through "cat" or something so that the environment is stable.

2. Having "-v" run through a tty is yet another source of variation that may help us find bugs (though of course sometimes it finds false positives). I'm a little uncomfortable with this just because it's not providing us variation in any kind of planned or cohesive way. This failure lasted for months before somebody noticed it was broken under "-v".

But if we take that approach, then tests are responsible for handling both cases. Passing "--quiet" here works, though it feels like making test_subcommand more flexible is the right fix. Looks like we had an "inexact" variant at one point, but it was dropped (because it was buggy) in 16dcec218b (test-lib-functions: remove test_subcommand_inexact, 2022-03-25).

None of which needs to hold up this patch, but I wonder if we'd want to pursue the larger fix in (1).

-Peff

#4 lore raw
Quoted 7 lines · Jeff King

I agree this is a good fix for now, but I wonder philosophically what it means. That is, I could see two arguments:

1. Our tests sometimes run with stderr connected to a tty and sometimes not. This means the test environment isn't consistent, and perhaps we should be piping all "-v" tests through "cat" or something so that the environment is stable.

Yes, this is tempting (and I almost brought it up in my response), and a pipe to "|cat" may be hopefully closer than tester's tty to the redirection to "/dev/null". I didn't know how much closer, though, and the differences may still matter (we could teach "git grep" or "git diff --exit-code" to notice that the output is sent to /dev/null and stop at the first hit, for example), but still "|cat" is closer than ">/dev/tty".

Quoted 2 lines

None of which needs to hold up this patch, but I wonder if we'd want to pursue the larger fix in (1).

Yeah, I agree.

Thanks.

#5 lore raw
Quoted 10 lines · Junio C Hamano
Quoted 7 lines · Jeff King

I agree this is a good fix for now, but I wonder philosophically what it means. That is, I could see two arguments:

1. Our tests sometimes run with stderr connected to a tty and sometimes not. This means the test environment isn't consistent, and perhaps we should be piping all "-v" tests through "cat" or something so that the environment is stable.

Quoted 7 lines

Yes, this is tempting (and I almost brought it up in my response), and a pipe to "|cat" may be hopefully closer than tester's tty to the redirection to "/dev/null". I didn't know how much closer, though, and the differences may still matter (we could teach "git grep" or "git diff --exit-code" to notice that the output is sent to /dev/null and stop at the first hit, for example), but still "|cat" is closer than ">/dev/tty".

One thing I'd worry about is buffering. One of the nice things about "-v" is that there is nothing between you and the running programs, so you are much less likely to be fooled about the order of events in the output. Or wondering why nothing is happening because real-time output seems to have stalled. But piping through "cat" may end up with weird pauses while it fills up a 4k buffer. Using stdbuf could help, but that's far from portable.

-Peff

#6 lore raw
Quoted 7 lines · Jeff King

One thing I'd worry about is buffering. One of the nice things about "-v" is that there is nothing between you and the running programs, so you are much less likely to be fooled about the order of events in the output. Or wondering why nothing is happening because real-time output seems to have stalled. But piping through "cat" may end up with weird pauses while it fills up a 4k buffer. Using stdbuf could help, but that's far from portable.

We could pipe to "dd bs=1 conv=fsync" (tongue-in-cheek---I think conv=fsync is a GNU thing).

#7 lore raw
Quoted 10 lines · Junio C Hamano
Quoted 7 lines · Jeff King

One thing I'd worry about is buffering. One of the nice things about "-v" is that there is nothing between you and the running programs, so you are much less likely to be fooled about the order of events in the output. Or wondering why nothing is happening because real-time output seems to have stalled. But piping through "cat" may end up with weird pauses while it fills up a 4k buffer. Using stdbuf could help, but that's far from portable.

Quoted 2 lines

We could pipe to "dd bs=1 conv=fsync" (tongue-in-cheek---I think conv=fsync is a GNU thing).

We don't need the fsync; we are just worried about in-process buffering, not kernel-level flushing. So bs=1 is sufficient, in that it would use syscalls to read/write single bytes. It would just be horribly inefficient.

We really just want immediate partial read()/write() but with sensible buffer sizes. It would be easy to write a 5-line C program that did this if we really wanted to. I'm not entirely convinced it's worth worrying too much about, though.

-Peff