Added back CRITERION_ENABLE_TAP and added CRITERION_OUTPUTS environment variable.
This commit is contained in:
parent
26b25cf1f9
commit
1beccec921
2 changed files with 40 additions and 1 deletions
|
@ -93,3 +93,8 @@ Environment variables are alternatives to command line switches when set to 1.
|
||||||
to its value. (\*nix only)
|
to its value. (\*nix only)
|
||||||
* ``CRITERION_DISABLE_TIME_MEASUREMENTS``: Disables any time measurements on
|
* ``CRITERION_DISABLE_TIME_MEASUREMENTS``: Disables any time measurements on
|
||||||
the tests.
|
the tests.
|
||||||
|
* ``CRITERION_OUTPUTS``: Can be set to a comma-separated list of
|
||||||
|
``PROVIDER:FILE`` entries. For instance, setting the variable to
|
||||||
|
``tap:foo.tap,xml:bar.xml`` has the same effect as specifying ``--tap=foo.tap``
|
||||||
|
and ``--xml=bar.xml`` at once.
|
||||||
|
* ``CRITERION_ENABLE_TAP``: (Deprecated, use CRITERION_OUTPUTS) Same as ``--tap``.
|
||||||
|
|
|
@ -200,10 +200,42 @@ int criterion_handle_args(int argc, char *argv[], bool handle_unknown_arg) {
|
||||||
|
|
||||||
opt->measure_time = !!strcmp("1", DEF(getenv("CRITERION_DISABLE_TIME_MEASUREMENTS"), "0"));
|
opt->measure_time = !!strcmp("1", DEF(getenv("CRITERION_DISABLE_TIME_MEASUREMENTS"), "0"));
|
||||||
|
|
||||||
|
bool quiet = false;
|
||||||
|
|
||||||
|
// CRITERION_ENABLE_TAP backward compatibility.
|
||||||
|
// The environment variable is otherwise deprecated.
|
||||||
|
if (!strcmp("1", DEF(getenv("CRITERION_ENABLE_TAP"), "0"))) {
|
||||||
|
quiet = true;
|
||||||
|
criterion_add_output("tap", DEF(optarg, "-"));
|
||||||
|
}
|
||||||
|
|
||||||
bool do_list_tests = false;
|
bool do_list_tests = false;
|
||||||
bool do_print_version = false;
|
bool do_print_version = false;
|
||||||
bool do_print_usage = false;
|
bool do_print_usage = false;
|
||||||
bool quiet = false;
|
|
||||||
|
const char *outputs = getenv("CRITERION_OUTPUTS");
|
||||||
|
if (outputs) {
|
||||||
|
char *out = strdup(outputs);
|
||||||
|
char *buf = NULL;
|
||||||
|
strtok_r(out, ",", &buf);
|
||||||
|
|
||||||
|
for (char *s = out; s; s = strtok_r(NULL, ",", &buf)) {
|
||||||
|
s = strdup(s);
|
||||||
|
char *buf2 = NULL;
|
||||||
|
char *provider = strtok_r(s, ":", &buf2);
|
||||||
|
char *path = strtok_r(NULL, ":", &buf2);
|
||||||
|
|
||||||
|
if (provider == NULL || path == NULL) {
|
||||||
|
do_print_usage = true;
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
|
quiet = true;
|
||||||
|
criterion_add_output(provider, path);
|
||||||
|
}
|
||||||
|
free(out);
|
||||||
|
}
|
||||||
|
|
||||||
for (int c; (c = getopt_long(argc, argv, "hvlfj:SqO:", opts, NULL)) != -1;) {
|
for (int c; (c = getopt_long(argc, argv, "hvlfj:SqO:", opts, NULL)) != -1;) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'b': criterion_options.logging_threshold = (enum criterion_logging_level) atou(DEF(optarg, "1")); break;
|
case 'b': criterion_options.logging_threshold = (enum criterion_logging_level) atou(DEF(optarg, "1")); break;
|
||||||
|
@ -241,6 +273,8 @@ int criterion_handle_args(int argc, char *argv[], bool handle_unknown_arg) {
|
||||||
default : do_print_usage = handle_unknown_arg; break;
|
default : do_print_usage = handle_unknown_arg; break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
end:
|
||||||
if (quiet)
|
if (quiet)
|
||||||
criterion_options.logging_threshold = CRITERION_LOG_LEVEL_QUIET;
|
criterion_options.logging_threshold = CRITERION_LOG_LEVEL_QUIET;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue