[Issue #15] Fixed incorrect reporting on setup/teardown crash
This commit is contained in:
parent
8a29e3e792
commit
14aa37594d
7 changed files with 66 additions and 35 deletions
|
@ -96,10 +96,11 @@ struct criterion_output_provider {
|
||||||
void (*log_pre_init )(struct criterion_test *test);
|
void (*log_pre_init )(struct criterion_test *test);
|
||||||
void (*log_pre_test )(struct criterion_test *test);
|
void (*log_pre_test )(struct criterion_test *test);
|
||||||
void (*log_assert )(struct criterion_assert_stats *stats);
|
void (*log_assert )(struct criterion_assert_stats *stats);
|
||||||
void (*log_test_crash)(struct criterion_test_stats *stats);
|
void (*log_test_crash )(struct criterion_test_stats *stats);
|
||||||
|
void (*log_other_crash)(struct criterion_test_stats *stats);
|
||||||
void (*log_post_test )(struct criterion_test_stats *stats);
|
void (*log_post_test )(struct criterion_test_stats *stats);
|
||||||
void (*log_post_fini )(struct criterion_test_stats *stats);
|
void (*log_post_fini )(struct criterion_test_stats *stats);
|
||||||
void (*log_post_suite)(struct criterion_suite_stats *stats);
|
void (*log_post_suite )(struct criterion_suite_stats *stats);
|
||||||
void (*log_post_all )(struct criterion_global_stats *stats);
|
void (*log_post_all )(struct criterion_global_stats *stats);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
23
po/fr.po
23
po/fr.po
|
@ -8,7 +8,7 @@ msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: criterion 1.0.0\n"
|
"Project-Id-Version: criterion 1.0.0\n"
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"POT-Creation-Date: 2015-04-10 00:15+0200\n"
|
"POT-Creation-Date: 2015-04-10 23:08+0200\n"
|
||||||
"PO-Revision-Date: 2015-04-03 17:58+0200\n"
|
"PO-Revision-Date: 2015-04-03 17:58+0200\n"
|
||||||
"Last-Translator: <franklinmathieu@gmail.com>\n"
|
"Last-Translator: <franklinmathieu@gmail.com>\n"
|
||||||
"Language-Team: French\n"
|
"Language-Team: French\n"
|
||||||
|
@ -28,22 +28,22 @@ msgstr "Criterion v%s\n"
|
||||||
msgid "%1$s::%2$s\n"
|
msgid "%1$s::%2$s\n"
|
||||||
msgstr "%1$s::%2$s\n"
|
msgstr "%1$s::%2$s\n"
|
||||||
|
|
||||||
#: src/log/normal.c:44 src/log/normal.c:110
|
#: src/log/normal.c:47 src/log/normal.c:121
|
||||||
#, c-format
|
#, c-format
|
||||||
msgid " %s\n"
|
msgid " %s\n"
|
||||||
msgstr " %s\n"
|
msgstr " %s\n"
|
||||||
|
|
||||||
#: src/log/normal.c:70
|
#: src/log/normal.c:76
|
||||||
#, c-format
|
#, c-format
|
||||||
msgid "%1$s::%2$s: Test is disabled\n"
|
msgid "%1$s::%2$s: Test is disabled\n"
|
||||||
msgstr "%1$s::%2$s: Le test est désactivé\n"
|
msgstr "%1$s::%2$s: Le test est désactivé\n"
|
||||||
|
|
||||||
#: src/log/normal.c:71
|
#: src/log/normal.c:77
|
||||||
#, c-format
|
#, c-format
|
||||||
msgid "%1$s::%2$s: Suite is disabled\n"
|
msgid "%1$s::%2$s: Suite is disabled\n"
|
||||||
msgstr "%1$s::%2$s: La suite est désactivée\n"
|
msgstr "%1$s::%2$s: La suite est désactivée\n"
|
||||||
|
|
||||||
#: src/log/normal.c:85
|
#: src/log/normal.c:94
|
||||||
#, c-format
|
#, c-format
|
||||||
msgid ""
|
msgid ""
|
||||||
"%1$sSynthesis: Tested: %2$s%3$lu%4$s | Passing: %5$s%6$lu%7$s | Failing: %8$s"
|
"%1$sSynthesis: Tested: %2$s%3$lu%4$s | Passing: %5$s%6$lu%7$s | Failing: %8$s"
|
||||||
|
@ -52,19 +52,26 @@ msgstr ""
|
||||||
"%1$sSynthèse: Testés: %2$s%3$lu%4$s | Validés: %5$s%6$lu%7$s | Échoués: %8$s"
|
"%1$sSynthèse: Testés: %2$s%3$lu%4$s | Validés: %5$s%6$lu%7$s | Échoués: %8$s"
|
||||||
"%9$lu%10$s | Plantages: %11$s%12$lu%13$s %14$s\n"
|
"%9$lu%10$s | Plantages: %11$s%12$lu%13$s %14$s\n"
|
||||||
|
|
||||||
#: src/log/normal.c:104
|
#: src/log/normal.c:115
|
||||||
#, c-format
|
#, c-format
|
||||||
msgid "%1$s%2$s%3$s:%4$s%5$d%6$s: Assertion failed: %7$s\n"
|
msgid "%1$s%2$s%3$s:%4$s%5$d%6$s: Assertion failed: %7$s\n"
|
||||||
msgstr "%1$s%2$s%3$s:%4$s%5$d%6$s: Échec d'assertion: %7$s\n"
|
msgstr "%1$s%2$s%3$s:%4$s%5$d%6$s: Échec d'assertion: %7$s\n"
|
||||||
|
|
||||||
#: src/log/normal.c:117
|
#: src/log/normal.c:128
|
||||||
#, c-format
|
#, c-format
|
||||||
msgid "%1$s%2$s%3$s:%4$s%5$u%6$s: Unexpected signal caught below this line!\n"
|
msgid "%1$s%2$s%3$s:%4$s%5$u%6$s: Unexpected signal caught below this line!\n"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"%1$s%2$s%3$s:%4$s%5$u%6$s: Un signal inattendu a été reçu après cette "
|
"%1$s%2$s%3$s:%4$s%5$u%6$s: Un signal inattendu a été reçu après cette "
|
||||||
"ligne!\n"
|
"ligne!\n"
|
||||||
|
|
||||||
#: src/log/normal.c:121
|
#: src/log/normal.c:132
|
||||||
#, c-format
|
#, c-format
|
||||||
msgid "%1$s::%2$s: CRASH!\n"
|
msgid "%1$s::%2$s: CRASH!\n"
|
||||||
msgstr "%1$s::%2$s: PLANTAGE!\n"
|
msgstr "%1$s::%2$s: PLANTAGE!\n"
|
||||||
|
|
||||||
|
#: src/log/normal.c:139
|
||||||
|
#, c-format
|
||||||
|
msgid "%1$sWarning! This test crashed during its setup or teardown.%2$s\n"
|
||||||
|
msgstr ""
|
||||||
|
"%1$sAttention! Ce test a planté pendant son initialisation ou sa "
|
||||||
|
"finalisation.%2$s\n"
|
||||||
|
|
|
@ -134,6 +134,12 @@ void normal_log_test_crash(struct criterion_test_stats *stats) {
|
||||||
stats->test->name);
|
stats->test->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void normal_log_other_crash(UNUSED struct criterion_test_stats *stats) {
|
||||||
|
criterion_pimportant(CRITERION_PREFIX_DASHES,
|
||||||
|
_("%1$sWarning! This test crashed during its setup or teardown.%2$s\n"),
|
||||||
|
FG_BOLD, RESET);
|
||||||
|
}
|
||||||
|
|
||||||
void normal_log_pre_suite(struct criterion_suite_set *set) {
|
void normal_log_pre_suite(struct criterion_suite_set *set) {
|
||||||
criterion_pinfo(CRITERION_PREFIX_EQUALS,
|
criterion_pinfo(CRITERION_PREFIX_EQUALS,
|
||||||
_s("Running %1$s%2$lu%3$s test from %4$s%5$s%6$s:\n",
|
_s("Running %1$s%2$lu%3$s test from %4$s%5$s%6$s:\n",
|
||||||
|
@ -149,6 +155,7 @@ struct criterion_output_provider normal_logging = {
|
||||||
.log_pre_suite = normal_log_pre_suite,
|
.log_pre_suite = normal_log_pre_suite,
|
||||||
.log_assert = normal_log_assert,
|
.log_assert = normal_log_assert,
|
||||||
.log_test_crash = normal_log_test_crash,
|
.log_test_crash = normal_log_test_crash,
|
||||||
|
.log_other_crash = normal_log_other_crash,
|
||||||
.log_post_test = normal_log_post_test,
|
.log_post_test = normal_log_post_test,
|
||||||
.log_post_suite = normal_log_post_suite,
|
.log_post_suite = normal_log_post_suite,
|
||||||
.log_post_all = normal_log_post_all,
|
.log_post_all = normal_log_post_all,
|
||||||
|
|
|
@ -50,9 +50,6 @@
|
||||||
IMPL_CALL_REPORT_HOOKS(Type); \
|
IMPL_CALL_REPORT_HOOKS(Type); \
|
||||||
ReportHook(Type)
|
ReportHook(Type)
|
||||||
|
|
||||||
#define log(Type, Arg) \
|
|
||||||
(criterion_options.output_provider->log_ ## Type ?: nothing)(Arg);
|
|
||||||
|
|
||||||
__attribute__((always_inline))
|
__attribute__((always_inline))
|
||||||
static inline void nothing() {}
|
static inline void nothing() {}
|
||||||
|
|
||||||
|
|
|
@ -43,4 +43,7 @@ DECL_CALL_REPORT_HOOKS(POST_FINI);
|
||||||
DECL_CALL_REPORT_HOOKS(POST_SUITE);
|
DECL_CALL_REPORT_HOOKS(POST_SUITE);
|
||||||
DECL_CALL_REPORT_HOOKS(POST_ALL);
|
DECL_CALL_REPORT_HOOKS(POST_ALL);
|
||||||
|
|
||||||
|
#define log(Type, Arg) \
|
||||||
|
(criterion_options.output_provider->log_ ## Type ?: nothing)(Arg);
|
||||||
|
|
||||||
#endif /* !REPORT_H_ */
|
#endif /* !REPORT_H_ */
|
||||||
|
|
20
src/runner.c
20
src/runner.c
|
@ -184,14 +184,20 @@ static void run_test(struct criterion_global_stats *stats,
|
||||||
if (proc == NULL && !is_runner())
|
if (proc == NULL && !is_runner())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
bool test_started = false;
|
||||||
|
bool normal_finish = false;
|
||||||
struct event *ev;
|
struct event *ev;
|
||||||
while ((ev = worker_read_event(proc)) != NULL) {
|
while ((ev = worker_read_event(proc)) != NULL) {
|
||||||
stat_push_event(stats, suite_stats, test_stats, ev);
|
stat_push_event(stats, suite_stats, test_stats, ev);
|
||||||
switch (ev->kind) {
|
switch (ev->kind) {
|
||||||
case PRE_INIT: report(PRE_INIT, test); break;
|
case PRE_INIT: report(PRE_INIT, test); break;
|
||||||
case PRE_TEST: report(PRE_TEST, test); break;
|
case PRE_TEST: report(PRE_TEST, test);
|
||||||
|
test_started = true;
|
||||||
|
break;
|
||||||
case ASSERT: report(ASSERT, ev->data); break;
|
case ASSERT: report(ASSERT, ev->data); break;
|
||||||
case POST_TEST: report(POST_TEST, test_stats); break;
|
case POST_TEST: report(POST_TEST, test_stats);
|
||||||
|
normal_finish = true;
|
||||||
|
break;
|
||||||
case POST_FINI: report(POST_FINI, test_stats); break;
|
case POST_FINI: report(POST_FINI, test_stats); break;
|
||||||
}
|
}
|
||||||
sfree(ev);
|
sfree(ev);
|
||||||
|
@ -199,6 +205,16 @@ static void run_test(struct criterion_global_stats *stats,
|
||||||
|
|
||||||
struct process_status status = wait_proc(proc);
|
struct process_status status = wait_proc(proc);
|
||||||
if (status.kind == SIGNAL) {
|
if (status.kind == SIGNAL) {
|
||||||
|
if (normal_finish || !test_started) {
|
||||||
|
log(other_crash, test_stats);
|
||||||
|
if (!test_started) {
|
||||||
|
stat_push_event(stats,
|
||||||
|
suite_stats,
|
||||||
|
test_stats,
|
||||||
|
&(struct event) { .kind = TEST_CRASH });
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
test_stats->signal = status.status;
|
test_stats->signal = status.status;
|
||||||
if (test->data->signal == 0) {
|
if (test->data->signal == 0) {
|
||||||
push_event(TEST_CRASH);
|
push_event(TEST_CRASH);
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
|
|
||||||
static void nothing() {};
|
static void nothing() {};
|
||||||
static void push_pre_suite();
|
static void push_pre_suite();
|
||||||
static void push_pre_test();
|
static void push_pre_init();
|
||||||
static void push_assert();
|
static void push_assert();
|
||||||
static void push_post_test();
|
static void push_post_test();
|
||||||
static void push_test_crash();
|
static void push_test_crash();
|
||||||
|
@ -81,8 +81,8 @@ void stat_push_event(s_glob_stats *stats,
|
||||||
static void (*const handles[])(s_glob_stats *, s_suite_stats *, s_test_stats *, void *) = {
|
static void (*const handles[])(s_glob_stats *, s_suite_stats *, s_test_stats *, void *) = {
|
||||||
nothing, // PRE_ALL
|
nothing, // PRE_ALL
|
||||||
push_pre_suite, // PRE_SUITE
|
push_pre_suite, // PRE_SUITE
|
||||||
nothing, // PRE_INIT
|
push_pre_init, // PRE_INIT
|
||||||
push_pre_test, // PRE_TEST
|
nothing, // PRE_TEST
|
||||||
push_assert, // ASSERT
|
push_assert, // ASSERT
|
||||||
push_test_crash, // TEST_CRASH
|
push_test_crash, // TEST_CRASH
|
||||||
push_post_test, // POST_TEST
|
push_post_test, // POST_TEST
|
||||||
|
@ -113,7 +113,7 @@ static inline bool is_disabled(struct criterion_test *t,
|
||||||
return t->data->disabled || (s->data && s->data->disabled);
|
return t->data->disabled || (s->data && s->data->disabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void push_pre_test(s_glob_stats *stats,
|
static void push_pre_init(s_glob_stats *stats,
|
||||||
s_suite_stats *suite,
|
s_suite_stats *suite,
|
||||||
s_test_stats *test,
|
s_test_stats *test,
|
||||||
UNUSED void *ptr) {
|
UNUSED void *ptr) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue