Skip to content

Commit cc7f43e

Browse files
committed
fixup! tests: include detailed trace logs with --write-junit-xml upon failure
The `cut -c` approach is *per line*, not *per file* as I had thought. So it does not work... Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 9e107c9 commit cc7f43e

File tree

2 files changed

+27
-7
lines changed

2 files changed

+27
-7
lines changed

t/helper/test-path-utils.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,26 @@ int cmd__path_utils(int argc, const char **argv)
311311
return !!res;
312312
}
313313

314+
if (argc == 4 && !strcmp(argv[1], "skip-n-bytes")) {
315+
int fd = open(argv[2], O_RDONLY), offset = atoi(argv[3]);
316+
char buffer[65536];
317+
318+
if (fd < 0)
319+
die_errno("could not open '%s'", argv[2]);
320+
if (lseek(fd, offset, SEEK_SET) < 0)
321+
die_errno("could not skip %d bytes", offset);
322+
for (;;) {
323+
ssize_t count = read(fd, buffer, sizeof(buffer));
324+
if (count < 0)
325+
die_errno("could not read '%s'", argv[2]);
326+
if (!count)
327+
break;
328+
write(1, buffer, count);
329+
}
330+
close(fd);
331+
return 0;
332+
}
333+
314334
if (argc > 5 && !strcmp(argv[1], "slice-tests")) {
315335
int res = 0;
316336
long offset, stride, i;

t/test-lib.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,8 @@ test_failure_ () {
518518
junit_insert="$junit_insert $(xml_attr_encode \
519519
"$(if test -n "$GIT_TEST_TEE_OUTPUT_FILE"
520520
then
521-
cut -c "$GIT_TEST_TEE_OFFSET-" <"$GIT_TEST_TEE_OUTPUT_FILE"
521+
test-tool path-utils skip-n-bytes \
522+
"$GIT_TEST_TEE_OUTPUT_FILE" $GIT_TEST_TEE_OFFSET
522523
else
523524
printf '%s\n' "$@" | sed 1d
524525
fi)")"
@@ -823,6 +824,11 @@ test_finish_ () {
823824
echo >&3 ""
824825
maybe_teardown_valgrind
825826
maybe_teardown_verbose
827+
if test -n "$GIT_TEST_TEE_OFFSET"
828+
then
829+
GIT_TEST_TEE_OFFSET=$(test-tool path-utils file-size \
830+
"$GIT_TEST_TEE_OUTPUT_FILE")
831+
fi
826832
}
827833

828834
test_skip () {
@@ -900,11 +906,6 @@ write_junit_xml_testcase () {
900906
write_junit_xml "$(printf '%s\n' \
901907
" <testcase $junit_attrs>" "$@" " </testcase>")"
902908
junit_have_testcase=t
903-
if test -n "$GIT_TEST_TEE_OUTPUT_FILE"
904-
then
905-
GIT_TEST_TEE_OFFSET=$(test-tool path-utils file-size \
906-
"$GIT_TEST_TEE_OUTPUT_FILE")
907-
fi
908909
}
909910

910911
test_done () {
@@ -1198,7 +1199,6 @@ then
11981199
if test -n "$GIT_TEST_TEE_OUTPUT_FILE"
11991200
then
12001201
GIT_TEST_TEE_OFFSET=0
1201-
GIT_TEST_TEE_ERR_OFFSET=0
12021202
fi
12031203
fi
12041204

0 commit comments

Comments
 (0)