Exit with a nonzero status if the tests fail.
authorMarien Zwart <marienz@gentoo.org>
Wed, 5 Apr 2006 15:20:51 +0000 (17:20 +0200)
committerMarien Zwart <marienz@gentoo.org>
Wed, 5 Apr 2006 15:20:51 +0000 (17:20 +0200)
test.py

diff --git a/test.py b/test.py
index 8913c1f835b6797d412a36d2e22b6bfef204d100..3d7161be22478fb8755044eaa60348db09a09d02 100644 (file)
--- a/test.py
+++ b/test.py
@@ -3,18 +3,28 @@ import doctest
 import sys
 if len(sys.argv) > 1:
     match = False
+    libbe_failures = libbe_tries = becommands_failures = becommands_tries = 0
     mod = plugin.get_plugin("libbe", sys.argv[1])
     if mod is not None:
-        doctest.testmod(mod)
+        libbe_failures, libbe_tries = doctest.testmod(mod)
         match = True
     mod = plugin.get_plugin("becommands", sys.argv[1])
     if mod is not None:
-        doctest.testmod(mod)
+        becommands_failures, becommands_tries = doctest.testmod(mod)
         match = True
     if not match:
         print "No modules match \"%s\"" % sys.argv[1]
-else:    
+        sys.exit(1)
+    else:
+        sys.exit(libbe_failures or becommands_failures)
+else:
+    failed = False
     for module in plugin.iter_plugins("libbe"):
-        doctest.testmod(module[1])
+        failures, tries = doctest.testmod(module[1])
+        if failures:
+            failed = True
     for module in plugin.iter_plugins("becommands"):
-        doctest.testmod(module[1])
+        failures, tries = doctest.testmod(module[1])
+        if failures:
+            failed = True
+    sys.exit(failed)