diff options
author | Patrick Steinhardt <ps@pks.im> | 2019-07-19 12:43:55 +0200 |
---|---|---|
committer | Patrick Steinhardt <ps@pks.im> | 2019-07-20 19:10:10 +0200 |
commit | fe3b5da3ec9bfbca9f2d17ab6d3eddf39516c9c7 (patch) | |
tree | 4e355110db0a104a05f5b94b28325f1a338c25d0 /tests | |
parent | 86ecd6008da3b0b0baa0833fd8932e91994a9f9b (diff) | |
download | libgit2-fe3b5da3ec9bfbca9f2d17ab6d3eddf39516c9c7.tar.gz |
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.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/clar.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/tests/clar.c b/tests/clar.c index 7c308dd34..ead13f46a 100644 --- a/tests/clar.c +++ b/tests/clar.c @@ -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 |