Re: [PATCH v3 15/21] tests: include detailed trace logs with --write-junit-xml upon failure
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Jan 17, 2019, 10:18 UTC
- Message-ID
- <nycvar.QRO.7.76.6.1901171112000.41@tvgsbejvaqbjf.bet>
- In-Reply-To
- <f678b105f81ec60f64c0f19e3cc7a8ef151ed52e.1547645770.git.gitgitgadget@gmail.com>
Hi,
On Wed, 16 Jan 2019, Johannes Schindelin via GitGitGadget wrote:
Show 12 quoted lines
> diff --git a/t/test-lib.sh b/t/test-lib.sh
> index e9782b6b32..f5371f505a 100644
> --- a/t/test-lib.sh
> +++ b/t/test-lib.sh
> @@ -503,8 +503,18 @@ test_failure_ () {
> junit_insert="<failure message=\"not ok $test_count -"
> junit_insert="$junit_insert $(xml_attr_encode "$1")\">"
> junit_insert="$junit_insert $(xml_attr_encode \
> - "$(printf '%s\n' "$@" | sed 1d)")"
> + "$(if test -n "$GIT_TEST_TEE_OUTPUT_FILE"
> + then
> + cut -c "$GIT_TEST_TEE_OFFSET-" <"$GIT_TEST_TEE_OUTPUT_FILE"Ooops. This does not work.
The intention of this patch was to remember the file size of the tee output file at the point when the previous test case was done, and skip that part (so that the first thing the user sees is the detailed trace of *just* the failed test case, with the complete trace being attached as `Standard_Error_Output.log`).
However, I totally misunderstood that `cut` is *always* line based. So this `cut -c` (which should have been a `cut -b` to begin with) is just plain wrong.
And since there is no easy Unix shell tool to just skip a bunch of bytes (`dd` comes close, but you have to abuse the buffer size to specify the number of bytes, or use buffer size 1, neither of which I like), I will just add a dozen lines to the `test-path-utils.c` to get problem fixed.
Show 32 quoted lines
> + else
> + printf '%s\n' "$@" | sed 1d
> + fi)")"
> junit_insert="$junit_insert</failure>"
> + if test -n "$GIT_TEST_TEE_OUTPUT_FILE"
> + then
> + junit_insert="$junit_insert<system-err>$(xml_attr_encode \
> + "$(cat "$GIT_TEST_TEE_OUTPUT_FILE")")</system-err>"
> + fi
> write_junit_xml_testcase "$1" " $junit_insert"
> fi
> test_failure=$(($test_failure + 1))
> @@ -872,6 +882,11 @@ write_junit_xml_testcase () {
> write_junit_xml "$(printf '%s\n' \
> " <testcase $junit_attrs>" "$@" " </testcase>")"
> junit_have_testcase=t
> + if test -n "$GIT_TEST_TEE_OUTPUT_FILE"
> + then
> + GIT_TEST_TEE_OFFSET=$(test-tool path-utils file-size \
> + "$GIT_TEST_TEE_OUTPUT_FILE")
> + fi
> }
>
> test_done () {
> @@ -1153,6 +1168,11 @@ then
> date +%Y-%m-%dT%H:%M:%S)\""
> write_junit_xml --truncate "<testsuites>" " <testsuite $junit_attrs>"
> junit_suite_start=$(test-tool date getnanos)
> + if test -n "$GIT_TEST_TEE_OUTPUT_FILE"
> + then
> + GIT_TEST_TEE_OFFSET=0
> + GIT_TEST_TEE_ERR_OFFSET=0Also, in case anybody wonders, this `GIT_TEST_TEE_ERR_OFFSET` variable is no longer used, and I should have removed it.
Oh well, I will just queue up the fixes in preparation for v4.
Ciao, Dscho
Show 8 quoted lines
> + fi > fi > > # Provide an implementation of the 'yes' utility > -- > gitgitgadget > >