Commit 87d82994be88effef0f1ff22d01bd8310a9167e4

Vicent Marti 2011-02-02T02:32:21

Make the test return an error code on failure Signed-off-by: Vicent Marti <tanoku@gmail.com>

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;
 }