summaryrefslogtreecommitdiff
path: root/t/helper
diff options
context:
space:
mode:
authorLibravatar Johannes Schindelin <johannes.schindelin@gmx.de>2019-01-29 06:19:34 -0800
committerLibravatar Junio C Hamano <gitster@pobox.com>2019-01-29 09:26:47 -0800
commitaf9912efaf9d70ef96c63dfc28043b0b856cd516 (patch)
tree73c35f9da4876f7e1b4409dc1bf5308d76ce1b0e /t/helper
parenttests: avoid calling Perl just to determine file sizes (diff)
downloadtgif-af9912efaf9d70ef96c63dfc28043b0b856cd516.tar.xz
tests: include detailed trace logs with --write-junit-xml upon failure
The JUnit XML format lends itself to be presented in a powerful UI, where you can drill down to the information you are interested in very quickly. For test failures, this usually means that you want to see the detailed trace of the failing tests. With Travis CI, we passed the `--verbose-log` option to get those traces. However, that seems excessive, as we do not need/use the logs in almost all of those cases: only when a test fails do we have a way to include the trace. So let's do something different when using Azure DevOps: let's run all the tests with `--quiet` first, and only if a failure is encountered, try to trace the commands as they are executed. Of course, we cannot turn on `--verbose-log` after the fact. So let's just re-run the test with all the same options, adding `--verbose-log`. And then munging the output file into the JUnit XML on the fly. Note: there is an off chance that re-running the test in verbose mode "fixes" the failures (and this does happen from time to time!). That is a possibility we should be able to live with. Ideally, we would label this as "Passed upon rerun", and Azure Pipelines even know about that outcome, but it is not available when using the JUnit XML format for now: https://github.com/Microsoft/azure-pipelines-agent/blob/master/src/Agent.Worker/TestResults/JunitResultReader.cs Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/helper')
-rw-r--r--t/helper/test-path-utils.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/t/helper/test-path-utils.c b/t/helper/test-path-utils.c
index 30211d6d64..6efde6f5ba 100644
--- a/t/helper/test-path-utils.c
+++ b/t/helper/test-path-utils.c
@@ -303,6 +303,27 @@ int cmd__path_utils(int argc, const char **argv)
return !!res;
}
+ if (argc == 4 && !strcmp(argv[1], "skip-n-bytes")) {
+ int fd = open(argv[2], O_RDONLY), offset = atoi(argv[3]);
+ char buffer[65536];
+
+ if (fd < 0)
+ die_errno("could not open '%s'", argv[2]);
+ if (lseek(fd, offset, SEEK_SET) < 0)
+ die_errno("could not skip %d bytes", offset);
+ for (;;) {
+ ssize_t count = read(fd, buffer, sizeof(buffer));
+ if (count < 0)
+ die_errno("could not read '%s'", argv[2]);
+ if (!count)
+ break;
+ if (write(1, buffer, count) < 0)
+ die_errno("could not write to stdout");
+ }
+ close(fd);
+ return 0;
+ }
+
fprintf(stderr, "%s: unknown function name: %s\n", argv[0],
argv[1] ? argv[1] : "(there was none)");
return 1;