Rename print_test_result and exit on any failing function
This commit is contained in:
parent
8c153b5321
commit
d9cf98da73
@ -6,15 +6,15 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
internal void print_test_result(TerminalColourist *colourist,
|
||||
TestFuncResult result);
|
||||
internal void handle_test_result(TerminalColourist *colourist,
|
||||
TestFuncResult result);
|
||||
|
||||
void run_tests(TestFunc *func1, ...) {
|
||||
TerminalColourist colourist = wapp_termcolour_get_colourist();
|
||||
|
||||
printf("\n");
|
||||
|
||||
print_test_result(&colourist, func1());
|
||||
handle_test_result(&colourist, func1());
|
||||
|
||||
va_list args;
|
||||
va_start(args, func1);
|
||||
@ -23,11 +23,7 @@ void run_tests(TestFunc *func1, ...) {
|
||||
|
||||
while (func) {
|
||||
TestFuncResult result = func();
|
||||
print_test_result(&colourist, result);
|
||||
|
||||
if (!result.passed) {
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
handle_test_result(&colourist, result);
|
||||
|
||||
func = va_arg(args, TestFunc *);
|
||||
}
|
||||
@ -37,8 +33,8 @@ void run_tests(TestFunc *func1, ...) {
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
internal void print_test_result(TerminalColourist *colourist,
|
||||
TestFuncResult result) {
|
||||
internal void handle_test_result(TerminalColourist *colourist,
|
||||
TestFuncResult result) {
|
||||
TerminalColour colour;
|
||||
const char *result_text;
|
||||
|
||||
@ -54,4 +50,8 @@ internal void print_test_result(TerminalColourist *colourist,
|
||||
wapp_termcolour_print_text(colourist, result_text, colour);
|
||||
wapp_termcolour_clear_colour(colourist);
|
||||
printf("] %s\n", result.name);
|
||||
|
||||
if (!result.passed) {
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user