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

Fred L. Drake, Jr. fred at zope.com
Fri Jan 16 15:42:46 EST 2004


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

Modified Files:
      Tag: zope3-zodb3-devel-branch
	test.py 
Log Message:
allow --dir to be passed more than once to include different parts of
the source tree


=== Zope3/test.py 1.80 => 1.80.2.1 ===
--- Zope3/test.py:1.80	Fri Dec 12 17:24:02 2003
+++ Zope3/test.py	Fri Jan 16 15:42:45 2004
@@ -44,8 +44,10 @@
     test, so Use With Care.
 
 --dir directory
-    Option to limit where tests are searched for. This is
-    important when you *really* want to limit the code that gets run.
+    Option to limit where tests are searched for. This is important
+    when you *really* want to limit the code that gets run.  This can
+    be specified more than once to run tests in two different parts of
+    the source tree.
     For example, if refactoring interfaces, you don't want to see the way
     you have broken setups for tests in other packages. You *just* want to
     run the interface tests.
@@ -480,30 +482,27 @@
             if os.path.isdir(name):
                 walk_with_symlinks(name, func, arg)
 
-
-def check_test_dir():
-    global test_dir
-    if test_dir and not os.path.exists(test_dir):
-        d = pathinit.libdir
-        d = os.path.join(d, test_dir)
-        if os.path.exists(d):
-            if not os.path.isdir(d):
-                raise ValueError(
-                    "%s does not exist and %s is not a directory"
-                    % (test_dir, d)
-                    )
-            test_dir = d
-        else:
-            raise ValueError("%s does not exist!" % test_dir)
-
+def find_test_dir(dir):
+    if os.path.exists(dir):
+        return dir
+    d = os.path.join(pathinit.libdir, dir)
+    if os.path.exists(d):
+        if os.path.isdir(d):
+            return d
+        raise ValueError("%s does not exist and %s is not a directory"
+                         % (dir, d))
+    raise ValueError("%s does not exist!" % dir)
 
 def find_tests(rx):
     global finder
     finder = TestFileFinder(pathinit.libdir)
 
-    check_test_dir()
-    walkdir = test_dir or pathinit.libdir
-    walk_with_symlinks(walkdir, finder.visit, rx)
+    if test_dirs:
+        for d in test_dirs:
+            d = find_test_dir(d)
+            walk_with_symlinks(d, finder.visit, rx)
+    else:
+        walk_with_symlinks(pathinit.libdir, finder.visit, rx)
     return finder.files
 
 def package_import(modname):
@@ -715,7 +714,7 @@
     global build_inplace
     global keepStaleBytecode
     global functional
-    global test_dir
+    global test_dirs
     global profile
 
     if argv is None:
@@ -742,7 +741,7 @@
     timetests = 0
     keepStaleBytecode = 0
     functional = False
-    test_dir = None
+    test_dirs = []
     profile = False
 
     try:
@@ -819,7 +818,7 @@
                 # must be a filename to write
                 timesfn = v
         elif k == '--dir':
-            test_dir = v
+            test_dirs.append(v)
 
     if sys.version_info < ( 2,3,2 ):
 	print """\




More information about the Zope3-Checkins mailing list