summaryrefslogtreecommitdiff
path: root/test/testpy
diff options
context:
space:
mode:
authorFedor Indutny <fedor@indutny.com>2014-12-17 20:34:21 +0700
committerFedor Indutny <fedor@indutny.com>2014-12-17 20:45:37 +0700
commitb7d247856e318a830eff7e2d12495008c1c80ae3 (patch)
tree78a7bf71876adbd7abc67504e9dc550229867826 /test/testpy
parent0e19476595729c850f07befea93e864822cd8459 (diff)
downloadnode-new-b7d247856e318a830eff7e2d12495008c1c80ae3.tar.gz
test: run tests in parallel, common improvements
* Allow running tests in mixed parallel/sequential modes * Add -J flag for running tests on all available CPUs * Support TEST_THREAD_ID in test/common.js and use it for tmpDir and PORT * make: use -J flag Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> PR-URL: https://github.com/iojs/io.js/pull/172 Fix: iojs/io.js#139
Diffstat (limited to 'test/testpy')
-rw-r--r--test/testpy/__init__.py27
1 files changed, 21 insertions, 6 deletions
diff --git a/test/testpy/__init__.py b/test/testpy/__init__.py
index cf64ba131c..a46e964a47 100644
--- a/test/testpy/__init__.py
+++ b/test/testpy/__init__.py
@@ -49,30 +49,34 @@ class SimpleTestCase(test.TestCase):
self.mode = mode
self.tmpdir = join(dirname(self.config.root), 'tmp')
self.additional_flags = additional
+
+ def GetTmpDir(self):
+ return "%s.%d" % (self.tmpdir, self.thread_id)
+
def AfterRun(self, result):
# delete the whole tmp dir
try:
- rmtree(self.tmpdir)
+ rmtree(self.GetTmpDir())
except:
pass
# make it again.
try:
- mkdir(self.tmpdir)
+ mkdir(self.GetTmpDir())
except:
pass
def BeforeRun(self):
# delete the whole tmp dir
try:
- rmtree(self.tmpdir)
+ rmtree(self.GetTmpDir())
except:
pass
# make it again.
# intermittently fails on win32, so keep trying
- while not os.path.exists(self.tmpdir):
+ while not os.path.exists(self.GetTmpDir()):
try:
- mkdir(self.tmpdir)
+ mkdir(self.GetTmpDir())
except:
pass
@@ -105,7 +109,6 @@ class SimpleTestCase(test.TestCase):
def GetSource(self):
return open(self.file).read()
-
class SimpleTestConfiguration(test.TestConfiguration):
def __init__(self, context, root, section, additional=[]):
@@ -136,6 +139,18 @@ class SimpleTestConfiguration(test.TestConfiguration):
if exists(status_file):
test.ReadConfigurationInto(status_file, sections, defs)
+class ParallelTestConfiguration(SimpleTestConfiguration):
+ def __init__(self, context, root, section, additional=[]):
+ super(ParallelTestConfiguration, self).__init__(context, root, section,
+ additional)
+
+ def ListTests(self, current_path, path, arch, mode):
+ result = super(ParallelTestConfiguration, self).ListTests(
+ current_path, path, arch, mode)
+ for test in result:
+ test.parallel = True
+ return result
+
class AddonTestConfiguration(SimpleTestConfiguration):
def __init__(self, context, root, section, additional=[]):
super(AddonTestConfiguration, self).__init__(context, root, section)