Added output for skipped tests (tap & normal logging)

This commit is contained in:
Snaipe 2015-03-24 01:09:10 +01:00
parent 9e65e34650
commit 32d7f6e518
3 changed files with 49 additions and 5 deletions

View file

@ -62,6 +62,24 @@ void normal_log_post_test(struct criterion_test_stats *stats) {
stats->elapsed_time);
}
__attribute__((always_inline))
static inline bool is_disabled(struct criterion_test *t, struct criterion_suite *s) {
return t->data->disabled || (s->data && s->data->disabled);
}
void normal_log_post_suite(struct criterion_suite_stats *stats) {
for (struct criterion_test_stats *ts = stats->tests; ts; ts = ts->next) {
if (is_disabled(ts->test, stats->suite)) {
criterion_info("[%sSKIP%s] %s::%s: %s is disabled\n",
FG_GOLD,
RESET,
ts->test->category,
ts->test->name,
ts->test->data->disabled ? "test" : "suite");
}
}
}
void normal_log_post_all(struct criterion_global_stats *stats) {
criterion_important("[%s====%s] ", FG_BLUE, RESET);
criterion_important("%sSynthesis: " SIZE_T_FORMAT " test%s run. " SIZE_T_FORMAT " passed, " SIZE_T_FORMAT " failed (with " SIZE_T_FORMAT " crash%s)%s\n",
@ -130,6 +148,7 @@ struct criterion_output_provider normal_logging = {
.log_pre_suite = normal_log_pre_suite,
.log_post_test = normal_log_post_test,
.log_assert = normal_log_assert,
.log_post_suite = normal_log_post_suite,
.log_post_all = normal_log_post_all,
.log_test_crash = normal_log_test_crash,
};

View file

@ -43,7 +43,7 @@ void tap_log_pre_all(struct criterion_test_set *set) {
++enabled_count;
}
}
criterion_important("TAP version 13\n1.." SIZE_T_FORMAT "\n", enabled_count);
criterion_important("TAP version 13\n1.." SIZE_T_FORMAT "\n", set->tests);
criterion_important("# Criterion v%s\n", VERSION);
}
@ -53,6 +53,22 @@ void tap_log_pre_suite(struct criterion_suite_set *set) {
set->suite.name);
}
__attribute__((always_inline))
static inline bool is_disabled(struct criterion_test *t, struct criterion_suite *s) {
return t->data->disabled || (s->data && s->data->disabled);
}
void tap_log_post_suite(struct criterion_suite_stats *stats) {
for (struct criterion_test_stats *ts = stats->tests; ts; ts = ts->next) {
if (is_disabled(ts->test, stats->suite)) {
criterion_important("ok - %s::%s # SKIP %s is disabled\n",
ts->test->category,
ts->test->name,
ts->test->data->disabled ? "test" : "suite");
}
}
}
void tap_log_post_test(struct criterion_test_stats *stats) {
const char *format = can_measure_time() ? "%s - %s::%s (%3.2fs)\n"
: "%s - %s::%s\n";
@ -89,4 +105,5 @@ struct criterion_output_provider tap_logging = {
.log_pre_suite = tap_log_pre_suite,
.log_test_crash = tap_log_test_crash,
.log_post_test = tap_log_post_test,
.log_post_suite = tap_log_post_suite,
};

View file

@ -97,7 +97,7 @@ typedef void (*f_test_run)(struct criterion_global_stats *,
static void map_tests(struct criterion_test_set *set, struct criterion_global_stats *stats, f_test_run fun) {
FOREACH_SET(struct criterion_suite_set *s, set->suites) {
if ((s->suite.data && s->suite.data->disabled) || !s->tests)
if (!s->tests)
continue;
report(PRE_SUITE, s);
@ -143,16 +143,24 @@ static void run_test_child(struct criterion_test *test, struct criterion_suite *
send_event(POST_FINI, NULL, 0);
}
__attribute__((always_inline))
static inline bool is_disabled(struct criterion_test *t, struct criterion_suite *s) {
return t->data->disabled || (s->data && s->data->disabled);
}
static void run_test(struct criterion_global_stats *stats,
struct criterion_suite_stats *suite_stats,
struct criterion_test *test,
struct criterion_suite *suite) {
if (test->data->disabled)
return;
smart struct criterion_test_stats *test_stats = test_stats_init(test);
if (is_disabled(test, suite)) {
struct event ev = { .kind = PRE_TEST };
stat_push_event(stats, suite_stats, test_stats, &ev);
return;
}
smart struct process *proc = spawn_test_worker(test, suite, run_test_child);
if (proc == NULL && !is_runner())
return;