diff --git a/include/criterion/types.h b/include/criterion/types.h index 55c36ac..3a4672f 100644 --- a/include/criterion/types.h +++ b/include/criterion/types.h @@ -36,6 +36,7 @@ struct criterion_test_extra_data { void (*fini)(void); int signal; bool disabled; + const char *description; void *data; }; diff --git a/samples/Makefile.am b/samples/Makefile.am index 932652f..78d071a 100644 --- a/samples/Makefile.am +++ b/samples/Makefile.am @@ -6,6 +6,7 @@ BIN_TESTS = \ asserts \ more-suites \ long-messages \ + description \ simple TESTS_ENVIRONMENT = CRITERION_ALWAYS_SUCCEED=1 diff --git a/samples/description.c b/samples/description.c new file mode 100644 index 0000000..3e9f02a --- /dev/null +++ b/samples/description.c @@ -0,0 +1,5 @@ +#include + +Test(misc, failing, .description = "Just a failing test") { + assert(0); +} diff --git a/samples/tests/tap_test.sh b/samples/tests/tap_test.sh index 0f209b0..38c0ac3 100755 --- a/samples/tests/tap_test.sh +++ b/samples/tests/tap_test.sh @@ -4,3 +4,4 @@ ./asserts --tap --always-succeed ./more-suites --tap --always-succeed ./long-messages --tap --always-succeed +./description --tap --always-succeed diff --git a/src/log/normal.c b/src/log/normal.c index b4c2d79..3e65fb4 100644 --- a/src/log/normal.c +++ b/src/log/normal.c @@ -47,6 +47,8 @@ void normal_log_pre_all(UNUSED struct criterion_test_set *set) { void normal_log_pre_init(struct criterion_test *test) { criterion_info("[%sRUN%s ] %s::%s\n", FG_BLUE, RESET, test->category, test->name); + if (test->data->description) + criterion_info("[%s----%s] %s\n", FG_BLUE, RESET, test->data->description); } void normal_log_post_test(struct criterion_test_stats *stats) { @@ -76,6 +78,8 @@ void normal_log_post_suite(struct criterion_suite_stats *stats) { ts->test->category, ts->test->name, ts->test->data->disabled ? "test" : "suite"); + if (ts->test->data->description) + criterion_info("[%s----%s] %s\n", FG_BLUE, RESET, ts->test->data->description); } } } diff --git a/src/log/tap.c b/src/log/tap.c index 46f1d5e..822b92f 100644 --- a/src/log/tap.c +++ b/src/log/tap.c @@ -61,21 +61,23 @@ static inline bool is_disabled(struct criterion_test *t, struct criterion_suite 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", + criterion_important("ok - %s::%s %s # SKIP %s is disabled\n", ts->test->category, ts->test->name, + ts->test->data->description ?: "", 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"; + const char *format = can_measure_time() ? "%s - %s::%s %s (%3.2fs)\n" + : "%s - %s::%s %s\n"; criterion_important(format, stats->failed ? "not ok" : "ok", stats->test->category, stats->test->name, + stats->test->data->description ?: "", stats->elapsed_time); for (struct criterion_assert_stats *asrt = stats->asserts; asrt; asrt = asrt->next) { if (!asrt->passed) {