diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2024-12-06 08:44:39 -0500 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2024-12-06 08:44:39 -0500 |
commit | 41c76e0ca3f34fd46235bac6c2c9eac0497b28fb (patch) | |
tree | d45af285fa0e36af03da4d16c7221295d1686ec2 | |
parent | 0c18b5b15ed6e78cc27580518ae29f20ff23da65 (diff) | |
download | stasis-41c76e0ca3f34fd46235bac6c2c9eac0497b28fb.tar.gz |
Improved markdown output and presentation
-rw-r--r-- | src/cli/stasis_indexer/helpers.c | 1 | ||||
-rw-r--r-- | src/cli/stasis_indexer/junitxml_report.c | 176 | ||||
-rw-r--r-- | src/cli/stasis_indexer/readmes.c | 18 |
3 files changed, 113 insertions, 82 deletions
diff --git a/src/cli/stasis_indexer/helpers.c b/src/cli/stasis_indexer/helpers.c index 078be68..8279896 100644 --- a/src/cli/stasis_indexer/helpers.c +++ b/src/cli/stasis_indexer/helpers.c @@ -204,6 +204,7 @@ struct Delivery *get_latest_deliveries(struct Delivery ctx[], size_t nelem) { } latest = get_latest_rc(ctx, nelem); + qsort(ctx, nelem, sizeof(*ctx), sort_by_latest_rc); for (size_t i = 0; i < nelem; i++) { if (ctx[i].meta.rc == latest) { result[n] = ctx[i]; diff --git a/src/cli/stasis_indexer/junitxml_report.c b/src/cli/stasis_indexer/junitxml_report.c index 90cae3b..10c336d 100644 --- a/src/cli/stasis_indexer/junitxml_report.c +++ b/src/cli/stasis_indexer/junitxml_report.c @@ -30,101 +30,121 @@ int indexer_junitxml_report(struct Delivery ctx[], const size_t nelem) { fprintf(stderr, "Unable to open %s for writing\n", indexfile); return -1; } - struct StrList *archs = get_architectures(*latest, nelem); - struct StrList *platforms = get_platforms(*latest, nelem); struct StrList *archs = get_architectures(latest, nelem); struct StrList *platforms = get_platforms(latest, nelem); qsort(latest, latest_count, sizeof(*latest), callback_sort_deliveries_dynamic_cmpfn); fprintf(indexfp, "# %s-%s Test Report\n\n", ctx->meta.name, ctx->meta.version); - fprintf(indexfp, "## Current Release\n\n"); size_t no_printable_data = 0; - for (size_t p = 0; p < strlist_count(platforms); p++) { - char *platform = strlist_item(platforms, p); - for (size_t a = 0; a < strlist_count(archs); a++) { - char *arch = strlist_item(archs, a); - int have_combo = 0; - for (size_t i = 0; i < nelem; i++) { - if (latest[i] && latest[i]->system.platform) { - if (strstr(latest[i]->system.platform[DELIVERY_PLATFORM_RELEASE], platform) && - strstr(latest[i]->system.arch, arch)) { - have_combo = 1; - break; + + size_t delivery_count = get_latest_rc(latest, latest_count); + for (size_t p = 0; p < strlist_count(platforms); p++) { + char *platform = strlist_item(platforms, p); + for (size_t a = 0; a < strlist_count(archs); a++) { + char *arch = strlist_item(archs, a); + + fprintf(indexfp, "## %s-%s\n\n", platform, arch); + for (size_t d = 0; d < delivery_count; d++) { + struct Delivery *current = &ctx[d]; + if (current->meta.rc == (int) d + 1 + && strcmp(current->system.arch, arch) != 0 + && strcmp(current->system.platform[DELIVERY_PLATFORM_RELEASE], platform) != 0) { + continue; } - } - } - if (!have_combo) { - continue; - } - fprintf(indexfp, "### %s-%s\n\n", platform, arch); - - fprintf(indexfp, "|Suite|Duration|Fail |Skip |Error |\n"); - fprintf(indexfp, "|:----|:------:|:------:|:---:|:----:|\n"); - for (size_t f = 0; f < strlist_count(file_listing); f++) { - char *filename = strlist_item(file_listing, f); - if (!endswith(filename, ".xml")) { - continue; - } - if (strstr(filename, platform) && strstr(filename, arch)) { - struct JUNIT_Testsuite *testsuite = junitxml_testsuite_read(filename); - if (testsuite) { - if (globals.verbose) { - printf("%s: duration: %0.4f, failed: %d, skipped: %d, errors: %d\n", filename, testsuite->time, testsuite->failures, testsuite->skipped, testsuite->errors); - } - fprintf(indexfp, "|[%s](%s)|%0.4f|%d|%d|%d|\n", filename, filename, testsuite->time, testsuite->failures, testsuite->skipped, testsuite->errors); - /* - * TODO: Display failure/skip/error output. - */ - char *bname = strdup(filename); - bname[strlen(bname) - 4] = 0; - char result_outfile[PATH_MAX] = {0}; - path_basename(bname); - mkdir(bname, 0755); - snprintf(result_outfile, sizeof(result_outfile) - 1, "%s/%s.md", bname, bname); - FILE *resultfp = fopen(result_outfile, "w+"); - if (!resultfp) { - SYSERROR("Unable to open %s for writing", result_outfile); - return -1; + fprintf(indexfp, "### %s\n", current->info.release_name); + fprintf(indexfp, "\n|Suite|Duration|Fail |Skip |Error |\n"); + fprintf(indexfp, "|:----|:------:|:------:|:---:|:----:|\n"); + for (size_t f = 0; f < strlist_count(file_listing); f++) { + char *filename = strlist_item(file_listing, f); + if (!endswith(filename, ".xml")) { + continue; } - for (size_t i = 0; i < testsuite->_tc_inuse; i++) { - if (testsuite->testcase[i]->tc_result_state_type) { - const char *type_str = NULL; - const int state = testsuite->testcase[i]->tc_result_state_type; - const char *message = NULL; - if (state == JUNIT_RESULT_STATE_FAILURE) { - message = testsuite->testcase[i]->result_state.failure->message; - type_str = "[FAILED]"; - } else if (state == JUNIT_RESULT_STATE_ERROR) { - message = testsuite->testcase[i]->result_state.error->message; - type_str = "[ERROR]"; - } else if (state == JUNIT_RESULT_STATE_SKIPPED) { - message = testsuite->testcase[i]->result_state.skipped->message; - type_str = "[SKIPPED]"; + char pattern[PATH_MAX] = {0}; + snprintf(pattern, sizeof(pattern) - 1, "*%s*", current->info.release_name); + if (!fnmatch(pattern, filename, 0) && strstr(filename, platform) && + strstr(filename, arch)) { + struct JUNIT_Testsuite *testsuite = junitxml_testsuite_read(filename); + if (testsuite) { + if (globals.verbose) { + printf("%s: duration: %0.4f, failed: %d, skipped: %d, errors: %d\n", filename, + testsuite->time, testsuite->failures, testsuite->skipped, + testsuite->errors); } - fprintf(resultfp, "### %s %s :: %s\n", type_str, testsuite->testcase[i]->classname, testsuite->testcase[i]->name); - fprintf(resultfp, "\nDuration: %0.04fs\n", testsuite->testcase[i]->time); - fprintf(resultfp, "\n```\n%s\n```\n", message); + + char *bname_tmp = strdup(filename); + char *bname = path_basename(bname_tmp); + bname[strlen(bname) - 4] = 0; + guard_free(bname_tmp); + + char result_outfile[PATH_MAX] = {0}; + + char result_path[PATH_MAX] = {0}; + //snprintf(result_path, sizeof(result_path) -1 , "%s/%s", platform, arch); + //mkdirs(result_path, 0755); + + char *short_name_pattern = NULL; + asprintf(&short_name_pattern, "-%s", current->info.release_name); + + char short_name[PATH_MAX] = {0}; + strncpy(short_name, bname, sizeof(short_name) - 1); + replace_text(short_name, short_name_pattern, "", 0); + replace_text(short_name, "results-", "", 0); + guard_free(short_name_pattern); + + fprintf(indexfp, "|[%s](%s.html)|%0.4f|%d|%d|%d|\n", short_name, + bname, + testsuite->time, testsuite->failures, testsuite->skipped, + testsuite->errors); + + snprintf(result_outfile, sizeof(result_outfile) - strlen(bname) - 3, "%s.md", + bname); + FILE *resultfp = fopen(result_outfile, "w+"); + if (!resultfp) { + SYSERROR("Unable to open %s for writing", result_outfile); + return -1; + } + + for (size_t i = 0; i < testsuite->_tc_inuse; i++) { + if (testsuite->testcase[i]->tc_result_state_type) { + const char *type_str = NULL; + const int state = testsuite->testcase[i]->tc_result_state_type; + const char *message = NULL; + if (state == JUNIT_RESULT_STATE_FAILURE) { + message = testsuite->testcase[i]->result_state.failure->message; + type_str = "[FAILED]"; + } else if (state == JUNIT_RESULT_STATE_ERROR) { + message = testsuite->testcase[i]->result_state.error->message; + type_str = "[ERROR]"; + } else if (state == JUNIT_RESULT_STATE_SKIPPED) { + message = testsuite->testcase[i]->result_state.skipped->message; + type_str = "[SKIPPED]"; + } + fprintf(resultfp, "### %s %s :: %s\n", type_str, + testsuite->testcase[i]->classname, testsuite->testcase[i]->name); + fprintf(resultfp, "\nDuration: %0.04fs\n", testsuite->testcase[i]->time); + fprintf(resultfp, "\n```\n%s\n```\n", message); + } + } + junitxml_testsuite_free(&testsuite); + fclose(resultfp); + } else { + fprintf(stderr, "bad test suite: %s: %s\n", strerror(errno), filename); + } + } else { + if (!no_printable_data) { + // Triggering for reasons unknown + //fprintf(indexfp, "|No data|-|-|-|-|-|-|\n"); + no_printable_data++; } } - junitxml_testsuite_free(&testsuite); - fclose(resultfp); - } else { - fprintf(stderr, "bad test suite: %s: %s\n", strerror(errno), filename); - } - } else { - if (!no_printable_data) { - // Triggering for reasons unknown - //fprintf(indexfp, "|No data|-|-|-|-|-|-|\n"); - no_printable_data++; } } + fprintf(indexfp, "\n"); + no_printable_data = 0; } fprintf(indexfp, "\n"); - no_printable_data = 0; - } - fprintf(indexfp, "\n"); } guard_strlist_free(&archs); guard_strlist_free(&platforms); diff --git a/src/cli/stasis_indexer/readmes.c b/src/cli/stasis_indexer/readmes.c index c98ecfc..df3614e 100644 --- a/src/cli/stasis_indexer/readmes.c +++ b/src/cli/stasis_indexer/readmes.c @@ -36,9 +36,6 @@ int indexer_readmes(struct Delivery ctx[], const size_t nelem) { continue; } fprintf(indexfp, "### %s-%s\n\n", platform, arch); - - fprintf(indexfp, "|Release|Info|Receipt|\n"); - fprintf(indexfp, "|:----:|:----:|:----:|\n"); for (size_t i = 0; i < nelem; i++) { char link_name[PATH_MAX]; char readme_name[PATH_MAX]; @@ -52,13 +49,26 @@ int indexer_readmes(struct Delivery ctx[], const size_t nelem) { sprintf(conf_name, "%s.ini", latest[i].info.release_name); sprintf(conf_name_relative, "../config/%s.ini", latest[i].info.release_name); if (strstr(link_name, platform) && strstr(link_name, arch)) { - fprintf(indexfp, "|[%s](%s)|[%s](%s)|[%s](%s)|\n", link_name, link_name, readme_name, readme_name, conf_name, conf_name_relative); + fprintf(indexfp, "- Info: [README](%s)\n", readme_name); + fprintf(indexfp, "- Release: [Conda Environment YAML](%s)\n", link_name); + fprintf(indexfp, "- Receipt: [STASIS input file](%s)\n", conf_name_relative); } } fprintf(indexfp, "\n"); } fprintf(indexfp, "\n"); } + + fprintf(indexfp, "## Releases\n"); + for (size_t i = 0; ctx[i].meta.name != NULL; i++) { + struct Delivery *current = &ctx[i]; + fprintf(indexfp, "### %s\n", current->info.release_name); + fprintf(indexfp, "- Info: [README](README-%s.html)\n", current->info.release_name); + fprintf(indexfp, "- Release: [Conda Environment YAML](%s.yml)\n", current->info.release_name); + fprintf(indexfp, "- Receipt: [STASIS input file](%s.ini)\n", current->info.release_name); + } + fprintf(indexfp, "\n"); + guard_strlist_free(&archs); guard_strlist_free(&platforms); fclose(indexfp); |