diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2024-03-14 15:52:54 -0400 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2024-03-14 15:52:54 -0400 |
commit | 4e1492f0fa3a48e5fa88d8623e47e50bb8527c87 (patch) | |
tree | 04198e99f40355cdd2644884bd8ca2b33f832069 /src/deliverable.c | |
parent | 7656ed0e011f910b84131360cc82e335f01913db (diff) | |
download | stasis-4e1492f0fa3a48e5fa88d8623e47e50bb8527c87.tar.gz |
Pretty-print pytest xml results (if xmllint is present)
* Adds Delivery.storage.results_dir member
* Exposes storage.results_dir to templates
* This is to make the test results human-readable
* xmllint is optional. If it isn't installed it isn't a big deal.
Diffstat (limited to 'src/deliverable.c')
-rw-r--r-- | src/deliverable.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/deliverable.c b/src/deliverable.c index efcfd43..f926724 100644 --- a/src/deliverable.c +++ b/src/deliverable.c @@ -1678,4 +1678,35 @@ int delivery_docker(struct Delivery *ctx) { } return 0; +} + +int delivery_fixup_test_results(struct Delivery *ctx) { + struct dirent *rec; + DIR *dp; + + dp = opendir(ctx->storage.results_dir); + if (!dp) { + perror(ctx->storage.results_dir); + return -1; + } + + while ((rec = readdir(dp)) != NULL) { + char path[PATH_MAX]; + memset(path, 0, sizeof(path)); + + if (!strcmp(rec->d_name, ".") || !strcmp(rec->d_name, "..")) { + continue; + } else if (!endswith(rec->d_name, ".xml")) { + continue; + } + + sprintf(path, "%s/%s", ctx->storage.results_dir, rec->d_name); + msg(OMC_MSG_L2, "%s\n", rec->d_name); + if (xml_pretty_print_in_place(path, OMC_XML_PRETTY_PRINT_PROG, OMC_XML_PRETTY_PRINT_ARGS)) { + msg(OMC_MSG_L3 | OMC_MSG_WARN, "Failed to rewrite file '%s'\n", rec->d_name); + } + } + + closedir(dp); + return 0; }
\ No newline at end of file |