]> gitweb.michael.orlitzky.com - dunshire.git/blobdiff - test/__main__.py
Build looping into the test suite and make doctests optional.
[dunshire.git] / test / __main__.py
old mode 100644 (file)
new mode 100755 (executable)
index 175c884..aca4e64
@@ -1,3 +1,34 @@
+#!/usr/bin/env python
+"""
+An implementation of __main__() that allows us to "run this module."
+"""
+from sys import argv
+
 from test import build_suite, run_suite
 
-run_suite(build_suite())
+# We take two command-line arguments. The first enables you to turn
+# off the doctests, which are deterministic. The second tells us to
+# repeat the test suite indefinitely rather than return the result
+# of running it once. The flags usually occur together so that we
+# don't waste time running the doctests in a loop.
+doctests = True
+loop = False
+
+if "--no-doctests" in argv:
+    doctests = False
+
+if "--loop" in argv:
+    loop = True
+
+# Running the test suite clobbers it! And deepcopy() doesn't work on a
+# suite that contains doctests! ARRRGRRGRRGRHG!!!!!! You're all idiots.
+result = run_suite(build_suite(doctests))
+
+if result.wasSuccessful() and not loop:
+    exit(0)
+
+if loop:
+    while(result.wasSuccessful()):
+        result = run_suite(build_suite(doctests))
+
+exit(1)