[Zodb-checkins] CVS: ZODB3 - test.py:1.19.2.2

Jeremy Hylton jeremy at zope.com
Tue Apr 29 12:08:24 EDT 2003


Update of /cvs-repository/ZODB3
In directory cvs.zope.org:/tmp/cvs-serv15723

Modified Files:
      Tag: ZODB3-3_1-branch
	test.py 
Log Message:
Merge the latest and greatest test.py from Zope3.


=== ZODB3/test.py 1.19.2.1 => 1.19.2.2 === (735/835 lines abridged)
--- ZODB3/test.py:1.19.2.1	Thu Oct  3 19:18:01 2002
+++ ZODB3/test.py	Tue Apr 29 11:08:23 2003
@@ -1,55 +1,107 @@
+#! /usr/bin/env python2.1
 ##############################################################################
 #
-# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# Copyright (c) 2001 Zope Corporation and Contributors.
 # All Rights Reserved.
-# 
+#
 # This software is subject to the provisions of the Zope Public License,
 # Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
 # FOR A PARTICULAR PURPOSE.
-# 
+#
 ##############################################################################
 """
-test.py [-bCdgGLvv] [modfilter [testfilter]]
+test.py [-aBbcdDfgGhLmprtTuv] [modfilter [testfilter]]
 
 Test harness.
 
--b  build
-    Run "python setup.py -q build" before running tests, where "python"
+-a level
+--all
+    Run the tests at the given level.  Any test at a level at or below this is
+    run, any test at a level above this is not run.  Level 0 runs all tests.
+    The default is to run tests at level 1.  --all is a shortcut for -a 0.
+
+-b
+    Run "python setup.py build" before running tests, where "python"
     is the version of python used to run test.py.  Highly recommended.
+    Tests will be run from the build directory.  (Note: In Python < 2.3
+    the -q flag is added to the setup.py command line.)
 
--C  use pychecker
+-B
+    Run "python setup.py build_ext -i" before running tests.  Tests will be
+    run from the source directory.
 
--d  debug
+-c  use pychecker
+
+-d
     Instead of the normal test harness, run a debug version which

[-=- -=- -=- 735 lines omitted -=- -=- -=-]

-        cmd = sys.executable + " setup.py -q build"
+        # Python 2.3 is more sane in its non -q output
+        if sys.hexversion >= 0x02030000:
+            qflag = ""
+        else:
+            qflag = "-q"
+        cmd = sys.executable + " setup.py " + qflag + " build"
+        if build_inplace:
+            cmd += "_ext -i"
         if VERBOSE:
             print cmd
         sts = os.system(cmd)
@@ -360,14 +721,34 @@
             print "Build failed", hex(sts)
             sys.exit(1)
 
+    if VERBOSE:
+        kind = functional and "functional" or "unit"
+        if level == 0:
+            print "Running %s tests at all levels" % kind
+        else:
+            print "Running %s tests at level %d" % (kind, level)
+
     if args:
         if len(args) > 1:
             test_filter = args[1]
         module_filter = args[0]
     try:
-        bad = main(module_filter, test_filter)
-        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=1, summary=1, coverdir=coverdir)
+        else:
+            bad = main(module_filter, test_filter, libdir)
+            if bad:
+                sys.exit(1)
     except ImportError, err:
         print err
         print sys.path




More information about the Zodb-checkins mailing list