#include "test.h" #include #include #include #include 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); 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; } }