Commit 8be25c87 authored by Jim Fulton's avatar Jim Fulton

Added layer declarations to take advantage of the test runner's

ability to run layers in parallel.  This reduces test run time my more
than 75% for me.
parent 216f69be
...@@ -22,6 +22,7 @@ import unittest ...@@ -22,6 +22,7 @@ import unittest
# Import the actual test class # Import the actual test class
from ZEO.tests import ConnectionTests, InvalidationTests from ZEO.tests import ConnectionTests, InvalidationTests
from zope.testing import doctest, setupstack from zope.testing import doctest, setupstack
import ZODB.tests.util
class FileStorageConfig: class FileStorageConfig:
def getConfig(self, path, create, read_only): def getConfig(self, path, create, read_only):
...@@ -139,6 +140,7 @@ def test_suite(): ...@@ -139,6 +140,7 @@ def test_suite():
'invalidations_while_connecting.test', 'invalidations_while_connecting.test',
setUp=setupstack.setUpDirectory, tearDown=setupstack.tearDown, setUp=setupstack.setUpDirectory, tearDown=setupstack.tearDown,
)) ))
suite.layer = ZODB.tests.util.MininalTestLayer('ZEO Connection Tests')
return suite return suite
......
...@@ -1099,10 +1099,13 @@ test_classes = [FileStorageTests, FileStorageRecoveryTests, ...@@ -1099,10 +1099,13 @@ test_classes = [FileStorageTests, FileStorageRecoveryTests,
def test_suite(): def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(ZODB.tests.util.AAAA_Test_Runner_Hack))
suite.addTest(doctest.DocTestSuite( suite.addTest(doctest.DocTestSuite(
setUp=zope.testing.setupstack.setUpDirectory, setUp=zope.testing.setupstack.setUpDirectory,
tearDown=zope.testing.setupstack.tearDown)) tearDown=zope.testing.setupstack.tearDown))
suite.addTest(doctest.DocFileSuite('registerDB.test')) suite.addTest(doctest.DocFileSuite(
'registerDB.test'
))
suite.addTest( suite.addTest(
doctest.DocFileSuite('zeo-fan-out.test', doctest.DocFileSuite('zeo-fan-out.test',
setUp=zope.testing.setupstack.setUpDirectory, setUp=zope.testing.setupstack.setUpDirectory,
...@@ -1111,6 +1114,7 @@ def test_suite(): ...@@ -1111,6 +1114,7 @@ def test_suite():
) )
for klass in test_classes: for klass in test_classes:
sub = unittest.makeSuite(klass, "check") sub = unittest.makeSuite(klass, "check")
sub.layer = ZODB.tests.util.MininalTestLayer(klass.__name__)
suite.addTest(sub) suite.addTest(sub)
return suite return suite
......
...@@ -61,3 +61,33 @@ class P(persistent.Persistent): ...@@ -61,3 +61,33 @@ class P(persistent.Persistent):
def __repr__(self): def __repr__(self):
return 'P(%s)' % self.name return 'P(%s)' % self.name
class MininalTestLayer:
__bases__ = ()
__module__ = ''
def __init__(self, name):
self.__name__ = name
def setUp(self):
self.here = os.getcwd()
self.tmp = tempfile.mkdtemp(self.__name__, dir=os.getcwd())
os.chdir(self.tmp)
def tearDown(self):
os.chdir(self.here)
zope.testing.setupstack.rmtree(self.tmp)
testSetUp = testTearDown = lambda self: None
class AAAA_Test_Runner_Hack(unittest.TestCase):
"""Hack to work around a bug in the test runner.
The first later (lex sorted) is run first in the foreground
"""
layer = MininalTestLayer('!no tests here!')
def testNothing(self):
pass
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment