Make the test return an error code on failure Signed-off-by: Vicent Marti <tanoku@gmail.com>
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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
diff --git a/tests/test_lib.c b/tests/test_lib.c
index 3c3d7e5..eb13cd8 100755
--- a/tests/test_lib.c
+++ b/tests/test_lib.c
@@ -157,7 +157,7 @@ static void print_details(git_testsuite *ts)
}
}
-void git_testsuite_run(git_testsuite *ts)
+int git_testsuite_run(git_testsuite *ts)
{
int i;
@@ -175,5 +175,7 @@ void git_testsuite_run(git_testsuite *ts)
}
printf("\n ");
print_details(ts);
+
+ return ts->fail_count;
}
diff --git a/tests/test_lib.h b/tests/test_lib.h
index 099ed8a..ae384ba 100755
--- a/tests/test_lib.h
+++ b/tests/test_lib.h
@@ -10,7 +10,7 @@
#include <git2.h>
#define ADD_TEST(SUITE, MODULE, TEST) \
- git_testsuite_add(SUITE, git_test_new(#TEST " (" MODULE ")", &_gittest__##TEST))
+ git_testsuite_add(SUITE, git_test_new(MODULE "::" #TEST, &_gittest__##TEST))
#define BEGIN_TEST(MODULE, TEST) \
void _gittest__##TEST(git_test *_gittest) \
@@ -38,7 +38,7 @@ void git_testsuite_free(git_testsuite *ts);
void git_testsuite_add(git_testsuite *ts, git_test *tc);
void git_testsuite_addsuite(git_testsuite* ts, git_testsuite *ts2);
-void git_testsuite_run(git_testsuite *ts);
+int git_testsuite_run(git_testsuite *ts);
#endif
diff --git a/tests/test_main.c b/tests/test_main.c
index 5769967..5ffbf61 100644
--- a/tests/test_main.c
+++ b/tests/test_main.c
@@ -87,18 +87,20 @@ void libgit2_free_suites(git_testsuite **suites)
int main(int GIT_UNUSED(argc), char *GIT_UNUSED(argv[]))
{
- unsigned int i;
+ unsigned int i, failures;
git_testsuite **suites;
GIT_UNUSED_ARG(argc);
GIT_UNUSED_ARG(argv);
suites = libgit2_get_suites();
+ failures = 0;
for (i = 0; i < GIT_SUITE_COUNT; ++i)
- git_testsuite_run(suites[i]);
+ failures += git_testsuite_run(suites[i]);
libgit2_free_suites(suites);
- return 0;
+
+ return failures ? -1 : 0;
}