[glib] gtester: Return a failure exit code when a test fails



commit 4a25d6002341df796e13643695478a4ecb4c7a49
Author: Benjamin Otte <otte gnome org>
Date:   Mon Jul 18 13:39:36 2011 +0200

    gtester: Return a failure exit code when a test fails
    
    Previously, gtester used the testcase_fail_count as the number of tests
    that failed in the latest run testcase, but then use that as the return
    value of main().
    
    Now we count the failed testcases of the whole run.

 glib/gtester.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/glib/gtester.c b/glib/gtester.c
index 12e576c..28fac8d 100644
--- a/glib/gtester.c
+++ b/glib/gtester.c
@@ -113,7 +113,7 @@ testcase_close (long double duration,
     g_print ("GTester: last random seed: %s\n", subtest_last_seed);
   if (exit_status)
     testcase_fail_count += 1;
-  if (subtest_mode_fatal && testcase_fail_count)
+  if (subtest_mode_fatal && exit_status)
     terminate();
 }
 
@@ -418,8 +418,8 @@ launch_test (const char *binary)
   gboolean success = TRUE;
   GTimer *btimer = g_timer_new();
   gboolean need_restart;
+
   testcase_count = 0;
-  testcase_fail_count = 0;
   if (!gtester_quiet)
     g_print ("TEST: %s... ", binary);
 
@@ -446,7 +446,7 @@ launch_test (const char *binary)
     }
 
   if (!gtester_quiet)
-    g_print ("%s: %s\n", testcase_fail_count || !success ? "FAIL" : "PASS", binary);
+    g_print ("%s: %s\n", !success ? "FAIL" : "PASS", binary);
   g_timer_destroy (btimer);
   if (subtest_mode_fatal && !success)
     terminate();
@@ -681,7 +681,7 @@ main (int    argc,
 
   close (log_fd);
 
-  return testcase_fail_count == 0 ? 0 : 1;
+  return testcase_fail_count == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
 }
 
 static void



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]