From 32d7f6e518aeb550b35ecfba9902308ee6639794 Mon Sep 17 00:00:00 2001 From: Snaipe Date: Tue, 24 Mar 2015 01:09:10 +0100 Subject: [PATCH] Added output for skipped tests (tap & normal logging) --- src/log/normal.c | 19 +++++++++++++++++++ src/log/tap.c | 19 ++++++++++++++++++- src/runner.c | 16 ++++++++++++---- 3 files changed, 49 insertions(+), 5 deletions(-) diff --git a/src/log/normal.c b/src/log/normal.c index cb68d54..3bae3b1 100644 --- a/src/log/normal.c +++ b/src/log/normal.c @@ -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, }; diff --git a/src/log/tap.c b/src/log/tap.c index d5221d8..46f1d5e 100644 --- a/src/log/tap.c +++ b/src/log/tap.c @@ -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, }; diff --git a/src/runner.c b/src/runner.c index 3491193..14ffcb9 100644 --- a/src/runner.c +++ b/src/runner.c @@ -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;