Commit bc57b80b by Vicent Marti

Update to Clay 0.10.0

Comes with support for global events; this fixes #496.
parent b5daae68
...@@ -57,6 +57,8 @@ void cl_fixture_cleanup(const char *fixture_name); ...@@ -57,6 +57,8 @@ void cl_fixture_cleanup(const char *fixture_name);
/** /**
* Test method declarations * Test method declarations
*/ */
extern void clay_on_init(void);
extern void clay_on_shutdown(void);
extern void test_buf_basic__printf(void); extern void test_buf_basic__printf(void);
extern void test_buf_basic__resize(void); extern void test_buf_basic__resize(void);
extern void test_config_add__cleanup(void); extern void test_config_add__cleanup(void);
......
#include "clay_libgit2.h"
void clay_on_init(void)
{
git_threads_init();
}
void clay_on_shutdown(void)
{
git_threads_shutdown();
}
...@@ -103,6 +103,10 @@ static void clay_print_onabort(const char *msg, ...); ...@@ -103,6 +103,10 @@ static void clay_print_onabort(const char *msg, ...);
static void clay_unsandbox(void); static void clay_unsandbox(void);
static int clay_sandbox(void); static int clay_sandbox(void);
/* Event callback overrides */
#define clay_on_test() /* nop */
#define clay_on_suite() /* nop */
/* Autogenerated test data by clay */ /* Autogenerated test data by clay */
static const struct clay_func _clay_cb_buf_basic[] = { static const struct clay_func _clay_cb_buf_basic[] = {
{"printf", &test_buf_basic__printf}, {"printf", &test_buf_basic__printf},
...@@ -528,6 +532,7 @@ clay_run_test( ...@@ -528,6 +532,7 @@ clay_run_test(
{ {
int error_st = _clay.suite_errors; int error_st = _clay.suite_errors;
clay_on_test();
_clay.trampoline_enabled = 1; _clay.trampoline_enabled = 1;
if (setjmp(_clay.trampoline) == 0) { if (setjmp(_clay.trampoline) == 0) {
...@@ -583,6 +588,7 @@ clay_run_suite(const struct clay_suite *suite) ...@@ -583,6 +588,7 @@ clay_run_suite(const struct clay_suite *suite)
size_t i; size_t i;
clay_print_onsuite(suite->name); clay_print_onsuite(suite->name);
clay_on_suite();
_clay.active_suite = suite->name; _clay.active_suite = suite->name;
_clay.suite_errors = 0; _clay.suite_errors = 0;
...@@ -661,11 +667,12 @@ clay_test(int argc, char **argv) ...@@ -661,11 +667,12 @@ clay_test(int argc, char **argv)
); );
if (clay_sandbox() < 0) { if (clay_sandbox() < 0) {
fprintf(stderr, clay_print_onabort("Failed to sandbox the test runner.\n");
"Failed to sandbox the test runner.\n" exit(-1);
"Testing will proceed without sandboxing.\n");
} }
clay_on_init();
if (argc > 1) { if (argc > 1) {
clay_parse_args(argc, argv); clay_parse_args(argc, argv);
} else { } else {
...@@ -675,11 +682,13 @@ clay_test(int argc, char **argv) ...@@ -675,11 +682,13 @@ clay_test(int argc, char **argv)
} }
clay_print_shutdown( clay_print_shutdown(
(int)_clay_callback_count, _clay.test_count,
(int)_clay_suite_count, (int)_clay_suite_count,
_clay.total_errors _clay.total_errors
); );
clay_on_shutdown();
clay_unsandbox(); clay_unsandbox();
return _clay.total_errors; return _clay.total_errors;
} }
...@@ -1049,10 +1058,10 @@ cl_fs_cleanup(void) ...@@ -1049,10 +1058,10 @@ cl_fs_cleanup(void)
static void clay_print_init(int test_count, int suite_count, const char *suite_names) static void clay_print_init(int test_count, int suite_count, const char *suite_names)
{ {
(void)test_count;
(void)suite_names; (void)suite_names;
(void)suite_count; (void)suite_count;
printf("TAP version 13\n"); printf("TAP version 13\n");
printf("1..%d\n", test_count);
} }
static void clay_print_shutdown(int test_count, int suite_count, int error_count) static void clay_print_shutdown(int test_count, int suite_count, int error_count)
...@@ -1061,7 +1070,12 @@ static void clay_print_shutdown(int test_count, int suite_count, int error_count ...@@ -1061,7 +1070,12 @@ static void clay_print_shutdown(int test_count, int suite_count, int error_count
(void)suite_count; (void)suite_count;
(void)error_count; (void)error_count;
printf("\n"); if (!error_count)
printf("# passed all %d test(s)\n", test_count);
else
printf("# failed %d among %d test(s)\n", error_count,
test_count);
printf("1..%d\n", test_count);
} }
static void clay_print_error(int num, const struct clay_error *error) static void clay_print_error(int num, const struct clay_error *error)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment