[Zope3-checkins] CVS: Zope3 - test.py:1.39

Jeremy Hylton jeremy@zope.com
Wed, 12 Mar 2003 18:39:26 -0500


Update of /cvs-repository/Zope3
In directory cvs.zope.org:/tmp/cvs-serv2929

Modified Files:
	test.py 
Log Message:
Start trace mode earlier in test, so that module imports are traced.


=== Zope3/test.py 1.38 => 1.39 ===
--- Zope3/test.py:1.38	Mon Feb 24 17:57:24 2003
+++ Zope3/test.py	Wed Mar 12 18:39:22 2003
@@ -476,15 +476,6 @@
     elif LOOP:
         while True:
             runner(files, test_filter, debug)
-    elif TRACE:
-        coverdir = os.path.join(os.getcwd(), "coverage")
-        import trace
-        tracer = trace.Trace(ignoredirs=[sys.prefix, sys.exec_prefix],
-                             trace=0, count=1)
-        tracer.runctx("runner(files, test_filter, debug)",
-                      globals=globals(), locals=vars())
-        r = tracer.results()
-        r.write_results(show_missing=True, summary=True, coverdir=coverdir)
     else:
         runner(files, test_filter, debug)
 
@@ -631,9 +622,22 @@
             test_filter = args[1]
         module_filter = args[0]
     try:
-        bad = main(module_filter, test_filter, libdir)
-        if bad:
-            sys.exit(1)
+        if TRACE:
+            # if the trace module is used, then we don't exit with
+            # status if on a false return value from main.
+            coverdir = os.path.join(os.getcwd(), "coverage")
+            import trace
+            tracer = trace.Trace(ignoredirs=[sys.prefix, sys.exec_prefix],
+                                 trace=0, count=1)
+
+            tracer.runctx("main(module_filter, test_filter, libdir)",
+                          globals=globals(), locals=vars())
+            r = tracer.results()
+            r.write_results(show_missing=True, summary=True, coverdir=coverdir)
+        else:
+            bad = main(module_filter, test_filter, libdir)
+            if bad:
+                sys.exit(1)
     except ImportError, err:
         print err
         print sys.path