[CMF-checkins] CVS: CMF - all_cmf_tests.py:1.4
Tres Seaver
tseaver@zope.com
Sun, 30 Jun 2002 18:27:03 -0400
Update of /cvs-repository/CMF
In directory cvs.zope.org:/tmp/cvs-serv26893
Modified Files:
all_cmf_tests.py
Log Message:
- Extend bare-bones test runner to permit running only selected packages.
Note that the runner needs to be able to 'import Zope', which implies
that the SOFTWARE_HOME, INSTANCE_HOME, and PYTHONPATH need to be set
in the environment before starting it.
=== CMF/all_cmf_tests.py 1.3 => 1.4 ===
-from unittest import TestSuite,main
-from Products.CMFCore.tests.base.utils import build_test_suite
-
-def test_suite():
-
- return TestSuite((
- build_test_suite('Products.CMFCore.tests',['test_all']),
- build_test_suite('Products.CMFDefault.tests',['test_all']),
- build_test_suite('Products.CMFTopic.tests',['test_all']),
- build_test_suite('Products.CMFCalendar.tests',['test_all'],required=0),
- build_test_suite('Products.CMFDecor.tests',['test_all'],required=0),
- build_test_suite('Products.DCWorkflow.tests',['test_all'],required=0),
- ))
+#! /usr/bin/env python
+import unittest
+import sys
+
+# PackageName Required?
+CMF_PACKAGES = [ ( 'CMFCore', 1 )
+ , ( 'CMFDefault', 1 )
+ , ( 'CMFTopic', 1 )
+ , ( 'CMFCalendar', 0 )
+ , ( 'DCWorkflow', 0 )
+ ]
+
+PACKAGES_UNDER_TEST = []
+
+def test_suite():
+
+ import Zope
+ from Products.CMFCore.tests.base.utils import build_test_suite
+
+ suite = unittest.TestSuite()
+
+ packages = PACKAGES_UNDER_TEST or CMF_PACKAGES
+
+ for package_name, required in packages:
+ dotted = 'Products.%s.tests' % package_name
+ suite.addTest( build_test_suite( dotted
+ , [ 'test_all' ]
+ , required=required
+ ) )
+
+ return suite
+
+def usage():
+
+ USAGE = """\
+all_cmf_tests.py [-?] <package_name>*
+
+where
+
+ package_name is the list of packages to be tested
+ default: %s
+"""
+
+ print USAGE % CMF_PACKAGES
+ sys.exit( 2 )
+
+def main():
+
+ import getopt
+
+ try:
+ opts, args = getopt.getopt( sys.argv[1:], 'v?' )
+ except getopt.GetoptError:
+ usage()
+
+ sys.argv[ 1: ] = []
+ PASSTHROUGH = ( '-v', )
+
+ for k, v in opts:
+
+ if k in PASSTHROUGH:
+ sys.argv.append( k )
+
+ if k == '-?' or k == '--help':
+ usage()
+
+ for arg in args:
+ PACKAGES_UNDER_TEST.append( ( arg, 1 ) )
+
+ unittest.main(defaultTest='test_suite')
if __name__ == '__main__':
- main(defaultTest='test_suite')
+ main()