Fixed innaccurate statistics on wrong signal
This commit is contained in:
parent
49d7741a66
commit
162aa6608b
4 changed files with 13 additions and 10 deletions
|
@ -24,6 +24,7 @@
|
|||
#ifndef CRITERION_STATS_H_
|
||||
# define CRITERION_STATS_H_
|
||||
|
||||
# include <stdbool.h>
|
||||
# include "criterion.h"
|
||||
|
||||
struct criterion_assert_stats {
|
||||
|
@ -40,8 +41,9 @@ struct criterion_assert_stats {
|
|||
struct criterion_test_stats {
|
||||
struct criterion_test *test;
|
||||
struct criterion_assert_stats *asserts;
|
||||
int passed;
|
||||
int failed;
|
||||
bool failed;
|
||||
int passed_asserts;
|
||||
int failed_asserts;
|
||||
int signal;
|
||||
unsigned progress;
|
||||
const char *file;
|
||||
|
|
|
@ -25,7 +25,7 @@ ReportHook(PRE_INIT)(struct criterion_test *test) {
|
|||
|
||||
ReportHook(POST_TEST)(struct criterion_test_stats *stats) {
|
||||
printf("Asserts: [%d passed, %d failed, %d total]\n",
|
||||
stats->passed, stats->failed, stats->passed + stats->failed);
|
||||
stats->passed_asserts, stats->failed_asserts, stats->passed_asserts + stats->failed_asserts);
|
||||
}
|
||||
|
||||
ReportHook(PRE_EVERYTHING)() {
|
||||
|
|
|
@ -53,9 +53,7 @@ ReportHook(PRE_INIT)(struct criterion_test *test) {
|
|||
}
|
||||
|
||||
ReportHook(POST_TEST)(struct criterion_test_stats *stats) {
|
||||
int success = stats->failed == 0;
|
||||
|
||||
fprintf(stderr, "%s::%s: %s\n", stats->test->category, stats->test->name, success ? "SUCCESS" : "FAILURE");
|
||||
fprintf(stderr, "%s::%s: %s\n", stats->test->category, stats->test->name, stats->failed ? "FAILURE" : "SUCCESS");
|
||||
}
|
||||
|
||||
ReportHook(PRE_TEST)() {}
|
||||
|
|
11
src/stats.c
11
src/stats.c
|
@ -102,10 +102,10 @@ static void push_assert(s_glob_stats *stats,
|
|||
|
||||
if (data->passed) {
|
||||
++stats->asserts_passed;
|
||||
++test->passed;
|
||||
++test->passed_asserts;
|
||||
} else {
|
||||
++stats->asserts_failed;
|
||||
++test->failed;
|
||||
++test->failed_asserts;
|
||||
}
|
||||
|
||||
test->progress = dup->line;
|
||||
|
@ -115,15 +115,18 @@ static void push_assert(s_glob_stats *stats,
|
|||
static void push_post_test(s_glob_stats *stats,
|
||||
s_test_stats *test,
|
||||
UNUSED void *ptr) {
|
||||
if (test->failed > 0)
|
||||
if (test->failed_asserts > 0 || test->signal != test->test->data->signal) {
|
||||
test->failed = 1;
|
||||
++stats->tests_failed;
|
||||
else
|
||||
} else {
|
||||
++stats->tests_passed;
|
||||
}
|
||||
}
|
||||
|
||||
static void push_test_crash(s_glob_stats *stats,
|
||||
s_test_stats *test,
|
||||
UNUSED void *ptr) {
|
||||
test->failed = 1;
|
||||
++stats->tests_failed;
|
||||
++stats->tests_crashed;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue