From 4e1492f0fa3a48e5fa88d8623e47e50bb8527c87 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Thu, 14 Mar 2024 15:52:54 -0400 Subject: 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. --- src/deliverable.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'src/deliverable.c') diff --git a/src/deliverable.c b/src/deliverable.c index efcfd43..f926724 100644 --- a/src/deliverable.c +++ b/src/deliverable.c @@ -1677,5 +1677,36 @@ int delivery_docker(struct Delivery *ctx) { return -1; } + 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 -- cgit