Commit fe3b5da3 by Patrick Steinhardt

clar: provide ability to set summary file via environment

As different test suites for our CI are mostly defined via CMake, it's
hard to run those tests with a summary file path as that'd require us to
add another parameter to all unit tests. As we do not want to
unconditionally run unit tests with a summary file, we would have to add
another CMake build parameter for test execution, which is ugly.

Instead, implement a way to provide a summary file path via the
environment.
parent 86ecd600
......@@ -145,7 +145,7 @@ static struct {
int report_suite_names;
int write_summary;
const char *summary_filename;
char *summary_filename;
struct clar_summary *summary;
struct clar_explicit *explicit;
......@@ -474,8 +474,8 @@ clar_parse_args(int argc, char **argv)
case 'r':
_clar.write_summary = 1;
_clar.summary_filename = *(argument + 2) ? (argument + 2) :
"summary.xml";
free(_clar.summary_filename);
_clar.summary_filename = strdup(*(argument + 2) ? (argument + 2) : "summary.xml");
break;
default:
......@@ -493,6 +493,11 @@ clar_test_init(int argc, char **argv)
""
);
if ((_clar.summary_filename = getenv("CLAR_SUMMARY")) != NULL) {
_clar.write_summary = 1;
_clar.summary_filename = strdup(_clar.summary_filename);
}
if (argc > 1)
clar_parse_args(argc, argv);
......@@ -553,6 +558,8 @@ clar_test_shutdown(void)
report_next = report->next;
free(report);
}
free(_clar.summary_filename);
}
int
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment