Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(26)

Unified Diff: Lib/test/test_regrtest.py

Issue 26295: Random failures when running test suite in parallel (-m test -j0) caused by test_regrtest
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Lib/test/libregrtest/setup.py ('k') | Lib/test/test_zipfile.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Lib/test/test_regrtest.py Tue Mar 15 23:08:44 2016 +0100
+++ b/Lib/test/test_regrtest.py Tue Mar 15 23:21:00 2016 +0100
@@ -15,6 +15,7 @@ import re
import subprocess
import sys
import sysconfig
+import tempfile
import textwrap
import unittest
from test import libregrtest
@@ -306,9 +307,18 @@ class BaseTestCase(unittest.TestCase):
TESTNAME_PREFIX = 'test_regrtest_'
TESTNAME_REGEX = r'test_[a-z0-9_]+'
+ def create_testdir(self):
+ self.tmpdir = tempfile.mkdtemp()
+ self.addCleanup(support.rmtree, self.tmpdir)
+
+ self.tmptestdir = os.path.join(self.tmpdir, 'test')
+ os.mkdir(self.tmptestdir)
+
def setUp(self):
self.testdir = os.path.realpath(os.path.dirname(__file__))
+ self.create_testdir()
+
# When test_regrtest is interrupted by CTRL+c, it can leave
# temporary test files
remove = [entry.path
@@ -327,7 +337,7 @@ class BaseTestCase(unittest.TestCase):
# test_regrtest cannot be run twice in parallel because
# of setUp() and create_test()
name = self.TESTNAME_PREFIX + "%s_%s" % (os.getpid(), name)
- path = os.path.join(self.testdir, name + '.py')
+ path = os.path.join(self.tmptestdir, name + '.py')
self.addCleanup(support.unlink, path)
# Use 'x' mode to ensure that we do not override existing tests
@@ -461,7 +471,7 @@ class ProgramsTestCase(BaseTestCase):
self.tests = [self.create_test() for index in range(self.NTEST)]
self.python_args = ['-Wd', '-E', '-bb']
- self.regrtest_args = ['-uall', '-rwW']
+ self.regrtest_args = ['-uall', '-rwW', '--testdir=%s' % self.tmptestdir]
if hasattr(faulthandler, 'dump_traceback_later'):
self.regrtest_args.extend(('--timeout', '3600', '-j4'))
if sys.platform == 'win32':
@@ -518,7 +528,8 @@ class ProgramsTestCase(BaseTestCase):
def test_tools_script_run_tests(self):
# Tools/scripts/run_tests.py
script = os.path.join(ROOT_DIR, 'Tools', 'scripts', 'run_tests.py')
- self.run_tests([script, *self.tests])
+ args = [script, '--testdir=%s' % self.tmptestdir, *self.tests]
+ self.run_tests(args)
def run_batch(self, *args):
proc = self.run_command(args)
@@ -554,8 +565,9 @@ class ArgsTestCase(BaseTestCase):
Test arguments of the Python test suite.
"""
- def run_tests(self, *args, **kw):
- return self.run_python(['-m', 'test', *args], **kw)
+ def run_tests(self, *testargs, **kw):
+ cmdargs = ['-m', 'test', '--testdir=%s' % self.tmptestdir, *testargs]
+ return self.run_python(cmdargs, **kw)
def test_failing_test(self):
# test a failing test
« no previous file with comments | « Lib/test/libregrtest/setup.py ('k') | Lib/test/test_zipfile.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+