blob: 2b2bfae560a2888cb9b391e333a333b4e8863df9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
#include "test.h"
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
static bool any_failure = false;
void test_fail(const char *fmt, ...) {
any_failure = true;
fprintf(stderr, "\x1b[1m\x1b[91mFailure:\x1b[0m ");
va_list args;
va_start(args, fmt);
vfprintf(stderr, fmt, args);
va_end(args);
fprintf(stderr, "\n");
}
int main(int argc, char **argv) {
if (argc > 2 || (argc == 2 && strcmp(argv[1], "--help") == 0)) {
printf("usage: tests [TEST DIRECTORY]\n");
return EXIT_FAILURE;
}
const char *test_dir = argc == 2 ? argv[1] : "../tests";
test_parsing(test_dir);
test_errors(test_dir);
test_location(test_dir);
if (any_failure) {
fprintf(stderr, "\x1b[1m\x1b[91mSome tests failed.\x1b[0m\n");
return EXIT_FAILURE;
} else {
printf("\x1b[1m\x1b[92mAll tests OK\x1b[0m\n");
return 0;
}
}
|