Added an optional description field for tests
This commit is contained in:
parent
4dceef9dba
commit
9ca88d5673
6 changed files with 17 additions and 3 deletions
|
@ -36,6 +36,7 @@ struct criterion_test_extra_data {
|
|||
void (*fini)(void);
|
||||
int signal;
|
||||
bool disabled;
|
||||
const char *description;
|
||||
void *data;
|
||||
};
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ BIN_TESTS = \
|
|||
asserts \
|
||||
more-suites \
|
||||
long-messages \
|
||||
description \
|
||||
simple
|
||||
|
||||
TESTS_ENVIRONMENT = CRITERION_ALWAYS_SUCCEED=1
|
||||
|
|
5
samples/description.c
Normal file
5
samples/description.c
Normal file
|
@ -0,0 +1,5 @@
|
|||
#include <criterion/criterion.h>
|
||||
|
||||
Test(misc, failing, .description = "Just a failing test") {
|
||||
assert(0);
|
||||
}
|
|
@ -4,3 +4,4 @@
|
|||
./asserts --tap --always-succeed
|
||||
./more-suites --tap --always-succeed
|
||||
./long-messages --tap --always-succeed
|
||||
./description --tap --always-succeed
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Add table
Reference in a new issue