Git fork

t/test-lib: don't print shell traces to stdout

We have several flags like "--verbose", "--verbose-only" or "-x" that
cause us to generate shell traces. The generated tracing output is split
up in these cases so that the test's stdout is printed to file
descriptor 3 whereas its stderr is printed to file descriptor 4.
Depending on which options have been given, we then end up either:

- Redirecting both file descriptors to a file.

- Redirecting them to stdout and stderr, respectively.

- Closing them in case we're running in none-verbose mode.

The second case causes problems though when passing output to a TAP
parser. We print the test's stdout to the console's stdout, and that
results in broken TAP output.

Fix the issue by instead redirecting the test's stdout to the shell's
stderr. This makes it impossible to discern stdout from stderr, but
going by my own experience I never came across a usecase where I would
have needed this distinction.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

authored by

Patrick Steinhardt and committed by
Junio C Hamano
d411d3d8 a1199a23

+21 -18
+19 -16
t/t0000-basic.sh
··· 219 test_expect_success "failing test" false 220 test_done 221 EOF 222 - mv t1234-verbose/out t1234-verbose/out+ && 223 - grep -v "^Initialized empty" t1234-verbose/out+ >t1234-verbose/out && 224 - check_sub_test_lib_test t1234-verbose <<-\EOF 225 - > expecting success of 1234.1 '\''passing test'\'': true 226 > ok 1 - passing test 227 > Z 228 > expecting success of 1234.2 '\''test with output'\'': echo foo 229 > foo 230 - > ok 2 - test with output 231 > Z 232 > expecting success of 1234.3 '\''failing test'\'': false 233 - > not ok 3 - failing test 234 - > # false 235 > Z 236 - > # failed 1 among 3 test(s) 237 - > 1..3 238 - EOF 239 ' 240 241 test_expect_success 'subtest: --verbose-only option' ' 242 run_sub_test_lib_test_err \ 243 t1234-verbose \ 244 --verbose-only=2 && 245 - check_sub_test_lib_test t1234-verbose <<-\EOF 246 > ok 1 - passing test 247 - > Z 248 - > expecting success of 1234.2 '\''test with output'\'': echo foo 249 - > foo 250 > ok 2 - test with output 251 - > Z 252 > not ok 3 - failing test 253 > # false 254 > # failed 1 among 3 test(s) 255 > 1..3 256 - EOF 257 ' 258 259 test_expect_success 'subtest: skip one with GIT_SKIP_TESTS' '
··· 219 test_expect_success "failing test" false 220 test_done 221 EOF 222 + mv t1234-verbose/err t1234-verbose/err+ && 223 + grep -v "^Initialized empty" t1234-verbose/err+ >t1234-verbose/err && 224 + check_sub_test_lib_test_err t1234-verbose \ 225 + <<-\EOF_OUT 3<<-\EOF_ERR 226 > ok 1 - passing test 227 + > ok 2 - test with output 228 + > not ok 3 - failing test 229 + > # false 230 + > # failed 1 among 3 test(s) 231 + > 1..3 232 + EOF_OUT 233 + > expecting success of 1234.1 '\''passing test'\'': true 234 > Z 235 > expecting success of 1234.2 '\''test with output'\'': echo foo 236 > foo 237 > Z 238 > expecting success of 1234.3 '\''failing test'\'': false 239 > Z 240 + EOF_ERR 241 ' 242 243 test_expect_success 'subtest: --verbose-only option' ' 244 run_sub_test_lib_test_err \ 245 t1234-verbose \ 246 --verbose-only=2 && 247 + check_sub_test_lib_test_err t1234-verbose <<-\EOF_OUT 3<<-\EOF_ERR 248 > ok 1 - passing test 249 > ok 2 - test with output 250 > not ok 3 - failing test 251 > # false 252 > # failed 1 among 3 test(s) 253 > 1..3 254 + EOF_OUT 255 + > Z 256 + > expecting success of 1234.2 '\''test with output'\'': echo foo 257 + > foo 258 + > Z 259 + EOF_ERR 260 ' 261 262 test_expect_success 'subtest: skip one with GIT_SKIP_TESTS' '
+2 -2
t/test-lib.sh
··· 707 exec 3>>"$GIT_TEST_TEE_OUTPUT_FILE" 4>&3 708 elif test "$verbose" = "t" 709 then 710 - exec 4>&2 3>&1 711 else 712 exec 4>/dev/null 3>/dev/null 713 fi ··· 949 test -z "$verbose_only" && return 950 if match_pattern_list $test_count "$verbose_only" 951 then 952 - exec 4>&2 3>&1 953 # Emit a delimiting blank line when going from 954 # non-verbose to verbose. Within verbose mode the 955 # delimiter is printed by test_expect_*. The choice
··· 707 exec 3>>"$GIT_TEST_TEE_OUTPUT_FILE" 4>&3 708 elif test "$verbose" = "t" 709 then 710 + exec 4>&2 3>&2 711 else 712 exec 4>/dev/null 3>/dev/null 713 fi ··· 949 test -z "$verbose_only" && return 950 if match_pattern_list $test_count "$verbose_only" 951 then 952 + exec 4>&2 3>&2 953 # Emit a delimiting blank line when going from 954 # non-verbose to verbose. Within verbose mode the 955 # delimiter is printed by test_expect_*. The choice