mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
gh-109566: regrtest reexecutes the process (#109909)
When --fast-ci or --slow-ci option is used, regrtest now replaces the current process with a new process to add "-u -W default -bb -E" options to Python. Changes: * PCbuild/rt.bat and Tools/scripts/run_tests.py no longer need to add "-u -W default -bb -E" options to Python: it's now done by regrtest. * Fix Tools/scripts/run_tests.py: flush stdout before replacing the process. Previously, buffered messages were lost.
This commit is contained in:
parent
ecd813f054
commit
fbfec5642e
7 changed files with 107 additions and 14 deletions
|
@ -382,7 +382,8 @@ class ParseArgsTestCase(unittest.TestCase):
|
|||
# Check Regrtest attributes which are more reliable than Namespace
|
||||
# which has an unclear API
|
||||
regrtest = main.Regrtest(ns)
|
||||
self.assertNotEqual(regrtest.num_workers, 0)
|
||||
self.assertTrue(regrtest.ci_mode)
|
||||
self.assertEqual(regrtest.num_workers, -1)
|
||||
self.assertTrue(regrtest.want_rerun)
|
||||
self.assertTrue(regrtest.randomize)
|
||||
self.assertIsNone(regrtest.random_seed)
|
||||
|
@ -1960,6 +1961,61 @@ class ArgsTestCase(BaseTestCase):
|
|||
self.check_executed_tests(output, tests,
|
||||
stats=len(tests), parallel=True)
|
||||
|
||||
def check_reexec(self, option):
|
||||
# --fast-ci and --slow-ci add "-u -W default -bb -E" options to Python
|
||||
code = textwrap.dedent(r"""
|
||||
import sys
|
||||
import unittest
|
||||
try:
|
||||
from _testinternalcapi import get_config
|
||||
except ImportError:
|
||||
get_config = None
|
||||
|
||||
class WorkerTests(unittest.TestCase):
|
||||
@unittest.skipUnless(get_config is None, 'need get_config()')
|
||||
def test_config(self):
|
||||
config = get_config()['config']
|
||||
# -u option
|
||||
self.assertEqual(config['buffered_stdio'], 0)
|
||||
# -W default option
|
||||
self.assertTrue(config['warnoptions'], ['default'])
|
||||
# -bb option
|
||||
self.assertTrue(config['bytes_warning'], 2)
|
||||
# -E option
|
||||
self.assertTrue(config['use_environment'], 0)
|
||||
|
||||
# test if get_config() is not available
|
||||
def test_unbuffered(self):
|
||||
# -u option
|
||||
self.assertFalse(sys.stdout.line_buffering)
|
||||
self.assertFalse(sys.stderr.line_buffering)
|
||||
|
||||
def test_python_opts(self):
|
||||
# -W default option
|
||||
self.assertTrue(sys.warnoptions, ['default'])
|
||||
# -bb option
|
||||
self.assertEqual(sys.flags.bytes_warning, 2)
|
||||
# -E option
|
||||
self.assertTrue(sys.flags.ignore_environment)
|
||||
""")
|
||||
testname = self.create_test(code=code)
|
||||
|
||||
cmd = [sys.executable,
|
||||
"-m", "test", option,
|
||||
f'--testdir={self.tmptestdir}',
|
||||
testname]
|
||||
proc = subprocess.run(cmd,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT,
|
||||
text=True)
|
||||
self.assertEqual(proc.returncode, 0, proc)
|
||||
|
||||
def test_reexec_fast_ci(self):
|
||||
self.check_reexec("--fast-ci")
|
||||
|
||||
def test_reexec_slow_ci(self):
|
||||
self.check_reexec("--slow-ci")
|
||||
|
||||
|
||||
class TestUtils(unittest.TestCase):
|
||||
def test_format_duration(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue