2012-12-27 18:53:12 -08:00
|
|
|
"""
|
|
|
|
|
Tests of regrtest.py.
|
2015-09-28 23:16:17 +02:00
|
|
|
|
|
|
|
|
Note: test_regrtest cannot be run twice in parallel.
|
2012-12-27 18:53:12 -08:00
|
|
|
"""
|
|
|
|
|
|
2015-10-11 10:04:26 +02:00
|
|
|
import contextlib
|
2019-07-23 22:28:48 -07:00
|
|
|
import glob
|
2015-10-11 10:03:28 +02:00
|
|
|
import io
|
2023-06-28 04:58:34 +02:00
|
|
|
import locale
|
2013-08-29 12:26:23 +03:00
|
|
|
import os.path
|
2015-09-28 23:16:17 +02:00
|
|
|
import platform
|
|
|
|
|
import re
|
|
|
|
|
import subprocess
|
|
|
|
|
import sys
|
2015-11-22 15:18:54 +01:00
|
|
|
import sysconfig
|
2016-03-30 02:33:52 +02:00
|
|
|
import tempfile
|
2015-09-28 23:16:17 +02:00
|
|
|
import textwrap
|
2021-07-22 20:25:58 +02:00
|
|
|
import time
|
2012-12-27 18:53:12 -08:00
|
|
|
import unittest
|
2015-09-26 10:38:01 +02:00
|
|
|
from test import libregrtest
|
|
|
|
|
from test import support
|
[3.11] gh-108822: Backport libregrtest changes from the main branch (#108820)
* Revert "[3.11] gh-101634: regrtest reports decoding error as failed test (#106169) (#106175)"
This reverts commit d5418e97fc524420011a370ba3c2c3cf6a89a74f.
* Revert "[3.11] bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (GH-30895) (GH-103342)"
This reverts commit ecb09a849689764193e0115d27e220f82b5f6d9f.
* Revert "gh-95027: Fix regrtest stdout encoding on Windows (GH-98492)"
This reverts commit b2aa28eec56d07b9c6777b02b7247cf21839de9f.
* Revert "[3.11] gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253) (GH-94408)"
This reverts commit 0122ab235b5acb52dd99fd05d8802a00f438b828.
* Revert "Run Tools/scripts/reindent.py (GH-94225)"
This reverts commit f0f3a424afb00a15ce8c0140dd218f5b33929be6.
* Revert "gh-94052: Don't re-run failed tests with --python option (GH-94054)"
This reverts commit 1347607db12012f6458ffcba48d8ad797083812e.
* Revert "[3.11] gh-84461: Fix Emscripten umask and permission issues (GH-94002) (GH-94006)"
This reverts commit 10731849184a3101ed18683b0128d689f1671c3f.
* gh-93353: regrtest checks for leaked temporary files (#93776)
When running tests with -jN, create a temporary directory per process
and mark a test as "environment changed" if a test leaks a temporary
file or directory.
(cherry picked from commit e566ce5496f1bad81c431aaee65e36d5e44771c5)
* gh-93353: Fix regrtest for -jN with N >= 2 (GH-93813)
(cherry picked from commit 36934a16e86f34d69ba2d41630fb5b4d06d59cff)
* gh-93353: regrtest supports checking tmp files with -j2 (#93909)
regrtest now also implements checking for leaked temporary files and
directories when using -jN for N >= 2. Use tempfile.mkdtemp() to
create the temporary directory. Skip this check on WASI.
(cherry picked from commit 4f85cec9e2077681b3dacc3108e646d509b720bf)
* gh-84461: Fix Emscripten umask and permission issues (GH-94002)
- Emscripten's default umask is too strict, see
https://github.com/emscripten-core/emscripten/issues/17269
- getuid/getgid and geteuid/getegid are stubs that always return 0
(root). Disable effective uid/gid syscalls and fix tests that use
chmod() current user.
- Cannot drop X bit from directory.
(cherry picked from commit 2702e408fd0e0dd7aec396b4cf8c7ce9caae81d8)
* gh-94052: Don't re-run failed tests with --python option (#94054)
(cherry picked from commit 0ff7b996f5d836e63cdaf652c7aa734285261096)
* Run Tools/scripts/reindent.py (#94225)
Reindent files which were not properly formatted (PEP 8: 4 spaces).
Remove also some trailing spaces.
(cherry picked from commit e87ada48a9e5d9d03f9759138869216df0d7383a)
* gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253)
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 199ba233248ab279f445e0809c2077976f0711bc)
* gh-96465: Clear fractions hash lru_cache under refleak testing (GH-96689)
Automerge-Triggered-By: GH:zware
(cherry picked from commit 9c8f3794337457b1d905a9fa0f38c2978fe32abd)
* gh-95027: Fix regrtest stdout encoding on Windows (#98492)
On Windows, when the Python test suite is run with the -jN option,
the ANSI code page is now used as the encoding for the stdout
temporary file, rather than using UTF-8 which can lead to decoding
errors.
(cherry picked from commit ec1f6f5f139868dc2c1116a7c7c878c38c668d53)
* gh-98903: Test suite fails with exit code 4 if no tests ran (#98904)
The Python test suite now fails wit exit code 4 if no tests ran. It
should help detecting typos in test names and test methods.
* Add "EXITCODE_" constants to Lib/test/libregrtest/main.py.
* Fix a typo: "NO TEST RUN" becomes "NO TESTS RAN"
(cherry picked from commit c76db37c0d23174cbffd6fa978d39693890ef020)
* gh-100086: Add build info to test.libregrtest (#100093)
The Python test runner (libregrtest) now logs Python build information like
"debug" vs "release" build, or LTO and PGO optimizations.
(cherry picked from commit 3c892022472eb975360fb3f0caa6f6fcc6fbf220)
* bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (#30895)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
(cherry picked from commit 995386071f96e4cfebfa027a71ca9134e4651d2a)
* gh-82054: allow test runner to split test_asyncio to execute in parallel by sharding. (#103927)
This runs test_asyncio sub-tests in parallel using sharding from Cinder. This suite is typically the longest-pole in runs because it is a test package with a lot of further sub-tests otherwise run serially. By breaking out the sub-tests as independent modules we can run a lot more in parallel.
After porting we can see the direct impact on a multicore system.
Without this change:
Running make test is 5 min 26 seconds
With this change:
Running make test takes 3 min 39 seconds
That'll vary based on system and parallelism. On a `-j 4` run similar to what CI and buildbot systems often do, it reduced the overall test suite completion latency by 10%.
The drawbacks are that this implementation is hacky and due to the sorting of the tests it obscures when the asyncio tests occur and involves changing CPython test infrastructure but, the wall time saved it is worth it, especially in low-core count CI runs as it pulls a long tail. The win for productivity and reserved CI resource usage is significant.
Future tests that deserve to be refactored into split up suites to benefit from are test_concurrent_futures and the way the _test_multiprocessing suite gets run for all start methods. As exposed by passing the -o flag to python -m test to get a list of the 10 longest running tests.
---------
Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google, LLC]
(cherry picked from commit 9e011e7c77dad7d0bbb944c44891531606caeb21)
* Display the sanitizer config in the regrtest header. (#105301)
Display the sanitizers present in libregrtest.
Having this in the CI output for tests with the relevant environment
variable displayed will help make it easier to do what we need to
create an equivalent local test run.
(cherry picked from commit 852348ab65783601e0844b6647ea033668b45c11)
* gh-101634: regrtest reports decoding error as failed test (#106169)
When running the Python test suite with -jN option, if a worker stdout
cannot be decoded from the locale encoding report a failed testn so the
exitcode is non-zero.
(cherry picked from commit 2ac3eec103cf450aaaebeb932e51155d2e7fb37b)
* gh-108223: test.pythoninfo and libregrtest log Py_NOGIL (#108238)
Enable with --disable-gil --without-pydebug:
$ make pythoninfo|grep NOGIL
sysconfig[Py_NOGIL]: 1
$ ./python -m test
...
== Python build: nogil debug
...
(cherry picked from commit 5afe0c17ca14df430736e549542a4b85e7e7c7ac)
* gh-90791: test.pythoninfo logs ASAN_OPTIONS env var (#108289)
* Cleanup libregrtest code logging ASAN_OPTIONS.
* Fix a typo on "ASAN_OPTIONS" vs "MSAN_OPTIONS".
(cherry picked from commit 3a1ac87f8f89d3206b46a0df4908afae629d669d)
* gh-108388: regrtest splits test_asyncio package (#108393)
Currently, test_asyncio package is only splitted into sub-tests when
using command "./python -m test". With this change, it's also
splitted when passing it on the command line:
"./python -m test test_asyncio".
Remove the concept of "STDTESTS". Python is now mature enough to not
have to bother with that anymore. Removing STDTESTS simplify the
code.
(cherry picked from commit 174e9da0836844a2138cc8915dd305cb2cd7a583)
* regrtest computes statistics (#108793)
test_netrc, test_pep646_syntax and test_xml_etree now return results
in the test_main() function.
Changes:
* Rewrite TestResult as a dataclass with a new State class.
* Add test.support.TestStats class and Regrtest.stats_dict attribute.
* libregrtest.runtest functions now modify a TestResult instance
in-place.
* libregrtest summary lists the number of run tests and skipped
tests, and denied resources.
* Add TestResult.has_meaningful_duration() method.
* Compute TestResult duration in the upper function.
* Use time.perf_counter() instead of time.monotonic().
* Regrtest: rename 'resource_denieds' attribute to 'resource_denied'.
* Rename CHILD_ERROR to MULTIPROCESSING_ERROR.
* Use match/case syntadx to have different code depending on the
test state.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit d4e534cbb35678c82b3a1276826af55d7bfc23b6)
* gh-108822: Add Changelog entry for regrtest statistics (#108821)
---------
Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Zachary Ware <zach@python.org>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Joshua Herman <zitterbewegung@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-09-03 19:21:53 +02:00
|
|
|
from test.support import os_helper, TestStats
|
2021-07-16 15:24:02 +02:00
|
|
|
from test.libregrtest import utils, setup
|
2012-12-27 18:53:12 -08:00
|
|
|
|
2022-01-25 09:09:06 +02:00
|
|
|
if not support.has_subprocess_support:
|
|
|
|
|
raise unittest.SkipTest("test module requires subprocess")
|
2012-12-27 18:53:12 -08:00
|
|
|
|
2019-04-25 01:46:31 +02:00
|
|
|
Py_DEBUG = hasattr(sys, 'gettotalrefcount')
|
2015-09-28 23:16:17 +02:00
|
|
|
ROOT_DIR = os.path.join(os.path.dirname(__file__), '..', '..')
|
|
|
|
|
ROOT_DIR = os.path.abspath(os.path.normpath(ROOT_DIR))
|
2019-10-03 16:15:16 +02:00
|
|
|
LOG_PREFIX = r'[0-9]+:[0-9]+:[0-9]+ (?:load avg: [0-9]+\.[0-9]{2} )?'
|
2015-09-28 23:16:17 +02:00
|
|
|
|
2023-04-07 19:35:16 +02:00
|
|
|
EXITCODE_BAD_TEST = 2
|
|
|
|
|
EXITCODE_ENV_CHANGED = 3
|
|
|
|
|
EXITCODE_NO_TESTS_RAN = 4
|
|
|
|
|
EXITCODE_INTERRUPTED = 130
|
|
|
|
|
|
2015-10-11 10:37:25 +02:00
|
|
|
TEST_INTERRUPTED = textwrap.dedent("""
|
2019-04-26 09:28:53 +02:00
|
|
|
from signal import SIGINT, raise_signal
|
2015-10-11 10:37:25 +02:00
|
|
|
try:
|
|
|
|
|
raise_signal(SIGINT)
|
|
|
|
|
except ImportError:
|
|
|
|
|
import os
|
|
|
|
|
os.kill(os.getpid(), SIGINT)
|
|
|
|
|
""")
|
|
|
|
|
|
2015-09-28 23:16:17 +02:00
|
|
|
|
|
|
|
|
class ParseArgsTestCase(unittest.TestCase):
|
|
|
|
|
"""
|
|
|
|
|
Test regrtest's argument parsing, function _parse_args().
|
|
|
|
|
"""
|
2012-12-27 18:53:12 -08:00
|
|
|
|
2013-08-29 12:26:23 +03:00
|
|
|
def checkError(self, args, msg):
|
|
|
|
|
with support.captured_stderr() as err, self.assertRaises(SystemExit):
|
2015-09-26 10:38:01 +02:00
|
|
|
libregrtest._parse_args(args)
|
2013-08-29 12:26:23 +03:00
|
|
|
self.assertIn(msg, err.getvalue())
|
2012-12-27 18:53:12 -08:00
|
|
|
|
2013-08-29 12:26:23 +03:00
|
|
|
def test_help(self):
|
|
|
|
|
for opt in '-h', '--help':
|
|
|
|
|
with self.subTest(opt=opt):
|
|
|
|
|
with support.captured_stdout() as out, \
|
|
|
|
|
self.assertRaises(SystemExit):
|
2015-09-26 10:38:01 +02:00
|
|
|
libregrtest._parse_args([opt])
|
2013-08-29 12:26:23 +03:00
|
|
|
self.assertIn('Run Python regression tests.', out.getvalue())
|
2012-12-27 18:53:12 -08:00
|
|
|
|
2013-08-29 12:26:23 +03:00
|
|
|
def test_timeout(self):
|
2015-09-26 10:38:01 +02:00
|
|
|
ns = libregrtest._parse_args(['--timeout', '4.2'])
|
2013-08-29 12:26:23 +03:00
|
|
|
self.assertEqual(ns.timeout, 4.2)
|
|
|
|
|
self.checkError(['--timeout'], 'expected one argument')
|
|
|
|
|
self.checkError(['--timeout', 'foo'], 'invalid float value')
|
2012-12-27 18:53:12 -08:00
|
|
|
|
2013-08-29 12:26:23 +03:00
|
|
|
def test_wait(self):
|
2015-09-26 10:38:01 +02:00
|
|
|
ns = libregrtest._parse_args(['--wait'])
|
2013-08-29 12:26:23 +03:00
|
|
|
self.assertTrue(ns.wait)
|
2012-12-27 18:53:12 -08:00
|
|
|
|
2018-09-07 17:20:42 +02:00
|
|
|
def test_worker_args(self):
|
|
|
|
|
ns = libregrtest._parse_args(['--worker-args', '[[], {}]'])
|
|
|
|
|
self.assertEqual(ns.worker_args, '[[], {}]')
|
|
|
|
|
self.checkError(['--worker-args'], 'expected one argument')
|
2012-12-27 18:53:12 -08:00
|
|
|
|
2013-08-29 12:26:23 +03:00
|
|
|
def test_start(self):
|
|
|
|
|
for opt in '-S', '--start':
|
|
|
|
|
with self.subTest(opt=opt):
|
2015-09-26 10:38:01 +02:00
|
|
|
ns = libregrtest._parse_args([opt, 'foo'])
|
2013-08-29 12:26:23 +03:00
|
|
|
self.assertEqual(ns.start, 'foo')
|
|
|
|
|
self.checkError([opt], 'expected one argument')
|
2012-12-27 18:53:12 -08:00
|
|
|
|
2013-08-29 12:26:23 +03:00
|
|
|
def test_verbose(self):
|
2015-09-26 10:38:01 +02:00
|
|
|
ns = libregrtest._parse_args(['-v'])
|
2013-08-29 12:26:23 +03:00
|
|
|
self.assertEqual(ns.verbose, 1)
|
2015-09-26 10:38:01 +02:00
|
|
|
ns = libregrtest._parse_args(['-vvv'])
|
2013-08-29 12:26:23 +03:00
|
|
|
self.assertEqual(ns.verbose, 3)
|
2015-09-26 10:38:01 +02:00
|
|
|
ns = libregrtest._parse_args(['--verbose'])
|
2013-08-29 12:26:23 +03:00
|
|
|
self.assertEqual(ns.verbose, 1)
|
2015-09-26 10:38:01 +02:00
|
|
|
ns = libregrtest._parse_args(['--verbose'] * 3)
|
2013-08-29 12:26:23 +03:00
|
|
|
self.assertEqual(ns.verbose, 3)
|
2015-09-26 10:38:01 +02:00
|
|
|
ns = libregrtest._parse_args([])
|
2013-08-29 12:26:23 +03:00
|
|
|
self.assertEqual(ns.verbose, 0)
|
2012-12-27 18:53:12 -08:00
|
|
|
|
2013-08-29 12:26:23 +03:00
|
|
|
def test_verbose2(self):
|
|
|
|
|
for opt in '-w', '--verbose2':
|
|
|
|
|
with self.subTest(opt=opt):
|
2015-09-26 10:38:01 +02:00
|
|
|
ns = libregrtest._parse_args([opt])
|
2013-08-29 12:26:23 +03:00
|
|
|
self.assertTrue(ns.verbose2)
|
2012-12-27 18:53:12 -08:00
|
|
|
|
2013-08-29 12:26:23 +03:00
|
|
|
def test_verbose3(self):
|
|
|
|
|
for opt in '-W', '--verbose3':
|
|
|
|
|
with self.subTest(opt=opt):
|
2015-09-26 10:38:01 +02:00
|
|
|
ns = libregrtest._parse_args([opt])
|
2013-08-29 12:26:23 +03:00
|
|
|
self.assertTrue(ns.verbose3)
|
2012-12-27 18:53:12 -08:00
|
|
|
|
2013-08-29 12:26:23 +03:00
|
|
|
def test_quiet(self):
|
|
|
|
|
for opt in '-q', '--quiet':
|
|
|
|
|
with self.subTest(opt=opt):
|
2015-09-26 10:38:01 +02:00
|
|
|
ns = libregrtest._parse_args([opt])
|
2013-08-29 12:26:23 +03:00
|
|
|
self.assertTrue(ns.quiet)
|
|
|
|
|
self.assertEqual(ns.verbose, 0)
|
2012-12-27 18:53:12 -08:00
|
|
|
|
2019-04-26 04:08:53 +02:00
|
|
|
def test_slowest(self):
|
2016-08-17 11:25:43 +02:00
|
|
|
for opt in '-o', '--slowest':
|
2013-08-29 12:26:23 +03:00
|
|
|
with self.subTest(opt=opt):
|
2015-09-26 10:38:01 +02:00
|
|
|
ns = libregrtest._parse_args([opt])
|
2013-08-29 12:26:23 +03:00
|
|
|
self.assertTrue(ns.print_slow)
|
|
|
|
|
|
|
|
|
|
def test_header(self):
|
2015-09-26 10:38:01 +02:00
|
|
|
ns = libregrtest._parse_args(['--header'])
|
2013-08-29 12:26:23 +03:00
|
|
|
self.assertTrue(ns.header)
|
|
|
|
|
|
2017-05-04 15:21:12 +02:00
|
|
|
ns = libregrtest._parse_args(['--verbose'])
|
|
|
|
|
self.assertTrue(ns.header)
|
|
|
|
|
|
2013-08-29 12:26:23 +03:00
|
|
|
def test_randomize(self):
|
|
|
|
|
for opt in '-r', '--randomize':
|
|
|
|
|
with self.subTest(opt=opt):
|
2015-09-26 10:38:01 +02:00
|
|
|
ns = libregrtest._parse_args([opt])
|
2013-08-29 12:26:23 +03:00
|
|
|
self.assertTrue(ns.randomize)
|
|
|
|
|
|
|
|
|
|
def test_randseed(self):
|
2015-09-26 10:38:01 +02:00
|
|
|
ns = libregrtest._parse_args(['--randseed', '12345'])
|
2013-08-29 12:26:23 +03:00
|
|
|
self.assertEqual(ns.random_seed, 12345)
|
|
|
|
|
self.assertTrue(ns.randomize)
|
|
|
|
|
self.checkError(['--randseed'], 'expected one argument')
|
|
|
|
|
self.checkError(['--randseed', 'foo'], 'invalid int value')
|
2012-12-27 18:53:12 -08:00
|
|
|
|
|
|
|
|
def test_fromfile(self):
|
2013-08-29 12:26:23 +03:00
|
|
|
for opt in '-f', '--fromfile':
|
|
|
|
|
with self.subTest(opt=opt):
|
2015-09-26 10:38:01 +02:00
|
|
|
ns = libregrtest._parse_args([opt, 'foo'])
|
2013-08-29 12:26:23 +03:00
|
|
|
self.assertEqual(ns.fromfile, 'foo')
|
|
|
|
|
self.checkError([opt], 'expected one argument')
|
|
|
|
|
self.checkError([opt, 'foo', '-s'], "don't go together")
|
|
|
|
|
|
|
|
|
|
def test_exclude(self):
|
|
|
|
|
for opt in '-x', '--exclude':
|
|
|
|
|
with self.subTest(opt=opt):
|
2015-09-26 10:38:01 +02:00
|
|
|
ns = libregrtest._parse_args([opt])
|
2013-08-29 12:26:23 +03:00
|
|
|
self.assertTrue(ns.exclude)
|
|
|
|
|
|
|
|
|
|
def test_single(self):
|
|
|
|
|
for opt in '-s', '--single':
|
|
|
|
|
with self.subTest(opt=opt):
|
2015-09-26 10:38:01 +02:00
|
|
|
ns = libregrtest._parse_args([opt])
|
2013-08-29 12:26:23 +03:00
|
|
|
self.assertTrue(ns.single)
|
|
|
|
|
self.checkError([opt, '-f', 'foo'], "don't go together")
|
2012-12-27 18:53:12 -08:00
|
|
|
|
2019-11-19 23:46:49 +00:00
|
|
|
def test_ignore(self):
|
|
|
|
|
for opt in '-i', '--ignore':
|
|
|
|
|
with self.subTest(opt=opt):
|
|
|
|
|
ns = libregrtest._parse_args([opt, 'pattern'])
|
|
|
|
|
self.assertEqual(ns.ignore_tests, ['pattern'])
|
|
|
|
|
self.checkError([opt], 'expected one argument')
|
|
|
|
|
|
2020-06-30 21:46:06 +08:00
|
|
|
self.addCleanup(os_helper.unlink, os_helper.TESTFN)
|
|
|
|
|
with open(os_helper.TESTFN, "w") as fp:
|
2019-11-19 23:46:49 +00:00
|
|
|
print('matchfile1', file=fp)
|
|
|
|
|
print('matchfile2', file=fp)
|
|
|
|
|
|
2020-06-30 21:46:06 +08:00
|
|
|
filename = os.path.abspath(os_helper.TESTFN)
|
2019-11-19 23:46:49 +00:00
|
|
|
ns = libregrtest._parse_args(['-m', 'match',
|
|
|
|
|
'--ignorefile', filename])
|
|
|
|
|
self.assertEqual(ns.ignore_tests,
|
|
|
|
|
['matchfile1', 'matchfile2'])
|
|
|
|
|
|
2012-12-27 18:53:12 -08:00
|
|
|
def test_match(self):
|
2013-08-29 12:26:23 +03:00
|
|
|
for opt in '-m', '--match':
|
|
|
|
|
with self.subTest(opt=opt):
|
2015-09-26 10:38:01 +02:00
|
|
|
ns = libregrtest._parse_args([opt, 'pattern'])
|
2017-06-09 10:18:48 +02:00
|
|
|
self.assertEqual(ns.match_tests, ['pattern'])
|
2013-08-29 12:26:23 +03:00
|
|
|
self.checkError([opt], 'expected one argument')
|
2012-12-27 18:53:12 -08:00
|
|
|
|
2017-06-09 10:18:48 +02:00
|
|
|
ns = libregrtest._parse_args(['-m', 'pattern1',
|
|
|
|
|
'-m', 'pattern2'])
|
|
|
|
|
self.assertEqual(ns.match_tests, ['pattern1', 'pattern2'])
|
|
|
|
|
|
2020-06-30 21:46:06 +08:00
|
|
|
self.addCleanup(os_helper.unlink, os_helper.TESTFN)
|
|
|
|
|
with open(os_helper.TESTFN, "w") as fp:
|
2017-06-09 10:18:48 +02:00
|
|
|
print('matchfile1', file=fp)
|
|
|
|
|
print('matchfile2', file=fp)
|
|
|
|
|
|
2020-06-30 21:46:06 +08:00
|
|
|
filename = os.path.abspath(os_helper.TESTFN)
|
2017-06-09 10:18:48 +02:00
|
|
|
ns = libregrtest._parse_args(['-m', 'match',
|
|
|
|
|
'--matchfile', filename])
|
|
|
|
|
self.assertEqual(ns.match_tests,
|
|
|
|
|
['match', 'matchfile1', 'matchfile2'])
|
|
|
|
|
|
2013-08-29 12:26:23 +03:00
|
|
|
def test_failfast(self):
|
|
|
|
|
for opt in '-G', '--failfast':
|
|
|
|
|
with self.subTest(opt=opt):
|
2015-09-26 10:38:01 +02:00
|
|
|
ns = libregrtest._parse_args([opt, '-v'])
|
2013-08-29 12:26:23 +03:00
|
|
|
self.assertTrue(ns.failfast)
|
2015-09-26 10:38:01 +02:00
|
|
|
ns = libregrtest._parse_args([opt, '-W'])
|
2013-08-29 12:26:23 +03:00
|
|
|
self.assertTrue(ns.failfast)
|
|
|
|
|
self.checkError([opt], '-G/--failfast needs either -v or -W')
|
|
|
|
|
|
|
|
|
|
def test_use(self):
|
|
|
|
|
for opt in '-u', '--use':
|
|
|
|
|
with self.subTest(opt=opt):
|
2015-09-26 10:38:01 +02:00
|
|
|
ns = libregrtest._parse_args([opt, 'gui,network'])
|
2013-08-29 12:26:23 +03:00
|
|
|
self.assertEqual(ns.use_resources, ['gui', 'network'])
|
2017-07-20 15:46:32 +02:00
|
|
|
|
2015-09-26 10:38:01 +02:00
|
|
|
ns = libregrtest._parse_args([opt, 'gui,none,network'])
|
2013-08-29 12:26:23 +03:00
|
|
|
self.assertEqual(ns.use_resources, ['network'])
|
2017-07-20 15:46:32 +02:00
|
|
|
|
|
|
|
|
expected = list(libregrtest.ALL_RESOURCES)
|
2013-08-29 12:26:23 +03:00
|
|
|
expected.remove('gui')
|
2015-09-26 10:38:01 +02:00
|
|
|
ns = libregrtest._parse_args([opt, 'all,-gui'])
|
2013-08-29 12:26:23 +03:00
|
|
|
self.assertEqual(ns.use_resources, expected)
|
|
|
|
|
self.checkError([opt], 'expected one argument')
|
|
|
|
|
self.checkError([opt, 'foo'], 'invalid resource')
|
|
|
|
|
|
2017-07-20 15:46:32 +02:00
|
|
|
# all + a resource not part of "all"
|
|
|
|
|
ns = libregrtest._parse_args([opt, 'all,tzdata'])
|
|
|
|
|
self.assertEqual(ns.use_resources,
|
|
|
|
|
list(libregrtest.ALL_RESOURCES) + ['tzdata'])
|
|
|
|
|
|
|
|
|
|
# test another resource which is not part of "all"
|
|
|
|
|
ns = libregrtest._parse_args([opt, 'extralargefile'])
|
|
|
|
|
self.assertEqual(ns.use_resources, ['extralargefile'])
|
|
|
|
|
|
2013-08-29 12:26:23 +03:00
|
|
|
def test_memlimit(self):
|
|
|
|
|
for opt in '-M', '--memlimit':
|
|
|
|
|
with self.subTest(opt=opt):
|
2015-09-26 10:38:01 +02:00
|
|
|
ns = libregrtest._parse_args([opt, '4G'])
|
2013-08-29 12:26:23 +03:00
|
|
|
self.assertEqual(ns.memlimit, '4G')
|
|
|
|
|
self.checkError([opt], 'expected one argument')
|
|
|
|
|
|
|
|
|
|
def test_testdir(self):
|
2015-09-26 10:38:01 +02:00
|
|
|
ns = libregrtest._parse_args(['--testdir', 'foo'])
|
2020-06-30 21:46:06 +08:00
|
|
|
self.assertEqual(ns.testdir, os.path.join(os_helper.SAVEDCWD, 'foo'))
|
2013-08-29 12:26:23 +03:00
|
|
|
self.checkError(['--testdir'], 'expected one argument')
|
|
|
|
|
|
2013-09-29 15:18:43 -04:00
|
|
|
def test_runleaks(self):
|
2013-08-29 12:26:23 +03:00
|
|
|
for opt in '-L', '--runleaks':
|
|
|
|
|
with self.subTest(opt=opt):
|
2015-09-26 10:38:01 +02:00
|
|
|
ns = libregrtest._parse_args([opt])
|
2013-08-29 12:26:23 +03:00
|
|
|
self.assertTrue(ns.runleaks)
|
2012-12-27 18:53:12 -08:00
|
|
|
|
2013-09-29 15:18:43 -04:00
|
|
|
def test_huntrleaks(self):
|
2013-08-29 12:26:23 +03:00
|
|
|
for opt in '-R', '--huntrleaks':
|
|
|
|
|
with self.subTest(opt=opt):
|
2015-09-26 10:38:01 +02:00
|
|
|
ns = libregrtest._parse_args([opt, ':'])
|
2013-08-29 12:26:23 +03:00
|
|
|
self.assertEqual(ns.huntrleaks, (5, 4, 'reflog.txt'))
|
2015-09-26 10:38:01 +02:00
|
|
|
ns = libregrtest._parse_args([opt, '6:'])
|
2013-08-29 12:26:23 +03:00
|
|
|
self.assertEqual(ns.huntrleaks, (6, 4, 'reflog.txt'))
|
2015-09-26 10:38:01 +02:00
|
|
|
ns = libregrtest._parse_args([opt, ':3'])
|
2013-08-29 12:26:23 +03:00
|
|
|
self.assertEqual(ns.huntrleaks, (5, 3, 'reflog.txt'))
|
2015-09-26 10:38:01 +02:00
|
|
|
ns = libregrtest._parse_args([opt, '6:3:leaks.log'])
|
2013-08-29 12:26:23 +03:00
|
|
|
self.assertEqual(ns.huntrleaks, (6, 3, 'leaks.log'))
|
|
|
|
|
self.checkError([opt], 'expected one argument')
|
|
|
|
|
self.checkError([opt, '6'],
|
|
|
|
|
'needs 2 or 3 colon-separated arguments')
|
|
|
|
|
self.checkError([opt, 'foo:'], 'invalid huntrleaks value')
|
|
|
|
|
self.checkError([opt, '6:foo'], 'invalid huntrleaks value')
|
|
|
|
|
|
|
|
|
|
def test_multiprocess(self):
|
|
|
|
|
for opt in '-j', '--multiprocess':
|
|
|
|
|
with self.subTest(opt=opt):
|
2015-09-26 10:38:01 +02:00
|
|
|
ns = libregrtest._parse_args([opt, '2'])
|
2013-08-29 12:26:23 +03:00
|
|
|
self.assertEqual(ns.use_mp, 2)
|
|
|
|
|
self.checkError([opt], 'expected one argument')
|
|
|
|
|
self.checkError([opt, 'foo'], 'invalid int value')
|
|
|
|
|
self.checkError([opt, '2', '-T'], "don't go together")
|
2016-12-19 21:01:33 +08:00
|
|
|
self.checkError([opt, '0', '-T'], "don't go together")
|
2013-08-29 12:26:23 +03:00
|
|
|
|
2013-09-29 15:18:43 -04:00
|
|
|
def test_coverage(self):
|
2013-08-29 12:26:23 +03:00
|
|
|
for opt in '-T', '--coverage':
|
|
|
|
|
with self.subTest(opt=opt):
|
2015-09-26 10:38:01 +02:00
|
|
|
ns = libregrtest._parse_args([opt])
|
2013-08-29 12:26:23 +03:00
|
|
|
self.assertTrue(ns.trace)
|
|
|
|
|
|
|
|
|
|
def test_coverdir(self):
|
|
|
|
|
for opt in '-D', '--coverdir':
|
|
|
|
|
with self.subTest(opt=opt):
|
2015-09-26 10:38:01 +02:00
|
|
|
ns = libregrtest._parse_args([opt, 'foo'])
|
2013-08-29 12:26:23 +03:00
|
|
|
self.assertEqual(ns.coverdir,
|
2020-06-30 21:46:06 +08:00
|
|
|
os.path.join(os_helper.SAVEDCWD, 'foo'))
|
2013-08-29 12:26:23 +03:00
|
|
|
self.checkError([opt], 'expected one argument')
|
|
|
|
|
|
|
|
|
|
def test_nocoverdir(self):
|
|
|
|
|
for opt in '-N', '--nocoverdir':
|
|
|
|
|
with self.subTest(opt=opt):
|
2015-09-26 10:38:01 +02:00
|
|
|
ns = libregrtest._parse_args([opt])
|
2013-08-29 12:26:23 +03:00
|
|
|
self.assertIsNone(ns.coverdir)
|
|
|
|
|
|
|
|
|
|
def test_threshold(self):
|
|
|
|
|
for opt in '-t', '--threshold':
|
|
|
|
|
with self.subTest(opt=opt):
|
2015-09-26 10:38:01 +02:00
|
|
|
ns = libregrtest._parse_args([opt, '1000'])
|
2013-08-29 12:26:23 +03:00
|
|
|
self.assertEqual(ns.threshold, 1000)
|
|
|
|
|
self.checkError([opt], 'expected one argument')
|
|
|
|
|
self.checkError([opt, 'foo'], 'invalid int value')
|
|
|
|
|
|
|
|
|
|
def test_nowindows(self):
|
|
|
|
|
for opt in '-n', '--nowindows':
|
|
|
|
|
with self.subTest(opt=opt):
|
2015-10-11 10:04:26 +02:00
|
|
|
with contextlib.redirect_stderr(io.StringIO()) as stderr:
|
|
|
|
|
ns = libregrtest._parse_args([opt])
|
2013-08-29 12:26:23 +03:00
|
|
|
self.assertTrue(ns.nowindows)
|
2015-10-11 10:04:26 +02:00
|
|
|
err = stderr.getvalue()
|
|
|
|
|
self.assertIn('the --nowindows (-n) option is deprecated', err)
|
2013-08-29 12:26:23 +03:00
|
|
|
|
|
|
|
|
def test_forever(self):
|
|
|
|
|
for opt in '-F', '--forever':
|
|
|
|
|
with self.subTest(opt=opt):
|
2015-09-26 10:38:01 +02:00
|
|
|
ns = libregrtest._parse_args([opt])
|
2013-08-29 12:26:23 +03:00
|
|
|
self.assertTrue(ns.forever)
|
|
|
|
|
|
|
|
|
|
def test_unrecognized_argument(self):
|
|
|
|
|
self.checkError(['--xxx'], 'usage:')
|
|
|
|
|
|
|
|
|
|
def test_long_option__partial(self):
|
2015-09-26 10:38:01 +02:00
|
|
|
ns = libregrtest._parse_args(['--qui'])
|
2013-08-29 12:26:23 +03:00
|
|
|
self.assertTrue(ns.quiet)
|
|
|
|
|
self.assertEqual(ns.verbose, 0)
|
|
|
|
|
|
|
|
|
|
def test_two_options(self):
|
2015-09-26 10:38:01 +02:00
|
|
|
ns = libregrtest._parse_args(['--quiet', '--exclude'])
|
2013-08-29 12:26:23 +03:00
|
|
|
self.assertTrue(ns.quiet)
|
|
|
|
|
self.assertEqual(ns.verbose, 0)
|
|
|
|
|
self.assertTrue(ns.exclude)
|
|
|
|
|
|
|
|
|
|
def test_option_with_empty_string_value(self):
|
2015-09-26 10:38:01 +02:00
|
|
|
ns = libregrtest._parse_args(['--start', ''])
|
2013-08-29 12:26:23 +03:00
|
|
|
self.assertEqual(ns.start, '')
|
|
|
|
|
|
|
|
|
|
def test_arg(self):
|
2015-09-26 10:38:01 +02:00
|
|
|
ns = libregrtest._parse_args(['foo'])
|
2013-08-29 12:26:23 +03:00
|
|
|
self.assertEqual(ns.args, ['foo'])
|
|
|
|
|
|
|
|
|
|
def test_option_and_arg(self):
|
2015-09-26 10:38:01 +02:00
|
|
|
ns = libregrtest._parse_args(['--quiet', 'foo'])
|
2013-08-29 12:26:23 +03:00
|
|
|
self.assertTrue(ns.quiet)
|
|
|
|
|
self.assertEqual(ns.verbose, 0)
|
|
|
|
|
self.assertEqual(ns.args, ['foo'])
|
2012-12-27 18:53:12 -08:00
|
|
|
|
2016-10-17 18:11:03 +02:00
|
|
|
def test_arg_option_arg(self):
|
2016-10-17 18:13:46 +02:00
|
|
|
ns = libregrtest._parse_args(['test_unaryop', '-v', 'test_binop'])
|
2016-10-17 18:11:03 +02:00
|
|
|
self.assertEqual(ns.verbose, 1)
|
|
|
|
|
self.assertEqual(ns.args, ['test_unaryop', 'test_binop'])
|
|
|
|
|
|
|
|
|
|
def test_unknown_option(self):
|
|
|
|
|
self.checkError(['--unknown-option'],
|
|
|
|
|
'unrecognized arguments: --unknown-option')
|
|
|
|
|
|
2012-12-27 18:53:12 -08:00
|
|
|
|
2015-09-28 23:16:17 +02:00
|
|
|
class BaseTestCase(unittest.TestCase):
|
|
|
|
|
TEST_UNIQUE_ID = 1
|
|
|
|
|
TESTNAME_PREFIX = 'test_regrtest_'
|
2016-03-23 12:14:10 +01:00
|
|
|
TESTNAME_REGEX = r'test_[a-zA-Z0-9_]+'
|
2015-09-28 23:16:17 +02:00
|
|
|
|
|
|
|
|
def setUp(self):
|
2015-11-22 15:18:54 +01:00
|
|
|
self.testdir = os.path.realpath(os.path.dirname(__file__))
|
2015-09-28 23:16:17 +02:00
|
|
|
|
2016-03-30 02:33:52 +02:00
|
|
|
self.tmptestdir = tempfile.mkdtemp()
|
2020-06-30 21:46:06 +08:00
|
|
|
self.addCleanup(os_helper.rmtree, self.tmptestdir)
|
2015-09-28 23:16:17 +02:00
|
|
|
|
2018-11-29 17:17:44 +00:00
|
|
|
def create_test(self, name=None, code=None):
|
2015-09-28 23:16:17 +02:00
|
|
|
if not name:
|
|
|
|
|
name = 'noop%s' % BaseTestCase.TEST_UNIQUE_ID
|
|
|
|
|
BaseTestCase.TEST_UNIQUE_ID += 1
|
|
|
|
|
|
2018-11-29 17:17:44 +00:00
|
|
|
if code is None:
|
|
|
|
|
code = textwrap.dedent("""
|
|
|
|
|
import unittest
|
|
|
|
|
|
|
|
|
|
class Tests(unittest.TestCase):
|
|
|
|
|
def test_empty_test(self):
|
|
|
|
|
pass
|
|
|
|
|
""")
|
|
|
|
|
|
2015-09-28 23:16:17 +02:00
|
|
|
# test_regrtest cannot be run twice in parallel because
|
|
|
|
|
# of setUp() and create_test()
|
2016-03-30 02:33:52 +02:00
|
|
|
name = self.TESTNAME_PREFIX + name
|
|
|
|
|
path = os.path.join(self.tmptestdir, name + '.py')
|
2015-09-28 23:16:17 +02:00
|
|
|
|
2020-06-30 21:46:06 +08:00
|
|
|
self.addCleanup(os_helper.unlink, path)
|
2015-09-28 23:16:17 +02:00
|
|
|
# Use 'x' mode to ensure that we do not override existing tests
|
2015-11-22 15:18:54 +01:00
|
|
|
try:
|
|
|
|
|
with open(path, 'x', encoding='utf-8') as fp:
|
|
|
|
|
fp.write(code)
|
|
|
|
|
except PermissionError as exc:
|
|
|
|
|
if not sysconfig.is_python_build():
|
|
|
|
|
self.skipTest("cannot write %s: %s" % (path, exc))
|
|
|
|
|
raise
|
2015-09-28 23:16:17 +02:00
|
|
|
return name
|
|
|
|
|
|
|
|
|
|
def regex_search(self, regex, output):
|
|
|
|
|
match = re.search(regex, output, re.MULTILINE)
|
|
|
|
|
if not match:
|
|
|
|
|
self.fail("%r not found in %r" % (regex, output))
|
|
|
|
|
return match
|
|
|
|
|
|
[3.11] gh-108822: Backport libregrtest changes from the main branch (#108820)
* Revert "[3.11] gh-101634: regrtest reports decoding error as failed test (#106169) (#106175)"
This reverts commit d5418e97fc524420011a370ba3c2c3cf6a89a74f.
* Revert "[3.11] bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (GH-30895) (GH-103342)"
This reverts commit ecb09a849689764193e0115d27e220f82b5f6d9f.
* Revert "gh-95027: Fix regrtest stdout encoding on Windows (GH-98492)"
This reverts commit b2aa28eec56d07b9c6777b02b7247cf21839de9f.
* Revert "[3.11] gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253) (GH-94408)"
This reverts commit 0122ab235b5acb52dd99fd05d8802a00f438b828.
* Revert "Run Tools/scripts/reindent.py (GH-94225)"
This reverts commit f0f3a424afb00a15ce8c0140dd218f5b33929be6.
* Revert "gh-94052: Don't re-run failed tests with --python option (GH-94054)"
This reverts commit 1347607db12012f6458ffcba48d8ad797083812e.
* Revert "[3.11] gh-84461: Fix Emscripten umask and permission issues (GH-94002) (GH-94006)"
This reverts commit 10731849184a3101ed18683b0128d689f1671c3f.
* gh-93353: regrtest checks for leaked temporary files (#93776)
When running tests with -jN, create a temporary directory per process
and mark a test as "environment changed" if a test leaks a temporary
file or directory.
(cherry picked from commit e566ce5496f1bad81c431aaee65e36d5e44771c5)
* gh-93353: Fix regrtest for -jN with N >= 2 (GH-93813)
(cherry picked from commit 36934a16e86f34d69ba2d41630fb5b4d06d59cff)
* gh-93353: regrtest supports checking tmp files with -j2 (#93909)
regrtest now also implements checking for leaked temporary files and
directories when using -jN for N >= 2. Use tempfile.mkdtemp() to
create the temporary directory. Skip this check on WASI.
(cherry picked from commit 4f85cec9e2077681b3dacc3108e646d509b720bf)
* gh-84461: Fix Emscripten umask and permission issues (GH-94002)
- Emscripten's default umask is too strict, see
https://github.com/emscripten-core/emscripten/issues/17269
- getuid/getgid and geteuid/getegid are stubs that always return 0
(root). Disable effective uid/gid syscalls and fix tests that use
chmod() current user.
- Cannot drop X bit from directory.
(cherry picked from commit 2702e408fd0e0dd7aec396b4cf8c7ce9caae81d8)
* gh-94052: Don't re-run failed tests with --python option (#94054)
(cherry picked from commit 0ff7b996f5d836e63cdaf652c7aa734285261096)
* Run Tools/scripts/reindent.py (#94225)
Reindent files which were not properly formatted (PEP 8: 4 spaces).
Remove also some trailing spaces.
(cherry picked from commit e87ada48a9e5d9d03f9759138869216df0d7383a)
* gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253)
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 199ba233248ab279f445e0809c2077976f0711bc)
* gh-96465: Clear fractions hash lru_cache under refleak testing (GH-96689)
Automerge-Triggered-By: GH:zware
(cherry picked from commit 9c8f3794337457b1d905a9fa0f38c2978fe32abd)
* gh-95027: Fix regrtest stdout encoding on Windows (#98492)
On Windows, when the Python test suite is run with the -jN option,
the ANSI code page is now used as the encoding for the stdout
temporary file, rather than using UTF-8 which can lead to decoding
errors.
(cherry picked from commit ec1f6f5f139868dc2c1116a7c7c878c38c668d53)
* gh-98903: Test suite fails with exit code 4 if no tests ran (#98904)
The Python test suite now fails wit exit code 4 if no tests ran. It
should help detecting typos in test names and test methods.
* Add "EXITCODE_" constants to Lib/test/libregrtest/main.py.
* Fix a typo: "NO TEST RUN" becomes "NO TESTS RAN"
(cherry picked from commit c76db37c0d23174cbffd6fa978d39693890ef020)
* gh-100086: Add build info to test.libregrtest (#100093)
The Python test runner (libregrtest) now logs Python build information like
"debug" vs "release" build, or LTO and PGO optimizations.
(cherry picked from commit 3c892022472eb975360fb3f0caa6f6fcc6fbf220)
* bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (#30895)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
(cherry picked from commit 995386071f96e4cfebfa027a71ca9134e4651d2a)
* gh-82054: allow test runner to split test_asyncio to execute in parallel by sharding. (#103927)
This runs test_asyncio sub-tests in parallel using sharding from Cinder. This suite is typically the longest-pole in runs because it is a test package with a lot of further sub-tests otherwise run serially. By breaking out the sub-tests as independent modules we can run a lot more in parallel.
After porting we can see the direct impact on a multicore system.
Without this change:
Running make test is 5 min 26 seconds
With this change:
Running make test takes 3 min 39 seconds
That'll vary based on system and parallelism. On a `-j 4` run similar to what CI and buildbot systems often do, it reduced the overall test suite completion latency by 10%.
The drawbacks are that this implementation is hacky and due to the sorting of the tests it obscures when the asyncio tests occur and involves changing CPython test infrastructure but, the wall time saved it is worth it, especially in low-core count CI runs as it pulls a long tail. The win for productivity and reserved CI resource usage is significant.
Future tests that deserve to be refactored into split up suites to benefit from are test_concurrent_futures and the way the _test_multiprocessing suite gets run for all start methods. As exposed by passing the -o flag to python -m test to get a list of the 10 longest running tests.
---------
Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google, LLC]
(cherry picked from commit 9e011e7c77dad7d0bbb944c44891531606caeb21)
* Display the sanitizer config in the regrtest header. (#105301)
Display the sanitizers present in libregrtest.
Having this in the CI output for tests with the relevant environment
variable displayed will help make it easier to do what we need to
create an equivalent local test run.
(cherry picked from commit 852348ab65783601e0844b6647ea033668b45c11)
* gh-101634: regrtest reports decoding error as failed test (#106169)
When running the Python test suite with -jN option, if a worker stdout
cannot be decoded from the locale encoding report a failed testn so the
exitcode is non-zero.
(cherry picked from commit 2ac3eec103cf450aaaebeb932e51155d2e7fb37b)
* gh-108223: test.pythoninfo and libregrtest log Py_NOGIL (#108238)
Enable with --disable-gil --without-pydebug:
$ make pythoninfo|grep NOGIL
sysconfig[Py_NOGIL]: 1
$ ./python -m test
...
== Python build: nogil debug
...
(cherry picked from commit 5afe0c17ca14df430736e549542a4b85e7e7c7ac)
* gh-90791: test.pythoninfo logs ASAN_OPTIONS env var (#108289)
* Cleanup libregrtest code logging ASAN_OPTIONS.
* Fix a typo on "ASAN_OPTIONS" vs "MSAN_OPTIONS".
(cherry picked from commit 3a1ac87f8f89d3206b46a0df4908afae629d669d)
* gh-108388: regrtest splits test_asyncio package (#108393)
Currently, test_asyncio package is only splitted into sub-tests when
using command "./python -m test". With this change, it's also
splitted when passing it on the command line:
"./python -m test test_asyncio".
Remove the concept of "STDTESTS". Python is now mature enough to not
have to bother with that anymore. Removing STDTESTS simplify the
code.
(cherry picked from commit 174e9da0836844a2138cc8915dd305cb2cd7a583)
* regrtest computes statistics (#108793)
test_netrc, test_pep646_syntax and test_xml_etree now return results
in the test_main() function.
Changes:
* Rewrite TestResult as a dataclass with a new State class.
* Add test.support.TestStats class and Regrtest.stats_dict attribute.
* libregrtest.runtest functions now modify a TestResult instance
in-place.
* libregrtest summary lists the number of run tests and skipped
tests, and denied resources.
* Add TestResult.has_meaningful_duration() method.
* Compute TestResult duration in the upper function.
* Use time.perf_counter() instead of time.monotonic().
* Regrtest: rename 'resource_denieds' attribute to 'resource_denied'.
* Rename CHILD_ERROR to MULTIPROCESSING_ERROR.
* Use match/case syntadx to have different code depending on the
test state.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit d4e534cbb35678c82b3a1276826af55d7bfc23b6)
* gh-108822: Add Changelog entry for regrtest statistics (#108821)
---------
Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Zachary Ware <zach@python.org>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Joshua Herman <zitterbewegung@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-09-03 19:21:53 +02:00
|
|
|
def check_line(self, output, regex, full=False):
|
|
|
|
|
if full:
|
|
|
|
|
regex += '\n'
|
2015-09-28 23:16:17 +02:00
|
|
|
regex = re.compile(r'^' + regex, re.MULTILINE)
|
|
|
|
|
self.assertRegex(output, regex)
|
|
|
|
|
|
|
|
|
|
def parse_executed_tests(self, output):
|
2019-10-03 16:15:16 +02:00
|
|
|
regex = (r'^%s\[ *[0-9]+(?:/ *[0-9]+)*\] (%s)'
|
|
|
|
|
% (LOG_PREFIX, self.TESTNAME_REGEX))
|
2015-09-30 13:51:17 +02:00
|
|
|
parser = re.finditer(regex, output, re.MULTILINE)
|
|
|
|
|
return list(match.group(1) for match in parser)
|
2015-09-28 23:16:17 +02:00
|
|
|
|
2015-09-30 13:51:17 +02:00
|
|
|
def check_executed_tests(self, output, tests, skipped=(), failed=(),
|
2017-06-26 18:33:19 +02:00
|
|
|
env_changed=(), omitted=(),
|
[3.11] gh-108822: Backport libregrtest changes from the main branch (#108820)
* Revert "[3.11] gh-101634: regrtest reports decoding error as failed test (#106169) (#106175)"
This reverts commit d5418e97fc524420011a370ba3c2c3cf6a89a74f.
* Revert "[3.11] bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (GH-30895) (GH-103342)"
This reverts commit ecb09a849689764193e0115d27e220f82b5f6d9f.
* Revert "gh-95027: Fix regrtest stdout encoding on Windows (GH-98492)"
This reverts commit b2aa28eec56d07b9c6777b02b7247cf21839de9f.
* Revert "[3.11] gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253) (GH-94408)"
This reverts commit 0122ab235b5acb52dd99fd05d8802a00f438b828.
* Revert "Run Tools/scripts/reindent.py (GH-94225)"
This reverts commit f0f3a424afb00a15ce8c0140dd218f5b33929be6.
* Revert "gh-94052: Don't re-run failed tests with --python option (GH-94054)"
This reverts commit 1347607db12012f6458ffcba48d8ad797083812e.
* Revert "[3.11] gh-84461: Fix Emscripten umask and permission issues (GH-94002) (GH-94006)"
This reverts commit 10731849184a3101ed18683b0128d689f1671c3f.
* gh-93353: regrtest checks for leaked temporary files (#93776)
When running tests with -jN, create a temporary directory per process
and mark a test as "environment changed" if a test leaks a temporary
file or directory.
(cherry picked from commit e566ce5496f1bad81c431aaee65e36d5e44771c5)
* gh-93353: Fix regrtest for -jN with N >= 2 (GH-93813)
(cherry picked from commit 36934a16e86f34d69ba2d41630fb5b4d06d59cff)
* gh-93353: regrtest supports checking tmp files with -j2 (#93909)
regrtest now also implements checking for leaked temporary files and
directories when using -jN for N >= 2. Use tempfile.mkdtemp() to
create the temporary directory. Skip this check on WASI.
(cherry picked from commit 4f85cec9e2077681b3dacc3108e646d509b720bf)
* gh-84461: Fix Emscripten umask and permission issues (GH-94002)
- Emscripten's default umask is too strict, see
https://github.com/emscripten-core/emscripten/issues/17269
- getuid/getgid and geteuid/getegid are stubs that always return 0
(root). Disable effective uid/gid syscalls and fix tests that use
chmod() current user.
- Cannot drop X bit from directory.
(cherry picked from commit 2702e408fd0e0dd7aec396b4cf8c7ce9caae81d8)
* gh-94052: Don't re-run failed tests with --python option (#94054)
(cherry picked from commit 0ff7b996f5d836e63cdaf652c7aa734285261096)
* Run Tools/scripts/reindent.py (#94225)
Reindent files which were not properly formatted (PEP 8: 4 spaces).
Remove also some trailing spaces.
(cherry picked from commit e87ada48a9e5d9d03f9759138869216df0d7383a)
* gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253)
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 199ba233248ab279f445e0809c2077976f0711bc)
* gh-96465: Clear fractions hash lru_cache under refleak testing (GH-96689)
Automerge-Triggered-By: GH:zware
(cherry picked from commit 9c8f3794337457b1d905a9fa0f38c2978fe32abd)
* gh-95027: Fix regrtest stdout encoding on Windows (#98492)
On Windows, when the Python test suite is run with the -jN option,
the ANSI code page is now used as the encoding for the stdout
temporary file, rather than using UTF-8 which can lead to decoding
errors.
(cherry picked from commit ec1f6f5f139868dc2c1116a7c7c878c38c668d53)
* gh-98903: Test suite fails with exit code 4 if no tests ran (#98904)
The Python test suite now fails wit exit code 4 if no tests ran. It
should help detecting typos in test names and test methods.
* Add "EXITCODE_" constants to Lib/test/libregrtest/main.py.
* Fix a typo: "NO TEST RUN" becomes "NO TESTS RAN"
(cherry picked from commit c76db37c0d23174cbffd6fa978d39693890ef020)
* gh-100086: Add build info to test.libregrtest (#100093)
The Python test runner (libregrtest) now logs Python build information like
"debug" vs "release" build, or LTO and PGO optimizations.
(cherry picked from commit 3c892022472eb975360fb3f0caa6f6fcc6fbf220)
* bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (#30895)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
(cherry picked from commit 995386071f96e4cfebfa027a71ca9134e4651d2a)
* gh-82054: allow test runner to split test_asyncio to execute in parallel by sharding. (#103927)
This runs test_asyncio sub-tests in parallel using sharding from Cinder. This suite is typically the longest-pole in runs because it is a test package with a lot of further sub-tests otherwise run serially. By breaking out the sub-tests as independent modules we can run a lot more in parallel.
After porting we can see the direct impact on a multicore system.
Without this change:
Running make test is 5 min 26 seconds
With this change:
Running make test takes 3 min 39 seconds
That'll vary based on system and parallelism. On a `-j 4` run similar to what CI and buildbot systems often do, it reduced the overall test suite completion latency by 10%.
The drawbacks are that this implementation is hacky and due to the sorting of the tests it obscures when the asyncio tests occur and involves changing CPython test infrastructure but, the wall time saved it is worth it, especially in low-core count CI runs as it pulls a long tail. The win for productivity and reserved CI resource usage is significant.
Future tests that deserve to be refactored into split up suites to benefit from are test_concurrent_futures and the way the _test_multiprocessing suite gets run for all start methods. As exposed by passing the -o flag to python -m test to get a list of the 10 longest running tests.
---------
Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google, LLC]
(cherry picked from commit 9e011e7c77dad7d0bbb944c44891531606caeb21)
* Display the sanitizer config in the regrtest header. (#105301)
Display the sanitizers present in libregrtest.
Having this in the CI output for tests with the relevant environment
variable displayed will help make it easier to do what we need to
create an equivalent local test run.
(cherry picked from commit 852348ab65783601e0844b6647ea033668b45c11)
* gh-101634: regrtest reports decoding error as failed test (#106169)
When running the Python test suite with -jN option, if a worker stdout
cannot be decoded from the locale encoding report a failed testn so the
exitcode is non-zero.
(cherry picked from commit 2ac3eec103cf450aaaebeb932e51155d2e7fb37b)
* gh-108223: test.pythoninfo and libregrtest log Py_NOGIL (#108238)
Enable with --disable-gil --without-pydebug:
$ make pythoninfo|grep NOGIL
sysconfig[Py_NOGIL]: 1
$ ./python -m test
...
== Python build: nogil debug
...
(cherry picked from commit 5afe0c17ca14df430736e549542a4b85e7e7c7ac)
* gh-90791: test.pythoninfo logs ASAN_OPTIONS env var (#108289)
* Cleanup libregrtest code logging ASAN_OPTIONS.
* Fix a typo on "ASAN_OPTIONS" vs "MSAN_OPTIONS".
(cherry picked from commit 3a1ac87f8f89d3206b46a0df4908afae629d669d)
* gh-108388: regrtest splits test_asyncio package (#108393)
Currently, test_asyncio package is only splitted into sub-tests when
using command "./python -m test". With this change, it's also
splitted when passing it on the command line:
"./python -m test test_asyncio".
Remove the concept of "STDTESTS". Python is now mature enough to not
have to bother with that anymore. Removing STDTESTS simplify the
code.
(cherry picked from commit 174e9da0836844a2138cc8915dd305cb2cd7a583)
* regrtest computes statistics (#108793)
test_netrc, test_pep646_syntax and test_xml_etree now return results
in the test_main() function.
Changes:
* Rewrite TestResult as a dataclass with a new State class.
* Add test.support.TestStats class and Regrtest.stats_dict attribute.
* libregrtest.runtest functions now modify a TestResult instance
in-place.
* libregrtest summary lists the number of run tests and skipped
tests, and denied resources.
* Add TestResult.has_meaningful_duration() method.
* Compute TestResult duration in the upper function.
* Use time.perf_counter() instead of time.monotonic().
* Regrtest: rename 'resource_denieds' attribute to 'resource_denied'.
* Rename CHILD_ERROR to MULTIPROCESSING_ERROR.
* Use match/case syntadx to have different code depending on the
test state.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit d4e534cbb35678c82b3a1276826af55d7bfc23b6)
* gh-108822: Add Changelog entry for regrtest statistics (#108821)
---------
Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Zachary Ware <zach@python.org>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Joshua Herman <zitterbewegung@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-09-03 19:21:53 +02:00
|
|
|
rerun={}, run_no_tests=(),
|
|
|
|
|
resource_denied=(),
|
2017-06-26 18:33:19 +02:00
|
|
|
randomize=False, interrupted=False,
|
[3.11] gh-108822: Backport libregrtest changes from the main branch (#108820)
* Revert "[3.11] gh-101634: regrtest reports decoding error as failed test (#106169) (#106175)"
This reverts commit d5418e97fc524420011a370ba3c2c3cf6a89a74f.
* Revert "[3.11] bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (GH-30895) (GH-103342)"
This reverts commit ecb09a849689764193e0115d27e220f82b5f6d9f.
* Revert "gh-95027: Fix regrtest stdout encoding on Windows (GH-98492)"
This reverts commit b2aa28eec56d07b9c6777b02b7247cf21839de9f.
* Revert "[3.11] gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253) (GH-94408)"
This reverts commit 0122ab235b5acb52dd99fd05d8802a00f438b828.
* Revert "Run Tools/scripts/reindent.py (GH-94225)"
This reverts commit f0f3a424afb00a15ce8c0140dd218f5b33929be6.
* Revert "gh-94052: Don't re-run failed tests with --python option (GH-94054)"
This reverts commit 1347607db12012f6458ffcba48d8ad797083812e.
* Revert "[3.11] gh-84461: Fix Emscripten umask and permission issues (GH-94002) (GH-94006)"
This reverts commit 10731849184a3101ed18683b0128d689f1671c3f.
* gh-93353: regrtest checks for leaked temporary files (#93776)
When running tests with -jN, create a temporary directory per process
and mark a test as "environment changed" if a test leaks a temporary
file or directory.
(cherry picked from commit e566ce5496f1bad81c431aaee65e36d5e44771c5)
* gh-93353: Fix regrtest for -jN with N >= 2 (GH-93813)
(cherry picked from commit 36934a16e86f34d69ba2d41630fb5b4d06d59cff)
* gh-93353: regrtest supports checking tmp files with -j2 (#93909)
regrtest now also implements checking for leaked temporary files and
directories when using -jN for N >= 2. Use tempfile.mkdtemp() to
create the temporary directory. Skip this check on WASI.
(cherry picked from commit 4f85cec9e2077681b3dacc3108e646d509b720bf)
* gh-84461: Fix Emscripten umask and permission issues (GH-94002)
- Emscripten's default umask is too strict, see
https://github.com/emscripten-core/emscripten/issues/17269
- getuid/getgid and geteuid/getegid are stubs that always return 0
(root). Disable effective uid/gid syscalls and fix tests that use
chmod() current user.
- Cannot drop X bit from directory.
(cherry picked from commit 2702e408fd0e0dd7aec396b4cf8c7ce9caae81d8)
* gh-94052: Don't re-run failed tests with --python option (#94054)
(cherry picked from commit 0ff7b996f5d836e63cdaf652c7aa734285261096)
* Run Tools/scripts/reindent.py (#94225)
Reindent files which were not properly formatted (PEP 8: 4 spaces).
Remove also some trailing spaces.
(cherry picked from commit e87ada48a9e5d9d03f9759138869216df0d7383a)
* gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253)
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 199ba233248ab279f445e0809c2077976f0711bc)
* gh-96465: Clear fractions hash lru_cache under refleak testing (GH-96689)
Automerge-Triggered-By: GH:zware
(cherry picked from commit 9c8f3794337457b1d905a9fa0f38c2978fe32abd)
* gh-95027: Fix regrtest stdout encoding on Windows (#98492)
On Windows, when the Python test suite is run with the -jN option,
the ANSI code page is now used as the encoding for the stdout
temporary file, rather than using UTF-8 which can lead to decoding
errors.
(cherry picked from commit ec1f6f5f139868dc2c1116a7c7c878c38c668d53)
* gh-98903: Test suite fails with exit code 4 if no tests ran (#98904)
The Python test suite now fails wit exit code 4 if no tests ran. It
should help detecting typos in test names and test methods.
* Add "EXITCODE_" constants to Lib/test/libregrtest/main.py.
* Fix a typo: "NO TEST RUN" becomes "NO TESTS RAN"
(cherry picked from commit c76db37c0d23174cbffd6fa978d39693890ef020)
* gh-100086: Add build info to test.libregrtest (#100093)
The Python test runner (libregrtest) now logs Python build information like
"debug" vs "release" build, or LTO and PGO optimizations.
(cherry picked from commit 3c892022472eb975360fb3f0caa6f6fcc6fbf220)
* bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (#30895)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
(cherry picked from commit 995386071f96e4cfebfa027a71ca9134e4651d2a)
* gh-82054: allow test runner to split test_asyncio to execute in parallel by sharding. (#103927)
This runs test_asyncio sub-tests in parallel using sharding from Cinder. This suite is typically the longest-pole in runs because it is a test package with a lot of further sub-tests otherwise run serially. By breaking out the sub-tests as independent modules we can run a lot more in parallel.
After porting we can see the direct impact on a multicore system.
Without this change:
Running make test is 5 min 26 seconds
With this change:
Running make test takes 3 min 39 seconds
That'll vary based on system and parallelism. On a `-j 4` run similar to what CI and buildbot systems often do, it reduced the overall test suite completion latency by 10%.
The drawbacks are that this implementation is hacky and due to the sorting of the tests it obscures when the asyncio tests occur and involves changing CPython test infrastructure but, the wall time saved it is worth it, especially in low-core count CI runs as it pulls a long tail. The win for productivity and reserved CI resource usage is significant.
Future tests that deserve to be refactored into split up suites to benefit from are test_concurrent_futures and the way the _test_multiprocessing suite gets run for all start methods. As exposed by passing the -o flag to python -m test to get a list of the 10 longest running tests.
---------
Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google, LLC]
(cherry picked from commit 9e011e7c77dad7d0bbb944c44891531606caeb21)
* Display the sanitizer config in the regrtest header. (#105301)
Display the sanitizers present in libregrtest.
Having this in the CI output for tests with the relevant environment
variable displayed will help make it easier to do what we need to
create an equivalent local test run.
(cherry picked from commit 852348ab65783601e0844b6647ea033668b45c11)
* gh-101634: regrtest reports decoding error as failed test (#106169)
When running the Python test suite with -jN option, if a worker stdout
cannot be decoded from the locale encoding report a failed testn so the
exitcode is non-zero.
(cherry picked from commit 2ac3eec103cf450aaaebeb932e51155d2e7fb37b)
* gh-108223: test.pythoninfo and libregrtest log Py_NOGIL (#108238)
Enable with --disable-gil --without-pydebug:
$ make pythoninfo|grep NOGIL
sysconfig[Py_NOGIL]: 1
$ ./python -m test
...
== Python build: nogil debug
...
(cherry picked from commit 5afe0c17ca14df430736e549542a4b85e7e7c7ac)
* gh-90791: test.pythoninfo logs ASAN_OPTIONS env var (#108289)
* Cleanup libregrtest code logging ASAN_OPTIONS.
* Fix a typo on "ASAN_OPTIONS" vs "MSAN_OPTIONS".
(cherry picked from commit 3a1ac87f8f89d3206b46a0df4908afae629d669d)
* gh-108388: regrtest splits test_asyncio package (#108393)
Currently, test_asyncio package is only splitted into sub-tests when
using command "./python -m test". With this change, it's also
splitted when passing it on the command line:
"./python -m test test_asyncio".
Remove the concept of "STDTESTS". Python is now mature enough to not
have to bother with that anymore. Removing STDTESTS simplify the
code.
(cherry picked from commit 174e9da0836844a2138cc8915dd305cb2cd7a583)
* regrtest computes statistics (#108793)
test_netrc, test_pep646_syntax and test_xml_etree now return results
in the test_main() function.
Changes:
* Rewrite TestResult as a dataclass with a new State class.
* Add test.support.TestStats class and Regrtest.stats_dict attribute.
* libregrtest.runtest functions now modify a TestResult instance
in-place.
* libregrtest summary lists the number of run tests and skipped
tests, and denied resources.
* Add TestResult.has_meaningful_duration() method.
* Compute TestResult duration in the upper function.
* Use time.perf_counter() instead of time.monotonic().
* Regrtest: rename 'resource_denieds' attribute to 'resource_denied'.
* Rename CHILD_ERROR to MULTIPROCESSING_ERROR.
* Use match/case syntadx to have different code depending on the
test state.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit d4e534cbb35678c82b3a1276826af55d7bfc23b6)
* gh-108822: Add Changelog entry for regrtest statistics (#108821)
---------
Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Zachary Ware <zach@python.org>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Joshua Herman <zitterbewegung@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-09-03 19:21:53 +02:00
|
|
|
fail_env_changed=False,
|
|
|
|
|
*, stats):
|
2015-09-28 23:16:17 +02:00
|
|
|
if isinstance(tests, str):
|
|
|
|
|
tests = [tests]
|
2015-09-30 13:51:17 +02:00
|
|
|
if isinstance(skipped, str):
|
|
|
|
|
skipped = [skipped]
|
[3.11] gh-108822: Backport libregrtest changes from the main branch (#108820)
* Revert "[3.11] gh-101634: regrtest reports decoding error as failed test (#106169) (#106175)"
This reverts commit d5418e97fc524420011a370ba3c2c3cf6a89a74f.
* Revert "[3.11] bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (GH-30895) (GH-103342)"
This reverts commit ecb09a849689764193e0115d27e220f82b5f6d9f.
* Revert "gh-95027: Fix regrtest stdout encoding on Windows (GH-98492)"
This reverts commit b2aa28eec56d07b9c6777b02b7247cf21839de9f.
* Revert "[3.11] gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253) (GH-94408)"
This reverts commit 0122ab235b5acb52dd99fd05d8802a00f438b828.
* Revert "Run Tools/scripts/reindent.py (GH-94225)"
This reverts commit f0f3a424afb00a15ce8c0140dd218f5b33929be6.
* Revert "gh-94052: Don't re-run failed tests with --python option (GH-94054)"
This reverts commit 1347607db12012f6458ffcba48d8ad797083812e.
* Revert "[3.11] gh-84461: Fix Emscripten umask and permission issues (GH-94002) (GH-94006)"
This reverts commit 10731849184a3101ed18683b0128d689f1671c3f.
* gh-93353: regrtest checks for leaked temporary files (#93776)
When running tests with -jN, create a temporary directory per process
and mark a test as "environment changed" if a test leaks a temporary
file or directory.
(cherry picked from commit e566ce5496f1bad81c431aaee65e36d5e44771c5)
* gh-93353: Fix regrtest for -jN with N >= 2 (GH-93813)
(cherry picked from commit 36934a16e86f34d69ba2d41630fb5b4d06d59cff)
* gh-93353: regrtest supports checking tmp files with -j2 (#93909)
regrtest now also implements checking for leaked temporary files and
directories when using -jN for N >= 2. Use tempfile.mkdtemp() to
create the temporary directory. Skip this check on WASI.
(cherry picked from commit 4f85cec9e2077681b3dacc3108e646d509b720bf)
* gh-84461: Fix Emscripten umask and permission issues (GH-94002)
- Emscripten's default umask is too strict, see
https://github.com/emscripten-core/emscripten/issues/17269
- getuid/getgid and geteuid/getegid are stubs that always return 0
(root). Disable effective uid/gid syscalls and fix tests that use
chmod() current user.
- Cannot drop X bit from directory.
(cherry picked from commit 2702e408fd0e0dd7aec396b4cf8c7ce9caae81d8)
* gh-94052: Don't re-run failed tests with --python option (#94054)
(cherry picked from commit 0ff7b996f5d836e63cdaf652c7aa734285261096)
* Run Tools/scripts/reindent.py (#94225)
Reindent files which were not properly formatted (PEP 8: 4 spaces).
Remove also some trailing spaces.
(cherry picked from commit e87ada48a9e5d9d03f9759138869216df0d7383a)
* gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253)
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 199ba233248ab279f445e0809c2077976f0711bc)
* gh-96465: Clear fractions hash lru_cache under refleak testing (GH-96689)
Automerge-Triggered-By: GH:zware
(cherry picked from commit 9c8f3794337457b1d905a9fa0f38c2978fe32abd)
* gh-95027: Fix regrtest stdout encoding on Windows (#98492)
On Windows, when the Python test suite is run with the -jN option,
the ANSI code page is now used as the encoding for the stdout
temporary file, rather than using UTF-8 which can lead to decoding
errors.
(cherry picked from commit ec1f6f5f139868dc2c1116a7c7c878c38c668d53)
* gh-98903: Test suite fails with exit code 4 if no tests ran (#98904)
The Python test suite now fails wit exit code 4 if no tests ran. It
should help detecting typos in test names and test methods.
* Add "EXITCODE_" constants to Lib/test/libregrtest/main.py.
* Fix a typo: "NO TEST RUN" becomes "NO TESTS RAN"
(cherry picked from commit c76db37c0d23174cbffd6fa978d39693890ef020)
* gh-100086: Add build info to test.libregrtest (#100093)
The Python test runner (libregrtest) now logs Python build information like
"debug" vs "release" build, or LTO and PGO optimizations.
(cherry picked from commit 3c892022472eb975360fb3f0caa6f6fcc6fbf220)
* bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (#30895)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
(cherry picked from commit 995386071f96e4cfebfa027a71ca9134e4651d2a)
* gh-82054: allow test runner to split test_asyncio to execute in parallel by sharding. (#103927)
This runs test_asyncio sub-tests in parallel using sharding from Cinder. This suite is typically the longest-pole in runs because it is a test package with a lot of further sub-tests otherwise run serially. By breaking out the sub-tests as independent modules we can run a lot more in parallel.
After porting we can see the direct impact on a multicore system.
Without this change:
Running make test is 5 min 26 seconds
With this change:
Running make test takes 3 min 39 seconds
That'll vary based on system and parallelism. On a `-j 4` run similar to what CI and buildbot systems often do, it reduced the overall test suite completion latency by 10%.
The drawbacks are that this implementation is hacky and due to the sorting of the tests it obscures when the asyncio tests occur and involves changing CPython test infrastructure but, the wall time saved it is worth it, especially in low-core count CI runs as it pulls a long tail. The win for productivity and reserved CI resource usage is significant.
Future tests that deserve to be refactored into split up suites to benefit from are test_concurrent_futures and the way the _test_multiprocessing suite gets run for all start methods. As exposed by passing the -o flag to python -m test to get a list of the 10 longest running tests.
---------
Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google, LLC]
(cherry picked from commit 9e011e7c77dad7d0bbb944c44891531606caeb21)
* Display the sanitizer config in the regrtest header. (#105301)
Display the sanitizers present in libregrtest.
Having this in the CI output for tests with the relevant environment
variable displayed will help make it easier to do what we need to
create an equivalent local test run.
(cherry picked from commit 852348ab65783601e0844b6647ea033668b45c11)
* gh-101634: regrtest reports decoding error as failed test (#106169)
When running the Python test suite with -jN option, if a worker stdout
cannot be decoded from the locale encoding report a failed testn so the
exitcode is non-zero.
(cherry picked from commit 2ac3eec103cf450aaaebeb932e51155d2e7fb37b)
* gh-108223: test.pythoninfo and libregrtest log Py_NOGIL (#108238)
Enable with --disable-gil --without-pydebug:
$ make pythoninfo|grep NOGIL
sysconfig[Py_NOGIL]: 1
$ ./python -m test
...
== Python build: nogil debug
...
(cherry picked from commit 5afe0c17ca14df430736e549542a4b85e7e7c7ac)
* gh-90791: test.pythoninfo logs ASAN_OPTIONS env var (#108289)
* Cleanup libregrtest code logging ASAN_OPTIONS.
* Fix a typo on "ASAN_OPTIONS" vs "MSAN_OPTIONS".
(cherry picked from commit 3a1ac87f8f89d3206b46a0df4908afae629d669d)
* gh-108388: regrtest splits test_asyncio package (#108393)
Currently, test_asyncio package is only splitted into sub-tests when
using command "./python -m test". With this change, it's also
splitted when passing it on the command line:
"./python -m test test_asyncio".
Remove the concept of "STDTESTS". Python is now mature enough to not
have to bother with that anymore. Removing STDTESTS simplify the
code.
(cherry picked from commit 174e9da0836844a2138cc8915dd305cb2cd7a583)
* regrtest computes statistics (#108793)
test_netrc, test_pep646_syntax and test_xml_etree now return results
in the test_main() function.
Changes:
* Rewrite TestResult as a dataclass with a new State class.
* Add test.support.TestStats class and Regrtest.stats_dict attribute.
* libregrtest.runtest functions now modify a TestResult instance
in-place.
* libregrtest summary lists the number of run tests and skipped
tests, and denied resources.
* Add TestResult.has_meaningful_duration() method.
* Compute TestResult duration in the upper function.
* Use time.perf_counter() instead of time.monotonic().
* Regrtest: rename 'resource_denieds' attribute to 'resource_denied'.
* Rename CHILD_ERROR to MULTIPROCESSING_ERROR.
* Use match/case syntadx to have different code depending on the
test state.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit d4e534cbb35678c82b3a1276826af55d7bfc23b6)
* gh-108822: Add Changelog entry for regrtest statistics (#108821)
---------
Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Zachary Ware <zach@python.org>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Joshua Herman <zitterbewegung@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-09-03 19:21:53 +02:00
|
|
|
if isinstance(resource_denied, str):
|
|
|
|
|
resource_denied = [resource_denied]
|
2015-09-30 13:51:17 +02:00
|
|
|
if isinstance(failed, str):
|
|
|
|
|
failed = [failed]
|
2017-06-26 18:33:19 +02:00
|
|
|
if isinstance(env_changed, str):
|
|
|
|
|
env_changed = [env_changed]
|
2015-10-11 10:37:25 +02:00
|
|
|
if isinstance(omitted, str):
|
|
|
|
|
omitted = [omitted]
|
[3.11] gh-108822: Backport libregrtest changes from the main branch (#108820)
* Revert "[3.11] gh-101634: regrtest reports decoding error as failed test (#106169) (#106175)"
This reverts commit d5418e97fc524420011a370ba3c2c3cf6a89a74f.
* Revert "[3.11] bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (GH-30895) (GH-103342)"
This reverts commit ecb09a849689764193e0115d27e220f82b5f6d9f.
* Revert "gh-95027: Fix regrtest stdout encoding on Windows (GH-98492)"
This reverts commit b2aa28eec56d07b9c6777b02b7247cf21839de9f.
* Revert "[3.11] gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253) (GH-94408)"
This reverts commit 0122ab235b5acb52dd99fd05d8802a00f438b828.
* Revert "Run Tools/scripts/reindent.py (GH-94225)"
This reverts commit f0f3a424afb00a15ce8c0140dd218f5b33929be6.
* Revert "gh-94052: Don't re-run failed tests with --python option (GH-94054)"
This reverts commit 1347607db12012f6458ffcba48d8ad797083812e.
* Revert "[3.11] gh-84461: Fix Emscripten umask and permission issues (GH-94002) (GH-94006)"
This reverts commit 10731849184a3101ed18683b0128d689f1671c3f.
* gh-93353: regrtest checks for leaked temporary files (#93776)
When running tests with -jN, create a temporary directory per process
and mark a test as "environment changed" if a test leaks a temporary
file or directory.
(cherry picked from commit e566ce5496f1bad81c431aaee65e36d5e44771c5)
* gh-93353: Fix regrtest for -jN with N >= 2 (GH-93813)
(cherry picked from commit 36934a16e86f34d69ba2d41630fb5b4d06d59cff)
* gh-93353: regrtest supports checking tmp files with -j2 (#93909)
regrtest now also implements checking for leaked temporary files and
directories when using -jN for N >= 2. Use tempfile.mkdtemp() to
create the temporary directory. Skip this check on WASI.
(cherry picked from commit 4f85cec9e2077681b3dacc3108e646d509b720bf)
* gh-84461: Fix Emscripten umask and permission issues (GH-94002)
- Emscripten's default umask is too strict, see
https://github.com/emscripten-core/emscripten/issues/17269
- getuid/getgid and geteuid/getegid are stubs that always return 0
(root). Disable effective uid/gid syscalls and fix tests that use
chmod() current user.
- Cannot drop X bit from directory.
(cherry picked from commit 2702e408fd0e0dd7aec396b4cf8c7ce9caae81d8)
* gh-94052: Don't re-run failed tests with --python option (#94054)
(cherry picked from commit 0ff7b996f5d836e63cdaf652c7aa734285261096)
* Run Tools/scripts/reindent.py (#94225)
Reindent files which were not properly formatted (PEP 8: 4 spaces).
Remove also some trailing spaces.
(cherry picked from commit e87ada48a9e5d9d03f9759138869216df0d7383a)
* gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253)
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 199ba233248ab279f445e0809c2077976f0711bc)
* gh-96465: Clear fractions hash lru_cache under refleak testing (GH-96689)
Automerge-Triggered-By: GH:zware
(cherry picked from commit 9c8f3794337457b1d905a9fa0f38c2978fe32abd)
* gh-95027: Fix regrtest stdout encoding on Windows (#98492)
On Windows, when the Python test suite is run with the -jN option,
the ANSI code page is now used as the encoding for the stdout
temporary file, rather than using UTF-8 which can lead to decoding
errors.
(cherry picked from commit ec1f6f5f139868dc2c1116a7c7c878c38c668d53)
* gh-98903: Test suite fails with exit code 4 if no tests ran (#98904)
The Python test suite now fails wit exit code 4 if no tests ran. It
should help detecting typos in test names and test methods.
* Add "EXITCODE_" constants to Lib/test/libregrtest/main.py.
* Fix a typo: "NO TEST RUN" becomes "NO TESTS RAN"
(cherry picked from commit c76db37c0d23174cbffd6fa978d39693890ef020)
* gh-100086: Add build info to test.libregrtest (#100093)
The Python test runner (libregrtest) now logs Python build information like
"debug" vs "release" build, or LTO and PGO optimizations.
(cherry picked from commit 3c892022472eb975360fb3f0caa6f6fcc6fbf220)
* bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (#30895)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
(cherry picked from commit 995386071f96e4cfebfa027a71ca9134e4651d2a)
* gh-82054: allow test runner to split test_asyncio to execute in parallel by sharding. (#103927)
This runs test_asyncio sub-tests in parallel using sharding from Cinder. This suite is typically the longest-pole in runs because it is a test package with a lot of further sub-tests otherwise run serially. By breaking out the sub-tests as independent modules we can run a lot more in parallel.
After porting we can see the direct impact on a multicore system.
Without this change:
Running make test is 5 min 26 seconds
With this change:
Running make test takes 3 min 39 seconds
That'll vary based on system and parallelism. On a `-j 4` run similar to what CI and buildbot systems often do, it reduced the overall test suite completion latency by 10%.
The drawbacks are that this implementation is hacky and due to the sorting of the tests it obscures when the asyncio tests occur and involves changing CPython test infrastructure but, the wall time saved it is worth it, especially in low-core count CI runs as it pulls a long tail. The win for productivity and reserved CI resource usage is significant.
Future tests that deserve to be refactored into split up suites to benefit from are test_concurrent_futures and the way the _test_multiprocessing suite gets run for all start methods. As exposed by passing the -o flag to python -m test to get a list of the 10 longest running tests.
---------
Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google, LLC]
(cherry picked from commit 9e011e7c77dad7d0bbb944c44891531606caeb21)
* Display the sanitizer config in the regrtest header. (#105301)
Display the sanitizers present in libregrtest.
Having this in the CI output for tests with the relevant environment
variable displayed will help make it easier to do what we need to
create an equivalent local test run.
(cherry picked from commit 852348ab65783601e0844b6647ea033668b45c11)
* gh-101634: regrtest reports decoding error as failed test (#106169)
When running the Python test suite with -jN option, if a worker stdout
cannot be decoded from the locale encoding report a failed testn so the
exitcode is non-zero.
(cherry picked from commit 2ac3eec103cf450aaaebeb932e51155d2e7fb37b)
* gh-108223: test.pythoninfo and libregrtest log Py_NOGIL (#108238)
Enable with --disable-gil --without-pydebug:
$ make pythoninfo|grep NOGIL
sysconfig[Py_NOGIL]: 1
$ ./python -m test
...
== Python build: nogil debug
...
(cherry picked from commit 5afe0c17ca14df430736e549542a4b85e7e7c7ac)
* gh-90791: test.pythoninfo logs ASAN_OPTIONS env var (#108289)
* Cleanup libregrtest code logging ASAN_OPTIONS.
* Fix a typo on "ASAN_OPTIONS" vs "MSAN_OPTIONS".
(cherry picked from commit 3a1ac87f8f89d3206b46a0df4908afae629d669d)
* gh-108388: regrtest splits test_asyncio package (#108393)
Currently, test_asyncio package is only splitted into sub-tests when
using command "./python -m test". With this change, it's also
splitted when passing it on the command line:
"./python -m test test_asyncio".
Remove the concept of "STDTESTS". Python is now mature enough to not
have to bother with that anymore. Removing STDTESTS simplify the
code.
(cherry picked from commit 174e9da0836844a2138cc8915dd305cb2cd7a583)
* regrtest computes statistics (#108793)
test_netrc, test_pep646_syntax and test_xml_etree now return results
in the test_main() function.
Changes:
* Rewrite TestResult as a dataclass with a new State class.
* Add test.support.TestStats class and Regrtest.stats_dict attribute.
* libregrtest.runtest functions now modify a TestResult instance
in-place.
* libregrtest summary lists the number of run tests and skipped
tests, and denied resources.
* Add TestResult.has_meaningful_duration() method.
* Compute TestResult duration in the upper function.
* Use time.perf_counter() instead of time.monotonic().
* Regrtest: rename 'resource_denieds' attribute to 'resource_denied'.
* Rename CHILD_ERROR to MULTIPROCESSING_ERROR.
* Use match/case syntadx to have different code depending on the
test state.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit d4e534cbb35678c82b3a1276826af55d7bfc23b6)
* gh-108822: Add Changelog entry for regrtest statistics (#108821)
---------
Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Zachary Ware <zach@python.org>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Joshua Herman <zitterbewegung@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-09-03 19:21:53 +02:00
|
|
|
if isinstance(run_no_tests, str):
|
|
|
|
|
run_no_tests = [run_no_tests]
|
|
|
|
|
if isinstance(stats, int):
|
|
|
|
|
stats = TestStats(stats)
|
2015-09-30 13:51:17 +02:00
|
|
|
|
|
|
|
|
executed = self.parse_executed_tests(output)
|
|
|
|
|
if randomize:
|
|
|
|
|
self.assertEqual(set(executed), set(tests), output)
|
2015-09-28 23:16:17 +02:00
|
|
|
else:
|
2015-09-30 13:51:17 +02:00
|
|
|
self.assertEqual(executed, tests, output)
|
|
|
|
|
|
|
|
|
|
def plural(count):
|
|
|
|
|
return 's' if count != 1 else ''
|
|
|
|
|
|
|
|
|
|
def list_regex(line_format, tests):
|
|
|
|
|
count = len(tests)
|
|
|
|
|
names = ' '.join(sorted(tests))
|
|
|
|
|
regex = line_format % (count, plural(count))
|
|
|
|
|
regex = r'%s:\n %s$' % (regex, names)
|
|
|
|
|
return regex
|
|
|
|
|
|
|
|
|
|
if skipped:
|
|
|
|
|
regex = list_regex('%s test%s skipped', skipped)
|
|
|
|
|
self.check_line(output, regex)
|
|
|
|
|
|
|
|
|
|
if failed:
|
|
|
|
|
regex = list_regex('%s test%s failed', failed)
|
|
|
|
|
self.check_line(output, regex)
|
|
|
|
|
|
2017-06-26 18:33:19 +02:00
|
|
|
if env_changed:
|
|
|
|
|
regex = list_regex('%s test%s altered the execution environment',
|
|
|
|
|
env_changed)
|
|
|
|
|
self.check_line(output, regex)
|
|
|
|
|
|
2015-10-11 10:37:25 +02:00
|
|
|
if omitted:
|
|
|
|
|
regex = list_regex('%s test%s omitted', omitted)
|
|
|
|
|
self.check_line(output, regex)
|
|
|
|
|
|
2018-06-08 09:53:51 +02:00
|
|
|
if rerun:
|
2021-07-22 20:25:58 +02:00
|
|
|
regex = list_regex('%s re-run test%s', rerun.keys())
|
2018-06-08 09:53:51 +02:00
|
|
|
self.check_line(output, regex)
|
2019-10-03 16:15:16 +02:00
|
|
|
regex = LOG_PREFIX + r"Re-running failed tests in verbose mode"
|
|
|
|
|
self.check_line(output, regex)
|
2021-07-22 20:25:58 +02:00
|
|
|
for name, match in rerun.items():
|
|
|
|
|
regex = LOG_PREFIX + f"Re-running {name} in verbose mode \\(matching: {match}\\)"
|
2018-06-08 09:53:51 +02:00
|
|
|
self.check_line(output, regex)
|
|
|
|
|
|
[3.11] gh-108822: Backport libregrtest changes from the main branch (#108820)
* Revert "[3.11] gh-101634: regrtest reports decoding error as failed test (#106169) (#106175)"
This reverts commit d5418e97fc524420011a370ba3c2c3cf6a89a74f.
* Revert "[3.11] bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (GH-30895) (GH-103342)"
This reverts commit ecb09a849689764193e0115d27e220f82b5f6d9f.
* Revert "gh-95027: Fix regrtest stdout encoding on Windows (GH-98492)"
This reverts commit b2aa28eec56d07b9c6777b02b7247cf21839de9f.
* Revert "[3.11] gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253) (GH-94408)"
This reverts commit 0122ab235b5acb52dd99fd05d8802a00f438b828.
* Revert "Run Tools/scripts/reindent.py (GH-94225)"
This reverts commit f0f3a424afb00a15ce8c0140dd218f5b33929be6.
* Revert "gh-94052: Don't re-run failed tests with --python option (GH-94054)"
This reverts commit 1347607db12012f6458ffcba48d8ad797083812e.
* Revert "[3.11] gh-84461: Fix Emscripten umask and permission issues (GH-94002) (GH-94006)"
This reverts commit 10731849184a3101ed18683b0128d689f1671c3f.
* gh-93353: regrtest checks for leaked temporary files (#93776)
When running tests with -jN, create a temporary directory per process
and mark a test as "environment changed" if a test leaks a temporary
file or directory.
(cherry picked from commit e566ce5496f1bad81c431aaee65e36d5e44771c5)
* gh-93353: Fix regrtest for -jN with N >= 2 (GH-93813)
(cherry picked from commit 36934a16e86f34d69ba2d41630fb5b4d06d59cff)
* gh-93353: regrtest supports checking tmp files with -j2 (#93909)
regrtest now also implements checking for leaked temporary files and
directories when using -jN for N >= 2. Use tempfile.mkdtemp() to
create the temporary directory. Skip this check on WASI.
(cherry picked from commit 4f85cec9e2077681b3dacc3108e646d509b720bf)
* gh-84461: Fix Emscripten umask and permission issues (GH-94002)
- Emscripten's default umask is too strict, see
https://github.com/emscripten-core/emscripten/issues/17269
- getuid/getgid and geteuid/getegid are stubs that always return 0
(root). Disable effective uid/gid syscalls and fix tests that use
chmod() current user.
- Cannot drop X bit from directory.
(cherry picked from commit 2702e408fd0e0dd7aec396b4cf8c7ce9caae81d8)
* gh-94052: Don't re-run failed tests with --python option (#94054)
(cherry picked from commit 0ff7b996f5d836e63cdaf652c7aa734285261096)
* Run Tools/scripts/reindent.py (#94225)
Reindent files which were not properly formatted (PEP 8: 4 spaces).
Remove also some trailing spaces.
(cherry picked from commit e87ada48a9e5d9d03f9759138869216df0d7383a)
* gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253)
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 199ba233248ab279f445e0809c2077976f0711bc)
* gh-96465: Clear fractions hash lru_cache under refleak testing (GH-96689)
Automerge-Triggered-By: GH:zware
(cherry picked from commit 9c8f3794337457b1d905a9fa0f38c2978fe32abd)
* gh-95027: Fix regrtest stdout encoding on Windows (#98492)
On Windows, when the Python test suite is run with the -jN option,
the ANSI code page is now used as the encoding for the stdout
temporary file, rather than using UTF-8 which can lead to decoding
errors.
(cherry picked from commit ec1f6f5f139868dc2c1116a7c7c878c38c668d53)
* gh-98903: Test suite fails with exit code 4 if no tests ran (#98904)
The Python test suite now fails wit exit code 4 if no tests ran. It
should help detecting typos in test names and test methods.
* Add "EXITCODE_" constants to Lib/test/libregrtest/main.py.
* Fix a typo: "NO TEST RUN" becomes "NO TESTS RAN"
(cherry picked from commit c76db37c0d23174cbffd6fa978d39693890ef020)
* gh-100086: Add build info to test.libregrtest (#100093)
The Python test runner (libregrtest) now logs Python build information like
"debug" vs "release" build, or LTO and PGO optimizations.
(cherry picked from commit 3c892022472eb975360fb3f0caa6f6fcc6fbf220)
* bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (#30895)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
(cherry picked from commit 995386071f96e4cfebfa027a71ca9134e4651d2a)
* gh-82054: allow test runner to split test_asyncio to execute in parallel by sharding. (#103927)
This runs test_asyncio sub-tests in parallel using sharding from Cinder. This suite is typically the longest-pole in runs because it is a test package with a lot of further sub-tests otherwise run serially. By breaking out the sub-tests as independent modules we can run a lot more in parallel.
After porting we can see the direct impact on a multicore system.
Without this change:
Running make test is 5 min 26 seconds
With this change:
Running make test takes 3 min 39 seconds
That'll vary based on system and parallelism. On a `-j 4` run similar to what CI and buildbot systems often do, it reduced the overall test suite completion latency by 10%.
The drawbacks are that this implementation is hacky and due to the sorting of the tests it obscures when the asyncio tests occur and involves changing CPython test infrastructure but, the wall time saved it is worth it, especially in low-core count CI runs as it pulls a long tail. The win for productivity and reserved CI resource usage is significant.
Future tests that deserve to be refactored into split up suites to benefit from are test_concurrent_futures and the way the _test_multiprocessing suite gets run for all start methods. As exposed by passing the -o flag to python -m test to get a list of the 10 longest running tests.
---------
Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google, LLC]
(cherry picked from commit 9e011e7c77dad7d0bbb944c44891531606caeb21)
* Display the sanitizer config in the regrtest header. (#105301)
Display the sanitizers present in libregrtest.
Having this in the CI output for tests with the relevant environment
variable displayed will help make it easier to do what we need to
create an equivalent local test run.
(cherry picked from commit 852348ab65783601e0844b6647ea033668b45c11)
* gh-101634: regrtest reports decoding error as failed test (#106169)
When running the Python test suite with -jN option, if a worker stdout
cannot be decoded from the locale encoding report a failed testn so the
exitcode is non-zero.
(cherry picked from commit 2ac3eec103cf450aaaebeb932e51155d2e7fb37b)
* gh-108223: test.pythoninfo and libregrtest log Py_NOGIL (#108238)
Enable with --disable-gil --without-pydebug:
$ make pythoninfo|grep NOGIL
sysconfig[Py_NOGIL]: 1
$ ./python -m test
...
== Python build: nogil debug
...
(cherry picked from commit 5afe0c17ca14df430736e549542a4b85e7e7c7ac)
* gh-90791: test.pythoninfo logs ASAN_OPTIONS env var (#108289)
* Cleanup libregrtest code logging ASAN_OPTIONS.
* Fix a typo on "ASAN_OPTIONS" vs "MSAN_OPTIONS".
(cherry picked from commit 3a1ac87f8f89d3206b46a0df4908afae629d669d)
* gh-108388: regrtest splits test_asyncio package (#108393)
Currently, test_asyncio package is only splitted into sub-tests when
using command "./python -m test". With this change, it's also
splitted when passing it on the command line:
"./python -m test test_asyncio".
Remove the concept of "STDTESTS". Python is now mature enough to not
have to bother with that anymore. Removing STDTESTS simplify the
code.
(cherry picked from commit 174e9da0836844a2138cc8915dd305cb2cd7a583)
* regrtest computes statistics (#108793)
test_netrc, test_pep646_syntax and test_xml_etree now return results
in the test_main() function.
Changes:
* Rewrite TestResult as a dataclass with a new State class.
* Add test.support.TestStats class and Regrtest.stats_dict attribute.
* libregrtest.runtest functions now modify a TestResult instance
in-place.
* libregrtest summary lists the number of run tests and skipped
tests, and denied resources.
* Add TestResult.has_meaningful_duration() method.
* Compute TestResult duration in the upper function.
* Use time.perf_counter() instead of time.monotonic().
* Regrtest: rename 'resource_denieds' attribute to 'resource_denied'.
* Rename CHILD_ERROR to MULTIPROCESSING_ERROR.
* Use match/case syntadx to have different code depending on the
test state.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit d4e534cbb35678c82b3a1276826af55d7bfc23b6)
* gh-108822: Add Changelog entry for regrtest statistics (#108821)
---------
Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Zachary Ware <zach@python.org>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Joshua Herman <zitterbewegung@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-09-03 19:21:53 +02:00
|
|
|
if run_no_tests:
|
|
|
|
|
regex = list_regex('%s test%s run no tests', run_no_tests)
|
2018-11-29 17:17:44 +00:00
|
|
|
self.check_line(output, regex)
|
|
|
|
|
|
2017-06-26 18:33:19 +02:00
|
|
|
good = (len(tests) - len(skipped) - len(failed)
|
[3.11] gh-108822: Backport libregrtest changes from the main branch (#108820)
* Revert "[3.11] gh-101634: regrtest reports decoding error as failed test (#106169) (#106175)"
This reverts commit d5418e97fc524420011a370ba3c2c3cf6a89a74f.
* Revert "[3.11] bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (GH-30895) (GH-103342)"
This reverts commit ecb09a849689764193e0115d27e220f82b5f6d9f.
* Revert "gh-95027: Fix regrtest stdout encoding on Windows (GH-98492)"
This reverts commit b2aa28eec56d07b9c6777b02b7247cf21839de9f.
* Revert "[3.11] gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253) (GH-94408)"
This reverts commit 0122ab235b5acb52dd99fd05d8802a00f438b828.
* Revert "Run Tools/scripts/reindent.py (GH-94225)"
This reverts commit f0f3a424afb00a15ce8c0140dd218f5b33929be6.
* Revert "gh-94052: Don't re-run failed tests with --python option (GH-94054)"
This reverts commit 1347607db12012f6458ffcba48d8ad797083812e.
* Revert "[3.11] gh-84461: Fix Emscripten umask and permission issues (GH-94002) (GH-94006)"
This reverts commit 10731849184a3101ed18683b0128d689f1671c3f.
* gh-93353: regrtest checks for leaked temporary files (#93776)
When running tests with -jN, create a temporary directory per process
and mark a test as "environment changed" if a test leaks a temporary
file or directory.
(cherry picked from commit e566ce5496f1bad81c431aaee65e36d5e44771c5)
* gh-93353: Fix regrtest for -jN with N >= 2 (GH-93813)
(cherry picked from commit 36934a16e86f34d69ba2d41630fb5b4d06d59cff)
* gh-93353: regrtest supports checking tmp files with -j2 (#93909)
regrtest now also implements checking for leaked temporary files and
directories when using -jN for N >= 2. Use tempfile.mkdtemp() to
create the temporary directory. Skip this check on WASI.
(cherry picked from commit 4f85cec9e2077681b3dacc3108e646d509b720bf)
* gh-84461: Fix Emscripten umask and permission issues (GH-94002)
- Emscripten's default umask is too strict, see
https://github.com/emscripten-core/emscripten/issues/17269
- getuid/getgid and geteuid/getegid are stubs that always return 0
(root). Disable effective uid/gid syscalls and fix tests that use
chmod() current user.
- Cannot drop X bit from directory.
(cherry picked from commit 2702e408fd0e0dd7aec396b4cf8c7ce9caae81d8)
* gh-94052: Don't re-run failed tests with --python option (#94054)
(cherry picked from commit 0ff7b996f5d836e63cdaf652c7aa734285261096)
* Run Tools/scripts/reindent.py (#94225)
Reindent files which were not properly formatted (PEP 8: 4 spaces).
Remove also some trailing spaces.
(cherry picked from commit e87ada48a9e5d9d03f9759138869216df0d7383a)
* gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253)
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 199ba233248ab279f445e0809c2077976f0711bc)
* gh-96465: Clear fractions hash lru_cache under refleak testing (GH-96689)
Automerge-Triggered-By: GH:zware
(cherry picked from commit 9c8f3794337457b1d905a9fa0f38c2978fe32abd)
* gh-95027: Fix regrtest stdout encoding on Windows (#98492)
On Windows, when the Python test suite is run with the -jN option,
the ANSI code page is now used as the encoding for the stdout
temporary file, rather than using UTF-8 which can lead to decoding
errors.
(cherry picked from commit ec1f6f5f139868dc2c1116a7c7c878c38c668d53)
* gh-98903: Test suite fails with exit code 4 if no tests ran (#98904)
The Python test suite now fails wit exit code 4 if no tests ran. It
should help detecting typos in test names and test methods.
* Add "EXITCODE_" constants to Lib/test/libregrtest/main.py.
* Fix a typo: "NO TEST RUN" becomes "NO TESTS RAN"
(cherry picked from commit c76db37c0d23174cbffd6fa978d39693890ef020)
* gh-100086: Add build info to test.libregrtest (#100093)
The Python test runner (libregrtest) now logs Python build information like
"debug" vs "release" build, or LTO and PGO optimizations.
(cherry picked from commit 3c892022472eb975360fb3f0caa6f6fcc6fbf220)
* bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (#30895)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
(cherry picked from commit 995386071f96e4cfebfa027a71ca9134e4651d2a)
* gh-82054: allow test runner to split test_asyncio to execute in parallel by sharding. (#103927)
This runs test_asyncio sub-tests in parallel using sharding from Cinder. This suite is typically the longest-pole in runs because it is a test package with a lot of further sub-tests otherwise run serially. By breaking out the sub-tests as independent modules we can run a lot more in parallel.
After porting we can see the direct impact on a multicore system.
Without this change:
Running make test is 5 min 26 seconds
With this change:
Running make test takes 3 min 39 seconds
That'll vary based on system and parallelism. On a `-j 4` run similar to what CI and buildbot systems often do, it reduced the overall test suite completion latency by 10%.
The drawbacks are that this implementation is hacky and due to the sorting of the tests it obscures when the asyncio tests occur and involves changing CPython test infrastructure but, the wall time saved it is worth it, especially in low-core count CI runs as it pulls a long tail. The win for productivity and reserved CI resource usage is significant.
Future tests that deserve to be refactored into split up suites to benefit from are test_concurrent_futures and the way the _test_multiprocessing suite gets run for all start methods. As exposed by passing the -o flag to python -m test to get a list of the 10 longest running tests.
---------
Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google, LLC]
(cherry picked from commit 9e011e7c77dad7d0bbb944c44891531606caeb21)
* Display the sanitizer config in the regrtest header. (#105301)
Display the sanitizers present in libregrtest.
Having this in the CI output for tests with the relevant environment
variable displayed will help make it easier to do what we need to
create an equivalent local test run.
(cherry picked from commit 852348ab65783601e0844b6647ea033668b45c11)
* gh-101634: regrtest reports decoding error as failed test (#106169)
When running the Python test suite with -jN option, if a worker stdout
cannot be decoded from the locale encoding report a failed testn so the
exitcode is non-zero.
(cherry picked from commit 2ac3eec103cf450aaaebeb932e51155d2e7fb37b)
* gh-108223: test.pythoninfo and libregrtest log Py_NOGIL (#108238)
Enable with --disable-gil --without-pydebug:
$ make pythoninfo|grep NOGIL
sysconfig[Py_NOGIL]: 1
$ ./python -m test
...
== Python build: nogil debug
...
(cherry picked from commit 5afe0c17ca14df430736e549542a4b85e7e7c7ac)
* gh-90791: test.pythoninfo logs ASAN_OPTIONS env var (#108289)
* Cleanup libregrtest code logging ASAN_OPTIONS.
* Fix a typo on "ASAN_OPTIONS" vs "MSAN_OPTIONS".
(cherry picked from commit 3a1ac87f8f89d3206b46a0df4908afae629d669d)
* gh-108388: regrtest splits test_asyncio package (#108393)
Currently, test_asyncio package is only splitted into sub-tests when
using command "./python -m test". With this change, it's also
splitted when passing it on the command line:
"./python -m test test_asyncio".
Remove the concept of "STDTESTS". Python is now mature enough to not
have to bother with that anymore. Removing STDTESTS simplify the
code.
(cherry picked from commit 174e9da0836844a2138cc8915dd305cb2cd7a583)
* regrtest computes statistics (#108793)
test_netrc, test_pep646_syntax and test_xml_etree now return results
in the test_main() function.
Changes:
* Rewrite TestResult as a dataclass with a new State class.
* Add test.support.TestStats class and Regrtest.stats_dict attribute.
* libregrtest.runtest functions now modify a TestResult instance
in-place.
* libregrtest summary lists the number of run tests and skipped
tests, and denied resources.
* Add TestResult.has_meaningful_duration() method.
* Compute TestResult duration in the upper function.
* Use time.perf_counter() instead of time.monotonic().
* Regrtest: rename 'resource_denieds' attribute to 'resource_denied'.
* Rename CHILD_ERROR to MULTIPROCESSING_ERROR.
* Use match/case syntadx to have different code depending on the
test state.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit d4e534cbb35678c82b3a1276826af55d7bfc23b6)
* gh-108822: Add Changelog entry for regrtest statistics (#108821)
---------
Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Zachary Ware <zach@python.org>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Joshua Herman <zitterbewegung@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-09-03 19:21:53 +02:00
|
|
|
- len(omitted) - len(env_changed) - len(run_no_tests))
|
2015-09-30 13:51:17 +02:00
|
|
|
if good:
|
|
|
|
|
regex = r'%s test%s OK\.$' % (good, plural(good))
|
|
|
|
|
if not skipped and not failed and good > 1:
|
|
|
|
|
regex = 'All %s' % regex
|
|
|
|
|
self.check_line(output, regex)
|
2015-09-28 23:16:17 +02:00
|
|
|
|
2016-08-17 16:12:16 +02:00
|
|
|
if interrupted:
|
|
|
|
|
self.check_line(output, 'Test suite interrupted by signal SIGINT.')
|
|
|
|
|
|
[3.11] gh-108822: Backport libregrtest changes from the main branch (#108820)
* Revert "[3.11] gh-101634: regrtest reports decoding error as failed test (#106169) (#106175)"
This reverts commit d5418e97fc524420011a370ba3c2c3cf6a89a74f.
* Revert "[3.11] bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (GH-30895) (GH-103342)"
This reverts commit ecb09a849689764193e0115d27e220f82b5f6d9f.
* Revert "gh-95027: Fix regrtest stdout encoding on Windows (GH-98492)"
This reverts commit b2aa28eec56d07b9c6777b02b7247cf21839de9f.
* Revert "[3.11] gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253) (GH-94408)"
This reverts commit 0122ab235b5acb52dd99fd05d8802a00f438b828.
* Revert "Run Tools/scripts/reindent.py (GH-94225)"
This reverts commit f0f3a424afb00a15ce8c0140dd218f5b33929be6.
* Revert "gh-94052: Don't re-run failed tests with --python option (GH-94054)"
This reverts commit 1347607db12012f6458ffcba48d8ad797083812e.
* Revert "[3.11] gh-84461: Fix Emscripten umask and permission issues (GH-94002) (GH-94006)"
This reverts commit 10731849184a3101ed18683b0128d689f1671c3f.
* gh-93353: regrtest checks for leaked temporary files (#93776)
When running tests with -jN, create a temporary directory per process
and mark a test as "environment changed" if a test leaks a temporary
file or directory.
(cherry picked from commit e566ce5496f1bad81c431aaee65e36d5e44771c5)
* gh-93353: Fix regrtest for -jN with N >= 2 (GH-93813)
(cherry picked from commit 36934a16e86f34d69ba2d41630fb5b4d06d59cff)
* gh-93353: regrtest supports checking tmp files with -j2 (#93909)
regrtest now also implements checking for leaked temporary files and
directories when using -jN for N >= 2. Use tempfile.mkdtemp() to
create the temporary directory. Skip this check on WASI.
(cherry picked from commit 4f85cec9e2077681b3dacc3108e646d509b720bf)
* gh-84461: Fix Emscripten umask and permission issues (GH-94002)
- Emscripten's default umask is too strict, see
https://github.com/emscripten-core/emscripten/issues/17269
- getuid/getgid and geteuid/getegid are stubs that always return 0
(root). Disable effective uid/gid syscalls and fix tests that use
chmod() current user.
- Cannot drop X bit from directory.
(cherry picked from commit 2702e408fd0e0dd7aec396b4cf8c7ce9caae81d8)
* gh-94052: Don't re-run failed tests with --python option (#94054)
(cherry picked from commit 0ff7b996f5d836e63cdaf652c7aa734285261096)
* Run Tools/scripts/reindent.py (#94225)
Reindent files which were not properly formatted (PEP 8: 4 spaces).
Remove also some trailing spaces.
(cherry picked from commit e87ada48a9e5d9d03f9759138869216df0d7383a)
* gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253)
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 199ba233248ab279f445e0809c2077976f0711bc)
* gh-96465: Clear fractions hash lru_cache under refleak testing (GH-96689)
Automerge-Triggered-By: GH:zware
(cherry picked from commit 9c8f3794337457b1d905a9fa0f38c2978fe32abd)
* gh-95027: Fix regrtest stdout encoding on Windows (#98492)
On Windows, when the Python test suite is run with the -jN option,
the ANSI code page is now used as the encoding for the stdout
temporary file, rather than using UTF-8 which can lead to decoding
errors.
(cherry picked from commit ec1f6f5f139868dc2c1116a7c7c878c38c668d53)
* gh-98903: Test suite fails with exit code 4 if no tests ran (#98904)
The Python test suite now fails wit exit code 4 if no tests ran. It
should help detecting typos in test names and test methods.
* Add "EXITCODE_" constants to Lib/test/libregrtest/main.py.
* Fix a typo: "NO TEST RUN" becomes "NO TESTS RAN"
(cherry picked from commit c76db37c0d23174cbffd6fa978d39693890ef020)
* gh-100086: Add build info to test.libregrtest (#100093)
The Python test runner (libregrtest) now logs Python build information like
"debug" vs "release" build, or LTO and PGO optimizations.
(cherry picked from commit 3c892022472eb975360fb3f0caa6f6fcc6fbf220)
* bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (#30895)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
(cherry picked from commit 995386071f96e4cfebfa027a71ca9134e4651d2a)
* gh-82054: allow test runner to split test_asyncio to execute in parallel by sharding. (#103927)
This runs test_asyncio sub-tests in parallel using sharding from Cinder. This suite is typically the longest-pole in runs because it is a test package with a lot of further sub-tests otherwise run serially. By breaking out the sub-tests as independent modules we can run a lot more in parallel.
After porting we can see the direct impact on a multicore system.
Without this change:
Running make test is 5 min 26 seconds
With this change:
Running make test takes 3 min 39 seconds
That'll vary based on system and parallelism. On a `-j 4` run similar to what CI and buildbot systems often do, it reduced the overall test suite completion latency by 10%.
The drawbacks are that this implementation is hacky and due to the sorting of the tests it obscures when the asyncio tests occur and involves changing CPython test infrastructure but, the wall time saved it is worth it, especially in low-core count CI runs as it pulls a long tail. The win for productivity and reserved CI resource usage is significant.
Future tests that deserve to be refactored into split up suites to benefit from are test_concurrent_futures and the way the _test_multiprocessing suite gets run for all start methods. As exposed by passing the -o flag to python -m test to get a list of the 10 longest running tests.
---------
Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google, LLC]
(cherry picked from commit 9e011e7c77dad7d0bbb944c44891531606caeb21)
* Display the sanitizer config in the regrtest header. (#105301)
Display the sanitizers present in libregrtest.
Having this in the CI output for tests with the relevant environment
variable displayed will help make it easier to do what we need to
create an equivalent local test run.
(cherry picked from commit 852348ab65783601e0844b6647ea033668b45c11)
* gh-101634: regrtest reports decoding error as failed test (#106169)
When running the Python test suite with -jN option, if a worker stdout
cannot be decoded from the locale encoding report a failed testn so the
exitcode is non-zero.
(cherry picked from commit 2ac3eec103cf450aaaebeb932e51155d2e7fb37b)
* gh-108223: test.pythoninfo and libregrtest log Py_NOGIL (#108238)
Enable with --disable-gil --without-pydebug:
$ make pythoninfo|grep NOGIL
sysconfig[Py_NOGIL]: 1
$ ./python -m test
...
== Python build: nogil debug
...
(cherry picked from commit 5afe0c17ca14df430736e549542a4b85e7e7c7ac)
* gh-90791: test.pythoninfo logs ASAN_OPTIONS env var (#108289)
* Cleanup libregrtest code logging ASAN_OPTIONS.
* Fix a typo on "ASAN_OPTIONS" vs "MSAN_OPTIONS".
(cherry picked from commit 3a1ac87f8f89d3206b46a0df4908afae629d669d)
* gh-108388: regrtest splits test_asyncio package (#108393)
Currently, test_asyncio package is only splitted into sub-tests when
using command "./python -m test". With this change, it's also
splitted when passing it on the command line:
"./python -m test test_asyncio".
Remove the concept of "STDTESTS". Python is now mature enough to not
have to bother with that anymore. Removing STDTESTS simplify the
code.
(cherry picked from commit 174e9da0836844a2138cc8915dd305cb2cd7a583)
* regrtest computes statistics (#108793)
test_netrc, test_pep646_syntax and test_xml_etree now return results
in the test_main() function.
Changes:
* Rewrite TestResult as a dataclass with a new State class.
* Add test.support.TestStats class and Regrtest.stats_dict attribute.
* libregrtest.runtest functions now modify a TestResult instance
in-place.
* libregrtest summary lists the number of run tests and skipped
tests, and denied resources.
* Add TestResult.has_meaningful_duration() method.
* Compute TestResult duration in the upper function.
* Use time.perf_counter() instead of time.monotonic().
* Regrtest: rename 'resource_denieds' attribute to 'resource_denied'.
* Rename CHILD_ERROR to MULTIPROCESSING_ERROR.
* Use match/case syntadx to have different code depending on the
test state.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit d4e534cbb35678c82b3a1276826af55d7bfc23b6)
* gh-108822: Add Changelog entry for regrtest statistics (#108821)
---------
Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Zachary Ware <zach@python.org>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Joshua Herman <zitterbewegung@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-09-03 19:21:53 +02:00
|
|
|
# Total tests
|
|
|
|
|
parts = [f'run={stats.tests_run:,}']
|
|
|
|
|
if stats.failures:
|
|
|
|
|
parts.append(f'failures={stats.failures:,}')
|
|
|
|
|
if stats.skipped:
|
|
|
|
|
parts.append(f'skipped={stats.skipped:,}')
|
|
|
|
|
line = fr'Total tests: {" ".join(parts)}'
|
|
|
|
|
self.check_line(output, line, full=True)
|
|
|
|
|
|
|
|
|
|
# Total test files
|
|
|
|
|
report = [f'success={good}']
|
|
|
|
|
if failed:
|
|
|
|
|
report.append(f'failed={len(failed)}')
|
|
|
|
|
if env_changed:
|
|
|
|
|
report.append(f'env_changed={len(env_changed)}')
|
|
|
|
|
if skipped:
|
|
|
|
|
report.append(f'skipped={len(skipped)}')
|
|
|
|
|
if resource_denied:
|
|
|
|
|
report.append(f'resource_denied={len(resource_denied)}')
|
|
|
|
|
if rerun:
|
|
|
|
|
report.append(f'rerun={len(rerun)}')
|
|
|
|
|
if run_no_tests:
|
|
|
|
|
report.append(f'run_no_tests={len(run_no_tests)}')
|
|
|
|
|
line = fr'Total test files: {" ".join(report)}'
|
|
|
|
|
self.check_line(output, line, full=True)
|
|
|
|
|
|
|
|
|
|
# Result
|
2018-06-08 09:53:51 +02:00
|
|
|
result = []
|
2017-06-26 18:33:19 +02:00
|
|
|
if failed:
|
2018-06-08 09:53:51 +02:00
|
|
|
result.append('FAILURE')
|
2017-06-26 18:33:19 +02:00
|
|
|
elif fail_env_changed and env_changed:
|
2018-06-08 09:53:51 +02:00
|
|
|
result.append('ENV CHANGED')
|
|
|
|
|
if interrupted:
|
|
|
|
|
result.append('INTERRUPTED')
|
2018-11-29 17:17:44 +00:00
|
|
|
if not any((good, result, failed, interrupted, skipped,
|
|
|
|
|
env_changed, fail_env_changed)):
|
[3.11] gh-108822: Backport libregrtest changes from the main branch (#108820)
* Revert "[3.11] gh-101634: regrtest reports decoding error as failed test (#106169) (#106175)"
This reverts commit d5418e97fc524420011a370ba3c2c3cf6a89a74f.
* Revert "[3.11] bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (GH-30895) (GH-103342)"
This reverts commit ecb09a849689764193e0115d27e220f82b5f6d9f.
* Revert "gh-95027: Fix regrtest stdout encoding on Windows (GH-98492)"
This reverts commit b2aa28eec56d07b9c6777b02b7247cf21839de9f.
* Revert "[3.11] gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253) (GH-94408)"
This reverts commit 0122ab235b5acb52dd99fd05d8802a00f438b828.
* Revert "Run Tools/scripts/reindent.py (GH-94225)"
This reverts commit f0f3a424afb00a15ce8c0140dd218f5b33929be6.
* Revert "gh-94052: Don't re-run failed tests with --python option (GH-94054)"
This reverts commit 1347607db12012f6458ffcba48d8ad797083812e.
* Revert "[3.11] gh-84461: Fix Emscripten umask and permission issues (GH-94002) (GH-94006)"
This reverts commit 10731849184a3101ed18683b0128d689f1671c3f.
* gh-93353: regrtest checks for leaked temporary files (#93776)
When running tests with -jN, create a temporary directory per process
and mark a test as "environment changed" if a test leaks a temporary
file or directory.
(cherry picked from commit e566ce5496f1bad81c431aaee65e36d5e44771c5)
* gh-93353: Fix regrtest for -jN with N >= 2 (GH-93813)
(cherry picked from commit 36934a16e86f34d69ba2d41630fb5b4d06d59cff)
* gh-93353: regrtest supports checking tmp files with -j2 (#93909)
regrtest now also implements checking for leaked temporary files and
directories when using -jN for N >= 2. Use tempfile.mkdtemp() to
create the temporary directory. Skip this check on WASI.
(cherry picked from commit 4f85cec9e2077681b3dacc3108e646d509b720bf)
* gh-84461: Fix Emscripten umask and permission issues (GH-94002)
- Emscripten's default umask is too strict, see
https://github.com/emscripten-core/emscripten/issues/17269
- getuid/getgid and geteuid/getegid are stubs that always return 0
(root). Disable effective uid/gid syscalls and fix tests that use
chmod() current user.
- Cannot drop X bit from directory.
(cherry picked from commit 2702e408fd0e0dd7aec396b4cf8c7ce9caae81d8)
* gh-94052: Don't re-run failed tests with --python option (#94054)
(cherry picked from commit 0ff7b996f5d836e63cdaf652c7aa734285261096)
* Run Tools/scripts/reindent.py (#94225)
Reindent files which were not properly formatted (PEP 8: 4 spaces).
Remove also some trailing spaces.
(cherry picked from commit e87ada48a9e5d9d03f9759138869216df0d7383a)
* gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253)
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 199ba233248ab279f445e0809c2077976f0711bc)
* gh-96465: Clear fractions hash lru_cache under refleak testing (GH-96689)
Automerge-Triggered-By: GH:zware
(cherry picked from commit 9c8f3794337457b1d905a9fa0f38c2978fe32abd)
* gh-95027: Fix regrtest stdout encoding on Windows (#98492)
On Windows, when the Python test suite is run with the -jN option,
the ANSI code page is now used as the encoding for the stdout
temporary file, rather than using UTF-8 which can lead to decoding
errors.
(cherry picked from commit ec1f6f5f139868dc2c1116a7c7c878c38c668d53)
* gh-98903: Test suite fails with exit code 4 if no tests ran (#98904)
The Python test suite now fails wit exit code 4 if no tests ran. It
should help detecting typos in test names and test methods.
* Add "EXITCODE_" constants to Lib/test/libregrtest/main.py.
* Fix a typo: "NO TEST RUN" becomes "NO TESTS RAN"
(cherry picked from commit c76db37c0d23174cbffd6fa978d39693890ef020)
* gh-100086: Add build info to test.libregrtest (#100093)
The Python test runner (libregrtest) now logs Python build information like
"debug" vs "release" build, or LTO and PGO optimizations.
(cherry picked from commit 3c892022472eb975360fb3f0caa6f6fcc6fbf220)
* bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (#30895)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
(cherry picked from commit 995386071f96e4cfebfa027a71ca9134e4651d2a)
* gh-82054: allow test runner to split test_asyncio to execute in parallel by sharding. (#103927)
This runs test_asyncio sub-tests in parallel using sharding from Cinder. This suite is typically the longest-pole in runs because it is a test package with a lot of further sub-tests otherwise run serially. By breaking out the sub-tests as independent modules we can run a lot more in parallel.
After porting we can see the direct impact on a multicore system.
Without this change:
Running make test is 5 min 26 seconds
With this change:
Running make test takes 3 min 39 seconds
That'll vary based on system and parallelism. On a `-j 4` run similar to what CI and buildbot systems often do, it reduced the overall test suite completion latency by 10%.
The drawbacks are that this implementation is hacky and due to the sorting of the tests it obscures when the asyncio tests occur and involves changing CPython test infrastructure but, the wall time saved it is worth it, especially in low-core count CI runs as it pulls a long tail. The win for productivity and reserved CI resource usage is significant.
Future tests that deserve to be refactored into split up suites to benefit from are test_concurrent_futures and the way the _test_multiprocessing suite gets run for all start methods. As exposed by passing the -o flag to python -m test to get a list of the 10 longest running tests.
---------
Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google, LLC]
(cherry picked from commit 9e011e7c77dad7d0bbb944c44891531606caeb21)
* Display the sanitizer config in the regrtest header. (#105301)
Display the sanitizers present in libregrtest.
Having this in the CI output for tests with the relevant environment
variable displayed will help make it easier to do what we need to
create an equivalent local test run.
(cherry picked from commit 852348ab65783601e0844b6647ea033668b45c11)
* gh-101634: regrtest reports decoding error as failed test (#106169)
When running the Python test suite with -jN option, if a worker stdout
cannot be decoded from the locale encoding report a failed testn so the
exitcode is non-zero.
(cherry picked from commit 2ac3eec103cf450aaaebeb932e51155d2e7fb37b)
* gh-108223: test.pythoninfo and libregrtest log Py_NOGIL (#108238)
Enable with --disable-gil --without-pydebug:
$ make pythoninfo|grep NOGIL
sysconfig[Py_NOGIL]: 1
$ ./python -m test
...
== Python build: nogil debug
...
(cherry picked from commit 5afe0c17ca14df430736e549542a4b85e7e7c7ac)
* gh-90791: test.pythoninfo logs ASAN_OPTIONS env var (#108289)
* Cleanup libregrtest code logging ASAN_OPTIONS.
* Fix a typo on "ASAN_OPTIONS" vs "MSAN_OPTIONS".
(cherry picked from commit 3a1ac87f8f89d3206b46a0df4908afae629d669d)
* gh-108388: regrtest splits test_asyncio package (#108393)
Currently, test_asyncio package is only splitted into sub-tests when
using command "./python -m test". With this change, it's also
splitted when passing it on the command line:
"./python -m test test_asyncio".
Remove the concept of "STDTESTS". Python is now mature enough to not
have to bother with that anymore. Removing STDTESTS simplify the
code.
(cherry picked from commit 174e9da0836844a2138cc8915dd305cb2cd7a583)
* regrtest computes statistics (#108793)
test_netrc, test_pep646_syntax and test_xml_etree now return results
in the test_main() function.
Changes:
* Rewrite TestResult as a dataclass with a new State class.
* Add test.support.TestStats class and Regrtest.stats_dict attribute.
* libregrtest.runtest functions now modify a TestResult instance
in-place.
* libregrtest summary lists the number of run tests and skipped
tests, and denied resources.
* Add TestResult.has_meaningful_duration() method.
* Compute TestResult duration in the upper function.
* Use time.perf_counter() instead of time.monotonic().
* Regrtest: rename 'resource_denieds' attribute to 'resource_denied'.
* Rename CHILD_ERROR to MULTIPROCESSING_ERROR.
* Use match/case syntadx to have different code depending on the
test state.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit d4e534cbb35678c82b3a1276826af55d7bfc23b6)
* gh-108822: Add Changelog entry for regrtest statistics (#108821)
---------
Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Zachary Ware <zach@python.org>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Joshua Herman <zitterbewegung@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-09-03 19:21:53 +02:00
|
|
|
result.append("NO TESTS RAN")
|
2018-11-29 17:17:44 +00:00
|
|
|
elif not result:
|
2018-06-08 09:53:51 +02:00
|
|
|
result.append('SUCCESS')
|
|
|
|
|
result = ', '.join(result)
|
|
|
|
|
if rerun:
|
|
|
|
|
result = 'FAILURE then %s' % result
|
[3.11] gh-108822: Backport libregrtest changes from the main branch (#108820)
* Revert "[3.11] gh-101634: regrtest reports decoding error as failed test (#106169) (#106175)"
This reverts commit d5418e97fc524420011a370ba3c2c3cf6a89a74f.
* Revert "[3.11] bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (GH-30895) (GH-103342)"
This reverts commit ecb09a849689764193e0115d27e220f82b5f6d9f.
* Revert "gh-95027: Fix regrtest stdout encoding on Windows (GH-98492)"
This reverts commit b2aa28eec56d07b9c6777b02b7247cf21839de9f.
* Revert "[3.11] gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253) (GH-94408)"
This reverts commit 0122ab235b5acb52dd99fd05d8802a00f438b828.
* Revert "Run Tools/scripts/reindent.py (GH-94225)"
This reverts commit f0f3a424afb00a15ce8c0140dd218f5b33929be6.
* Revert "gh-94052: Don't re-run failed tests with --python option (GH-94054)"
This reverts commit 1347607db12012f6458ffcba48d8ad797083812e.
* Revert "[3.11] gh-84461: Fix Emscripten umask and permission issues (GH-94002) (GH-94006)"
This reverts commit 10731849184a3101ed18683b0128d689f1671c3f.
* gh-93353: regrtest checks for leaked temporary files (#93776)
When running tests with -jN, create a temporary directory per process
and mark a test as "environment changed" if a test leaks a temporary
file or directory.
(cherry picked from commit e566ce5496f1bad81c431aaee65e36d5e44771c5)
* gh-93353: Fix regrtest for -jN with N >= 2 (GH-93813)
(cherry picked from commit 36934a16e86f34d69ba2d41630fb5b4d06d59cff)
* gh-93353: regrtest supports checking tmp files with -j2 (#93909)
regrtest now also implements checking for leaked temporary files and
directories when using -jN for N >= 2. Use tempfile.mkdtemp() to
create the temporary directory. Skip this check on WASI.
(cherry picked from commit 4f85cec9e2077681b3dacc3108e646d509b720bf)
* gh-84461: Fix Emscripten umask and permission issues (GH-94002)
- Emscripten's default umask is too strict, see
https://github.com/emscripten-core/emscripten/issues/17269
- getuid/getgid and geteuid/getegid are stubs that always return 0
(root). Disable effective uid/gid syscalls and fix tests that use
chmod() current user.
- Cannot drop X bit from directory.
(cherry picked from commit 2702e408fd0e0dd7aec396b4cf8c7ce9caae81d8)
* gh-94052: Don't re-run failed tests with --python option (#94054)
(cherry picked from commit 0ff7b996f5d836e63cdaf652c7aa734285261096)
* Run Tools/scripts/reindent.py (#94225)
Reindent files which were not properly formatted (PEP 8: 4 spaces).
Remove also some trailing spaces.
(cherry picked from commit e87ada48a9e5d9d03f9759138869216df0d7383a)
* gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253)
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 199ba233248ab279f445e0809c2077976f0711bc)
* gh-96465: Clear fractions hash lru_cache under refleak testing (GH-96689)
Automerge-Triggered-By: GH:zware
(cherry picked from commit 9c8f3794337457b1d905a9fa0f38c2978fe32abd)
* gh-95027: Fix regrtest stdout encoding on Windows (#98492)
On Windows, when the Python test suite is run with the -jN option,
the ANSI code page is now used as the encoding for the stdout
temporary file, rather than using UTF-8 which can lead to decoding
errors.
(cherry picked from commit ec1f6f5f139868dc2c1116a7c7c878c38c668d53)
* gh-98903: Test suite fails with exit code 4 if no tests ran (#98904)
The Python test suite now fails wit exit code 4 if no tests ran. It
should help detecting typos in test names and test methods.
* Add "EXITCODE_" constants to Lib/test/libregrtest/main.py.
* Fix a typo: "NO TEST RUN" becomes "NO TESTS RAN"
(cherry picked from commit c76db37c0d23174cbffd6fa978d39693890ef020)
* gh-100086: Add build info to test.libregrtest (#100093)
The Python test runner (libregrtest) now logs Python build information like
"debug" vs "release" build, or LTO and PGO optimizations.
(cherry picked from commit 3c892022472eb975360fb3f0caa6f6fcc6fbf220)
* bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (#30895)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
(cherry picked from commit 995386071f96e4cfebfa027a71ca9134e4651d2a)
* gh-82054: allow test runner to split test_asyncio to execute in parallel by sharding. (#103927)
This runs test_asyncio sub-tests in parallel using sharding from Cinder. This suite is typically the longest-pole in runs because it is a test package with a lot of further sub-tests otherwise run serially. By breaking out the sub-tests as independent modules we can run a lot more in parallel.
After porting we can see the direct impact on a multicore system.
Without this change:
Running make test is 5 min 26 seconds
With this change:
Running make test takes 3 min 39 seconds
That'll vary based on system and parallelism. On a `-j 4` run similar to what CI and buildbot systems often do, it reduced the overall test suite completion latency by 10%.
The drawbacks are that this implementation is hacky and due to the sorting of the tests it obscures when the asyncio tests occur and involves changing CPython test infrastructure but, the wall time saved it is worth it, especially in low-core count CI runs as it pulls a long tail. The win for productivity and reserved CI resource usage is significant.
Future tests that deserve to be refactored into split up suites to benefit from are test_concurrent_futures and the way the _test_multiprocessing suite gets run for all start methods. As exposed by passing the -o flag to python -m test to get a list of the 10 longest running tests.
---------
Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google, LLC]
(cherry picked from commit 9e011e7c77dad7d0bbb944c44891531606caeb21)
* Display the sanitizer config in the regrtest header. (#105301)
Display the sanitizers present in libregrtest.
Having this in the CI output for tests with the relevant environment
variable displayed will help make it easier to do what we need to
create an equivalent local test run.
(cherry picked from commit 852348ab65783601e0844b6647ea033668b45c11)
* gh-101634: regrtest reports decoding error as failed test (#106169)
When running the Python test suite with -jN option, if a worker stdout
cannot be decoded from the locale encoding report a failed testn so the
exitcode is non-zero.
(cherry picked from commit 2ac3eec103cf450aaaebeb932e51155d2e7fb37b)
* gh-108223: test.pythoninfo and libregrtest log Py_NOGIL (#108238)
Enable with --disable-gil --without-pydebug:
$ make pythoninfo|grep NOGIL
sysconfig[Py_NOGIL]: 1
$ ./python -m test
...
== Python build: nogil debug
...
(cherry picked from commit 5afe0c17ca14df430736e549542a4b85e7e7c7ac)
* gh-90791: test.pythoninfo logs ASAN_OPTIONS env var (#108289)
* Cleanup libregrtest code logging ASAN_OPTIONS.
* Fix a typo on "ASAN_OPTIONS" vs "MSAN_OPTIONS".
(cherry picked from commit 3a1ac87f8f89d3206b46a0df4908afae629d669d)
* gh-108388: regrtest splits test_asyncio package (#108393)
Currently, test_asyncio package is only splitted into sub-tests when
using command "./python -m test". With this change, it's also
splitted when passing it on the command line:
"./python -m test test_asyncio".
Remove the concept of "STDTESTS". Python is now mature enough to not
have to bother with that anymore. Removing STDTESTS simplify the
code.
(cherry picked from commit 174e9da0836844a2138cc8915dd305cb2cd7a583)
* regrtest computes statistics (#108793)
test_netrc, test_pep646_syntax and test_xml_etree now return results
in the test_main() function.
Changes:
* Rewrite TestResult as a dataclass with a new State class.
* Add test.support.TestStats class and Regrtest.stats_dict attribute.
* libregrtest.runtest functions now modify a TestResult instance
in-place.
* libregrtest summary lists the number of run tests and skipped
tests, and denied resources.
* Add TestResult.has_meaningful_duration() method.
* Compute TestResult duration in the upper function.
* Use time.perf_counter() instead of time.monotonic().
* Regrtest: rename 'resource_denieds' attribute to 'resource_denied'.
* Rename CHILD_ERROR to MULTIPROCESSING_ERROR.
* Use match/case syntadx to have different code depending on the
test state.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit d4e534cbb35678c82b3a1276826af55d7bfc23b6)
* gh-108822: Add Changelog entry for regrtest statistics (#108821)
---------
Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Zachary Ware <zach@python.org>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Joshua Herman <zitterbewegung@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-09-03 19:21:53 +02:00
|
|
|
self.check_line(output, f'Result: {result}', full=True)
|
2016-08-17 16:12:16 +02:00
|
|
|
|
2015-09-28 23:16:17 +02:00
|
|
|
def parse_random_seed(self, output):
|
|
|
|
|
match = self.regex_search(r'Using random seed ([0-9]+)', output)
|
|
|
|
|
randseed = int(match.group(1))
|
|
|
|
|
self.assertTrue(0 <= randseed <= 10000000, randseed)
|
|
|
|
|
return randseed
|
|
|
|
|
|
2015-10-03 00:20:56 +02:00
|
|
|
def run_command(self, args, input=None, exitcode=0, **kw):
|
2015-09-29 14:17:09 +02:00
|
|
|
if not input:
|
|
|
|
|
input = ''
|
2015-10-03 00:20:56 +02:00
|
|
|
if 'stderr' not in kw:
|
2019-06-13 01:09:04 +02:00
|
|
|
kw['stderr'] = subprocess.STDOUT
|
2015-09-30 13:51:17 +02:00
|
|
|
proc = subprocess.run(args,
|
|
|
|
|
universal_newlines=True,
|
|
|
|
|
input=input,
|
|
|
|
|
stdout=subprocess.PIPE,
|
2015-10-03 00:20:56 +02:00
|
|
|
**kw)
|
2015-09-30 13:51:17 +02:00
|
|
|
if proc.returncode != exitcode:
|
2015-10-03 00:20:56 +02:00
|
|
|
msg = ("Command %s failed with exit code %s\n"
|
|
|
|
|
"\n"
|
|
|
|
|
"stdout:\n"
|
|
|
|
|
"---\n"
|
|
|
|
|
"%s\n"
|
|
|
|
|
"---\n"
|
|
|
|
|
% (str(args), proc.returncode, proc.stdout))
|
|
|
|
|
if proc.stderr:
|
|
|
|
|
msg += ("\n"
|
|
|
|
|
"stderr:\n"
|
|
|
|
|
"---\n"
|
|
|
|
|
"%s"
|
|
|
|
|
"---\n"
|
|
|
|
|
% proc.stderr)
|
|
|
|
|
self.fail(msg)
|
2015-09-30 13:51:17 +02:00
|
|
|
return proc
|
2015-09-29 14:17:09 +02:00
|
|
|
|
|
|
|
|
def run_python(self, args, **kw):
|
|
|
|
|
args = [sys.executable, '-X', 'faulthandler', '-I', *args]
|
|
|
|
|
proc = self.run_command(args, **kw)
|
|
|
|
|
return proc.stdout
|
|
|
|
|
|
2015-09-28 23:16:17 +02:00
|
|
|
|
2019-07-23 22:28:48 -07:00
|
|
|
class CheckActualTests(BaseTestCase):
|
|
|
|
|
def test_finds_expected_number_of_tests(self):
|
2021-07-22 20:25:58 +02:00
|
|
|
"""
|
|
|
|
|
Check that regrtest appears to find the expected set of tests.
|
|
|
|
|
"""
|
2019-07-23 22:28:48 -07:00
|
|
|
args = ['-Wd', '-E', '-bb', '-m', 'test.regrtest', '--list-tests']
|
|
|
|
|
output = self.run_python(args)
|
|
|
|
|
rough_number_of_tests_found = len(output.splitlines())
|
2020-06-20 11:10:31 +03:00
|
|
|
actual_testsuite_glob = os.path.join(glob.escape(os.path.dirname(__file__)),
|
2019-07-23 22:28:48 -07:00
|
|
|
'test*.py')
|
|
|
|
|
rough_counted_test_py_files = len(glob.glob(actual_testsuite_glob))
|
|
|
|
|
# We're not trying to duplicate test finding logic in here,
|
|
|
|
|
# just give a rough estimate of how many there should be and
|
|
|
|
|
# be near that. This is a regression test to prevent mishaps
|
|
|
|
|
# such as https://bugs.python.org/issue37667 in the future.
|
|
|
|
|
# If you need to change the values in here during some
|
|
|
|
|
# mythical future test suite reorganization, don't go
|
|
|
|
|
# overboard with logic and keep that goal in mind.
|
|
|
|
|
self.assertGreater(rough_number_of_tests_found,
|
|
|
|
|
rough_counted_test_py_files*9//10,
|
|
|
|
|
msg='Unexpectedly low number of tests found in:\n'
|
|
|
|
|
f'{", ".join(output.splitlines())}')
|
|
|
|
|
|
|
|
|
|
|
2015-09-28 23:16:17 +02:00
|
|
|
class ProgramsTestCase(BaseTestCase):
|
|
|
|
|
"""
|
|
|
|
|
Test various ways to run the Python test suite. Use options close
|
|
|
|
|
to options used on the buildbot.
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
NTEST = 4
|
|
|
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
|
super().setUp()
|
|
|
|
|
|
|
|
|
|
# Create NTEST tests doing nothing
|
|
|
|
|
self.tests = [self.create_test() for index in range(self.NTEST)]
|
|
|
|
|
|
|
|
|
|
self.python_args = ['-Wd', '-E', '-bb']
|
2016-03-30 02:33:52 +02:00
|
|
|
self.regrtest_args = ['-uall', '-rwW',
|
|
|
|
|
'--testdir=%s' % self.tmptestdir]
|
2019-09-18 14:15:10 +02:00
|
|
|
self.regrtest_args.extend(('--timeout', '3600', '-j4'))
|
2015-09-28 23:16:17 +02:00
|
|
|
if sys.platform == 'win32':
|
|
|
|
|
self.regrtest_args.append('-n')
|
|
|
|
|
|
|
|
|
|
def check_output(self, output):
|
|
|
|
|
self.parse_random_seed(output)
|
[3.11] gh-108822: Backport libregrtest changes from the main branch (#108820)
* Revert "[3.11] gh-101634: regrtest reports decoding error as failed test (#106169) (#106175)"
This reverts commit d5418e97fc524420011a370ba3c2c3cf6a89a74f.
* Revert "[3.11] bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (GH-30895) (GH-103342)"
This reverts commit ecb09a849689764193e0115d27e220f82b5f6d9f.
* Revert "gh-95027: Fix regrtest stdout encoding on Windows (GH-98492)"
This reverts commit b2aa28eec56d07b9c6777b02b7247cf21839de9f.
* Revert "[3.11] gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253) (GH-94408)"
This reverts commit 0122ab235b5acb52dd99fd05d8802a00f438b828.
* Revert "Run Tools/scripts/reindent.py (GH-94225)"
This reverts commit f0f3a424afb00a15ce8c0140dd218f5b33929be6.
* Revert "gh-94052: Don't re-run failed tests with --python option (GH-94054)"
This reverts commit 1347607db12012f6458ffcba48d8ad797083812e.
* Revert "[3.11] gh-84461: Fix Emscripten umask and permission issues (GH-94002) (GH-94006)"
This reverts commit 10731849184a3101ed18683b0128d689f1671c3f.
* gh-93353: regrtest checks for leaked temporary files (#93776)
When running tests with -jN, create a temporary directory per process
and mark a test as "environment changed" if a test leaks a temporary
file or directory.
(cherry picked from commit e566ce5496f1bad81c431aaee65e36d5e44771c5)
* gh-93353: Fix regrtest for -jN with N >= 2 (GH-93813)
(cherry picked from commit 36934a16e86f34d69ba2d41630fb5b4d06d59cff)
* gh-93353: regrtest supports checking tmp files with -j2 (#93909)
regrtest now also implements checking for leaked temporary files and
directories when using -jN for N >= 2. Use tempfile.mkdtemp() to
create the temporary directory. Skip this check on WASI.
(cherry picked from commit 4f85cec9e2077681b3dacc3108e646d509b720bf)
* gh-84461: Fix Emscripten umask and permission issues (GH-94002)
- Emscripten's default umask is too strict, see
https://github.com/emscripten-core/emscripten/issues/17269
- getuid/getgid and geteuid/getegid are stubs that always return 0
(root). Disable effective uid/gid syscalls and fix tests that use
chmod() current user.
- Cannot drop X bit from directory.
(cherry picked from commit 2702e408fd0e0dd7aec396b4cf8c7ce9caae81d8)
* gh-94052: Don't re-run failed tests with --python option (#94054)
(cherry picked from commit 0ff7b996f5d836e63cdaf652c7aa734285261096)
* Run Tools/scripts/reindent.py (#94225)
Reindent files which were not properly formatted (PEP 8: 4 spaces).
Remove also some trailing spaces.
(cherry picked from commit e87ada48a9e5d9d03f9759138869216df0d7383a)
* gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253)
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 199ba233248ab279f445e0809c2077976f0711bc)
* gh-96465: Clear fractions hash lru_cache under refleak testing (GH-96689)
Automerge-Triggered-By: GH:zware
(cherry picked from commit 9c8f3794337457b1d905a9fa0f38c2978fe32abd)
* gh-95027: Fix regrtest stdout encoding on Windows (#98492)
On Windows, when the Python test suite is run with the -jN option,
the ANSI code page is now used as the encoding for the stdout
temporary file, rather than using UTF-8 which can lead to decoding
errors.
(cherry picked from commit ec1f6f5f139868dc2c1116a7c7c878c38c668d53)
* gh-98903: Test suite fails with exit code 4 if no tests ran (#98904)
The Python test suite now fails wit exit code 4 if no tests ran. It
should help detecting typos in test names and test methods.
* Add "EXITCODE_" constants to Lib/test/libregrtest/main.py.
* Fix a typo: "NO TEST RUN" becomes "NO TESTS RAN"
(cherry picked from commit c76db37c0d23174cbffd6fa978d39693890ef020)
* gh-100086: Add build info to test.libregrtest (#100093)
The Python test runner (libregrtest) now logs Python build information like
"debug" vs "release" build, or LTO and PGO optimizations.
(cherry picked from commit 3c892022472eb975360fb3f0caa6f6fcc6fbf220)
* bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (#30895)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
(cherry picked from commit 995386071f96e4cfebfa027a71ca9134e4651d2a)
* gh-82054: allow test runner to split test_asyncio to execute in parallel by sharding. (#103927)
This runs test_asyncio sub-tests in parallel using sharding from Cinder. This suite is typically the longest-pole in runs because it is a test package with a lot of further sub-tests otherwise run serially. By breaking out the sub-tests as independent modules we can run a lot more in parallel.
After porting we can see the direct impact on a multicore system.
Without this change:
Running make test is 5 min 26 seconds
With this change:
Running make test takes 3 min 39 seconds
That'll vary based on system and parallelism. On a `-j 4` run similar to what CI and buildbot systems often do, it reduced the overall test suite completion latency by 10%.
The drawbacks are that this implementation is hacky and due to the sorting of the tests it obscures when the asyncio tests occur and involves changing CPython test infrastructure but, the wall time saved it is worth it, especially in low-core count CI runs as it pulls a long tail. The win for productivity and reserved CI resource usage is significant.
Future tests that deserve to be refactored into split up suites to benefit from are test_concurrent_futures and the way the _test_multiprocessing suite gets run for all start methods. As exposed by passing the -o flag to python -m test to get a list of the 10 longest running tests.
---------
Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google, LLC]
(cherry picked from commit 9e011e7c77dad7d0bbb944c44891531606caeb21)
* Display the sanitizer config in the regrtest header. (#105301)
Display the sanitizers present in libregrtest.
Having this in the CI output for tests with the relevant environment
variable displayed will help make it easier to do what we need to
create an equivalent local test run.
(cherry picked from commit 852348ab65783601e0844b6647ea033668b45c11)
* gh-101634: regrtest reports decoding error as failed test (#106169)
When running the Python test suite with -jN option, if a worker stdout
cannot be decoded from the locale encoding report a failed testn so the
exitcode is non-zero.
(cherry picked from commit 2ac3eec103cf450aaaebeb932e51155d2e7fb37b)
* gh-108223: test.pythoninfo and libregrtest log Py_NOGIL (#108238)
Enable with --disable-gil --without-pydebug:
$ make pythoninfo|grep NOGIL
sysconfig[Py_NOGIL]: 1
$ ./python -m test
...
== Python build: nogil debug
...
(cherry picked from commit 5afe0c17ca14df430736e549542a4b85e7e7c7ac)
* gh-90791: test.pythoninfo logs ASAN_OPTIONS env var (#108289)
* Cleanup libregrtest code logging ASAN_OPTIONS.
* Fix a typo on "ASAN_OPTIONS" vs "MSAN_OPTIONS".
(cherry picked from commit 3a1ac87f8f89d3206b46a0df4908afae629d669d)
* gh-108388: regrtest splits test_asyncio package (#108393)
Currently, test_asyncio package is only splitted into sub-tests when
using command "./python -m test". With this change, it's also
splitted when passing it on the command line:
"./python -m test test_asyncio".
Remove the concept of "STDTESTS". Python is now mature enough to not
have to bother with that anymore. Removing STDTESTS simplify the
code.
(cherry picked from commit 174e9da0836844a2138cc8915dd305cb2cd7a583)
* regrtest computes statistics (#108793)
test_netrc, test_pep646_syntax and test_xml_etree now return results
in the test_main() function.
Changes:
* Rewrite TestResult as a dataclass with a new State class.
* Add test.support.TestStats class and Regrtest.stats_dict attribute.
* libregrtest.runtest functions now modify a TestResult instance
in-place.
* libregrtest summary lists the number of run tests and skipped
tests, and denied resources.
* Add TestResult.has_meaningful_duration() method.
* Compute TestResult duration in the upper function.
* Use time.perf_counter() instead of time.monotonic().
* Regrtest: rename 'resource_denieds' attribute to 'resource_denied'.
* Rename CHILD_ERROR to MULTIPROCESSING_ERROR.
* Use match/case syntadx to have different code depending on the
test state.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit d4e534cbb35678c82b3a1276826af55d7bfc23b6)
* gh-108822: Add Changelog entry for regrtest statistics (#108821)
---------
Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Zachary Ware <zach@python.org>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Joshua Herman <zitterbewegung@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-09-03 19:21:53 +02:00
|
|
|
self.check_executed_tests(output, self.tests,
|
|
|
|
|
randomize=True, stats=len(self.tests))
|
2015-09-28 23:16:17 +02:00
|
|
|
|
|
|
|
|
def run_tests(self, args):
|
2015-09-30 13:51:17 +02:00
|
|
|
output = self.run_python(args)
|
|
|
|
|
self.check_output(output)
|
2015-09-28 23:16:17 +02:00
|
|
|
|
|
|
|
|
def test_script_regrtest(self):
|
|
|
|
|
# Lib/test/regrtest.py
|
2015-11-22 15:18:54 +01:00
|
|
|
script = os.path.join(self.testdir, 'regrtest.py')
|
2015-09-28 23:16:17 +02:00
|
|
|
|
|
|
|
|
args = [*self.python_args, script, *self.regrtest_args, *self.tests]
|
|
|
|
|
self.run_tests(args)
|
|
|
|
|
|
|
|
|
|
def test_module_test(self):
|
|
|
|
|
# -m test
|
|
|
|
|
args = [*self.python_args, '-m', 'test',
|
|
|
|
|
*self.regrtest_args, *self.tests]
|
|
|
|
|
self.run_tests(args)
|
|
|
|
|
|
|
|
|
|
def test_module_regrtest(self):
|
|
|
|
|
# -m test.regrtest
|
|
|
|
|
args = [*self.python_args, '-m', 'test.regrtest',
|
|
|
|
|
*self.regrtest_args, *self.tests]
|
|
|
|
|
self.run_tests(args)
|
|
|
|
|
|
|
|
|
|
def test_module_autotest(self):
|
|
|
|
|
# -m test.autotest
|
|
|
|
|
args = [*self.python_args, '-m', 'test.autotest',
|
|
|
|
|
*self.regrtest_args, *self.tests]
|
|
|
|
|
self.run_tests(args)
|
|
|
|
|
|
|
|
|
|
def test_module_from_test_autotest(self):
|
|
|
|
|
# from test import autotest
|
|
|
|
|
code = 'from test import autotest'
|
|
|
|
|
args = [*self.python_args, '-c', code,
|
|
|
|
|
*self.regrtest_args, *self.tests]
|
|
|
|
|
self.run_tests(args)
|
|
|
|
|
|
|
|
|
|
def test_script_autotest(self):
|
|
|
|
|
# Lib/test/autotest.py
|
2015-11-22 15:18:54 +01:00
|
|
|
script = os.path.join(self.testdir, 'autotest.py')
|
2015-09-28 23:16:17 +02:00
|
|
|
args = [*self.python_args, script, *self.regrtest_args, *self.tests]
|
|
|
|
|
self.run_tests(args)
|
|
|
|
|
|
2015-11-22 15:18:54 +01:00
|
|
|
@unittest.skipUnless(sysconfig.is_python_build(),
|
|
|
|
|
'run_tests.py script is not installed')
|
2015-09-28 23:16:17 +02:00
|
|
|
def test_tools_script_run_tests(self):
|
|
|
|
|
# Tools/scripts/run_tests.py
|
|
|
|
|
script = os.path.join(ROOT_DIR, 'Tools', 'scripts', 'run_tests.py')
|
2016-03-30 08:51:15 +02:00
|
|
|
args = [script, *self.regrtest_args, *self.tests]
|
2016-03-30 02:33:52 +02:00
|
|
|
self.run_tests(args)
|
2015-09-28 23:16:17 +02:00
|
|
|
|
2015-09-29 01:02:37 +02:00
|
|
|
def run_batch(self, *args):
|
2015-09-29 14:17:09 +02:00
|
|
|
proc = self.run_command(args)
|
2015-09-28 23:16:17 +02:00
|
|
|
self.check_output(proc.stdout)
|
|
|
|
|
|
2015-11-22 15:18:54 +01:00
|
|
|
@unittest.skipUnless(sysconfig.is_python_build(),
|
|
|
|
|
'test.bat script is not installed')
|
2015-09-28 23:16:17 +02:00
|
|
|
@unittest.skipUnless(sys.platform == 'win32', 'Windows only')
|
|
|
|
|
def test_tools_buildbot_test(self):
|
|
|
|
|
# Tools\buildbot\test.bat
|
|
|
|
|
script = os.path.join(ROOT_DIR, 'Tools', 'buildbot', 'test.bat')
|
2016-03-30 08:38:05 +02:00
|
|
|
test_args = ['--testdir=%s' % self.tmptestdir]
|
2019-06-07 10:58:41 -07:00
|
|
|
if platform.machine() == 'ARM64':
|
|
|
|
|
test_args.append('-arm64') # ARM 64-bit build
|
2019-06-19 13:09:54 -07:00
|
|
|
elif platform.machine() == 'ARM':
|
|
|
|
|
test_args.append('-arm32') # 32-bit ARM build
|
2019-06-07 10:58:41 -07:00
|
|
|
elif platform.architecture()[0] == '64bit':
|
2015-09-29 01:02:37 +02:00
|
|
|
test_args.append('-x64') # 64-bit build
|
|
|
|
|
if not Py_DEBUG:
|
|
|
|
|
test_args.append('+d') # Release build, use python.exe
|
|
|
|
|
self.run_batch(script, *test_args, *self.tests)
|
2015-09-28 23:16:17 +02:00
|
|
|
|
|
|
|
|
@unittest.skipUnless(sys.platform == 'win32', 'Windows only')
|
|
|
|
|
def test_pcbuild_rt(self):
|
|
|
|
|
# PCbuild\rt.bat
|
|
|
|
|
script = os.path.join(ROOT_DIR, r'PCbuild\rt.bat')
|
2018-04-30 13:30:53 -03:00
|
|
|
if not os.path.isfile(script):
|
|
|
|
|
self.skipTest(f'File "{script}" does not exist')
|
2015-09-29 01:02:37 +02:00
|
|
|
rt_args = ["-q"] # Quick, don't run tests twice
|
2019-06-07 10:58:41 -07:00
|
|
|
if platform.machine() == 'ARM64':
|
|
|
|
|
rt_args.append('-arm64') # ARM 64-bit build
|
2019-06-19 13:09:54 -07:00
|
|
|
elif platform.machine() == 'ARM':
|
|
|
|
|
rt_args.append('-arm32') # 32-bit ARM build
|
2019-06-07 10:58:41 -07:00
|
|
|
elif platform.architecture()[0] == '64bit':
|
2015-09-29 01:02:37 +02:00
|
|
|
rt_args.append('-x64') # 64-bit build
|
|
|
|
|
if Py_DEBUG:
|
|
|
|
|
rt_args.append('-d') # Debug build, use python_d.exe
|
|
|
|
|
self.run_batch(script, *rt_args, *self.regrtest_args, *self.tests)
|
2015-09-28 23:16:17 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class ArgsTestCase(BaseTestCase):
|
|
|
|
|
"""
|
|
|
|
|
Test arguments of the Python test suite.
|
|
|
|
|
"""
|
|
|
|
|
|
2016-03-30 02:33:52 +02:00
|
|
|
def run_tests(self, *testargs, **kw):
|
|
|
|
|
cmdargs = ['-m', 'test', '--testdir=%s' % self.tmptestdir, *testargs]
|
|
|
|
|
return self.run_python(cmdargs, **kw)
|
2015-09-30 13:51:17 +02:00
|
|
|
|
|
|
|
|
def test_failing_test(self):
|
|
|
|
|
# test a failing test
|
|
|
|
|
code = textwrap.dedent("""
|
|
|
|
|
import unittest
|
|
|
|
|
|
|
|
|
|
class FailingTest(unittest.TestCase):
|
|
|
|
|
def test_failing(self):
|
|
|
|
|
self.fail("bug")
|
|
|
|
|
""")
|
2016-03-30 02:33:52 +02:00
|
|
|
test_ok = self.create_test('ok')
|
|
|
|
|
test_failing = self.create_test('failing', code=code)
|
2015-09-30 13:51:17 +02:00
|
|
|
tests = [test_ok, test_failing]
|
|
|
|
|
|
[3.11] gh-108822: Backport libregrtest changes from the main branch (#108820)
* Revert "[3.11] gh-101634: regrtest reports decoding error as failed test (#106169) (#106175)"
This reverts commit d5418e97fc524420011a370ba3c2c3cf6a89a74f.
* Revert "[3.11] bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (GH-30895) (GH-103342)"
This reverts commit ecb09a849689764193e0115d27e220f82b5f6d9f.
* Revert "gh-95027: Fix regrtest stdout encoding on Windows (GH-98492)"
This reverts commit b2aa28eec56d07b9c6777b02b7247cf21839de9f.
* Revert "[3.11] gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253) (GH-94408)"
This reverts commit 0122ab235b5acb52dd99fd05d8802a00f438b828.
* Revert "Run Tools/scripts/reindent.py (GH-94225)"
This reverts commit f0f3a424afb00a15ce8c0140dd218f5b33929be6.
* Revert "gh-94052: Don't re-run failed tests with --python option (GH-94054)"
This reverts commit 1347607db12012f6458ffcba48d8ad797083812e.
* Revert "[3.11] gh-84461: Fix Emscripten umask and permission issues (GH-94002) (GH-94006)"
This reverts commit 10731849184a3101ed18683b0128d689f1671c3f.
* gh-93353: regrtest checks for leaked temporary files (#93776)
When running tests with -jN, create a temporary directory per process
and mark a test as "environment changed" if a test leaks a temporary
file or directory.
(cherry picked from commit e566ce5496f1bad81c431aaee65e36d5e44771c5)
* gh-93353: Fix regrtest for -jN with N >= 2 (GH-93813)
(cherry picked from commit 36934a16e86f34d69ba2d41630fb5b4d06d59cff)
* gh-93353: regrtest supports checking tmp files with -j2 (#93909)
regrtest now also implements checking for leaked temporary files and
directories when using -jN for N >= 2. Use tempfile.mkdtemp() to
create the temporary directory. Skip this check on WASI.
(cherry picked from commit 4f85cec9e2077681b3dacc3108e646d509b720bf)
* gh-84461: Fix Emscripten umask and permission issues (GH-94002)
- Emscripten's default umask is too strict, see
https://github.com/emscripten-core/emscripten/issues/17269
- getuid/getgid and geteuid/getegid are stubs that always return 0
(root). Disable effective uid/gid syscalls and fix tests that use
chmod() current user.
- Cannot drop X bit from directory.
(cherry picked from commit 2702e408fd0e0dd7aec396b4cf8c7ce9caae81d8)
* gh-94052: Don't re-run failed tests with --python option (#94054)
(cherry picked from commit 0ff7b996f5d836e63cdaf652c7aa734285261096)
* Run Tools/scripts/reindent.py (#94225)
Reindent files which were not properly formatted (PEP 8: 4 spaces).
Remove also some trailing spaces.
(cherry picked from commit e87ada48a9e5d9d03f9759138869216df0d7383a)
* gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253)
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 199ba233248ab279f445e0809c2077976f0711bc)
* gh-96465: Clear fractions hash lru_cache under refleak testing (GH-96689)
Automerge-Triggered-By: GH:zware
(cherry picked from commit 9c8f3794337457b1d905a9fa0f38c2978fe32abd)
* gh-95027: Fix regrtest stdout encoding on Windows (#98492)
On Windows, when the Python test suite is run with the -jN option,
the ANSI code page is now used as the encoding for the stdout
temporary file, rather than using UTF-8 which can lead to decoding
errors.
(cherry picked from commit ec1f6f5f139868dc2c1116a7c7c878c38c668d53)
* gh-98903: Test suite fails with exit code 4 if no tests ran (#98904)
The Python test suite now fails wit exit code 4 if no tests ran. It
should help detecting typos in test names and test methods.
* Add "EXITCODE_" constants to Lib/test/libregrtest/main.py.
* Fix a typo: "NO TEST RUN" becomes "NO TESTS RAN"
(cherry picked from commit c76db37c0d23174cbffd6fa978d39693890ef020)
* gh-100086: Add build info to test.libregrtest (#100093)
The Python test runner (libregrtest) now logs Python build information like
"debug" vs "release" build, or LTO and PGO optimizations.
(cherry picked from commit 3c892022472eb975360fb3f0caa6f6fcc6fbf220)
* bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (#30895)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
(cherry picked from commit 995386071f96e4cfebfa027a71ca9134e4651d2a)
* gh-82054: allow test runner to split test_asyncio to execute in parallel by sharding. (#103927)
This runs test_asyncio sub-tests in parallel using sharding from Cinder. This suite is typically the longest-pole in runs because it is a test package with a lot of further sub-tests otherwise run serially. By breaking out the sub-tests as independent modules we can run a lot more in parallel.
After porting we can see the direct impact on a multicore system.
Without this change:
Running make test is 5 min 26 seconds
With this change:
Running make test takes 3 min 39 seconds
That'll vary based on system and parallelism. On a `-j 4` run similar to what CI and buildbot systems often do, it reduced the overall test suite completion latency by 10%.
The drawbacks are that this implementation is hacky and due to the sorting of the tests it obscures when the asyncio tests occur and involves changing CPython test infrastructure but, the wall time saved it is worth it, especially in low-core count CI runs as it pulls a long tail. The win for productivity and reserved CI resource usage is significant.
Future tests that deserve to be refactored into split up suites to benefit from are test_concurrent_futures and the way the _test_multiprocessing suite gets run for all start methods. As exposed by passing the -o flag to python -m test to get a list of the 10 longest running tests.
---------
Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google, LLC]
(cherry picked from commit 9e011e7c77dad7d0bbb944c44891531606caeb21)
* Display the sanitizer config in the regrtest header. (#105301)
Display the sanitizers present in libregrtest.
Having this in the CI output for tests with the relevant environment
variable displayed will help make it easier to do what we need to
create an equivalent local test run.
(cherry picked from commit 852348ab65783601e0844b6647ea033668b45c11)
* gh-101634: regrtest reports decoding error as failed test (#106169)
When running the Python test suite with -jN option, if a worker stdout
cannot be decoded from the locale encoding report a failed testn so the
exitcode is non-zero.
(cherry picked from commit 2ac3eec103cf450aaaebeb932e51155d2e7fb37b)
* gh-108223: test.pythoninfo and libregrtest log Py_NOGIL (#108238)
Enable with --disable-gil --without-pydebug:
$ make pythoninfo|grep NOGIL
sysconfig[Py_NOGIL]: 1
$ ./python -m test
...
== Python build: nogil debug
...
(cherry picked from commit 5afe0c17ca14df430736e549542a4b85e7e7c7ac)
* gh-90791: test.pythoninfo logs ASAN_OPTIONS env var (#108289)
* Cleanup libregrtest code logging ASAN_OPTIONS.
* Fix a typo on "ASAN_OPTIONS" vs "MSAN_OPTIONS".
(cherry picked from commit 3a1ac87f8f89d3206b46a0df4908afae629d669d)
* gh-108388: regrtest splits test_asyncio package (#108393)
Currently, test_asyncio package is only splitted into sub-tests when
using command "./python -m test". With this change, it's also
splitted when passing it on the command line:
"./python -m test test_asyncio".
Remove the concept of "STDTESTS". Python is now mature enough to not
have to bother with that anymore. Removing STDTESTS simplify the
code.
(cherry picked from commit 174e9da0836844a2138cc8915dd305cb2cd7a583)
* regrtest computes statistics (#108793)
test_netrc, test_pep646_syntax and test_xml_etree now return results
in the test_main() function.
Changes:
* Rewrite TestResult as a dataclass with a new State class.
* Add test.support.TestStats class and Regrtest.stats_dict attribute.
* libregrtest.runtest functions now modify a TestResult instance
in-place.
* libregrtest summary lists the number of run tests and skipped
tests, and denied resources.
* Add TestResult.has_meaningful_duration() method.
* Compute TestResult duration in the upper function.
* Use time.perf_counter() instead of time.monotonic().
* Regrtest: rename 'resource_denieds' attribute to 'resource_denied'.
* Rename CHILD_ERROR to MULTIPROCESSING_ERROR.
* Use match/case syntadx to have different code depending on the
test state.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit d4e534cbb35678c82b3a1276826af55d7bfc23b6)
* gh-108822: Add Changelog entry for regrtest statistics (#108821)
---------
Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Zachary Ware <zach@python.org>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Joshua Herman <zitterbewegung@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-09-03 19:21:53 +02:00
|
|
|
output = self.run_tests(*tests, exitcode=EXITCODE_BAD_TEST)
|
|
|
|
|
self.check_executed_tests(output, tests, failed=test_failing,
|
|
|
|
|
stats=TestStats(2, 1))
|
2015-09-28 23:16:17 +02:00
|
|
|
|
|
|
|
|
def test_resources(self):
|
|
|
|
|
# test -u command line option
|
|
|
|
|
tests = {}
|
|
|
|
|
for resource in ('audio', 'network'):
|
2018-11-29 17:17:44 +00:00
|
|
|
code = textwrap.dedent("""
|
|
|
|
|
from test import support; support.requires(%r)
|
|
|
|
|
import unittest
|
|
|
|
|
class PassingTest(unittest.TestCase):
|
|
|
|
|
def test_pass(self):
|
|
|
|
|
pass
|
|
|
|
|
""" % resource)
|
|
|
|
|
|
2015-09-28 23:16:17 +02:00
|
|
|
tests[resource] = self.create_test(resource, code)
|
|
|
|
|
test_names = sorted(tests.values())
|
|
|
|
|
|
|
|
|
|
# -u all: 2 resources enabled
|
|
|
|
|
output = self.run_tests('-u', 'all', *test_names)
|
[3.11] gh-108822: Backport libregrtest changes from the main branch (#108820)
* Revert "[3.11] gh-101634: regrtest reports decoding error as failed test (#106169) (#106175)"
This reverts commit d5418e97fc524420011a370ba3c2c3cf6a89a74f.
* Revert "[3.11] bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (GH-30895) (GH-103342)"
This reverts commit ecb09a849689764193e0115d27e220f82b5f6d9f.
* Revert "gh-95027: Fix regrtest stdout encoding on Windows (GH-98492)"
This reverts commit b2aa28eec56d07b9c6777b02b7247cf21839de9f.
* Revert "[3.11] gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253) (GH-94408)"
This reverts commit 0122ab235b5acb52dd99fd05d8802a00f438b828.
* Revert "Run Tools/scripts/reindent.py (GH-94225)"
This reverts commit f0f3a424afb00a15ce8c0140dd218f5b33929be6.
* Revert "gh-94052: Don't re-run failed tests with --python option (GH-94054)"
This reverts commit 1347607db12012f6458ffcba48d8ad797083812e.
* Revert "[3.11] gh-84461: Fix Emscripten umask and permission issues (GH-94002) (GH-94006)"
This reverts commit 10731849184a3101ed18683b0128d689f1671c3f.
* gh-93353: regrtest checks for leaked temporary files (#93776)
When running tests with -jN, create a temporary directory per process
and mark a test as "environment changed" if a test leaks a temporary
file or directory.
(cherry picked from commit e566ce5496f1bad81c431aaee65e36d5e44771c5)
* gh-93353: Fix regrtest for -jN with N >= 2 (GH-93813)
(cherry picked from commit 36934a16e86f34d69ba2d41630fb5b4d06d59cff)
* gh-93353: regrtest supports checking tmp files with -j2 (#93909)
regrtest now also implements checking for leaked temporary files and
directories when using -jN for N >= 2. Use tempfile.mkdtemp() to
create the temporary directory. Skip this check on WASI.
(cherry picked from commit 4f85cec9e2077681b3dacc3108e646d509b720bf)
* gh-84461: Fix Emscripten umask and permission issues (GH-94002)
- Emscripten's default umask is too strict, see
https://github.com/emscripten-core/emscripten/issues/17269
- getuid/getgid and geteuid/getegid are stubs that always return 0
(root). Disable effective uid/gid syscalls and fix tests that use
chmod() current user.
- Cannot drop X bit from directory.
(cherry picked from commit 2702e408fd0e0dd7aec396b4cf8c7ce9caae81d8)
* gh-94052: Don't re-run failed tests with --python option (#94054)
(cherry picked from commit 0ff7b996f5d836e63cdaf652c7aa734285261096)
* Run Tools/scripts/reindent.py (#94225)
Reindent files which were not properly formatted (PEP 8: 4 spaces).
Remove also some trailing spaces.
(cherry picked from commit e87ada48a9e5d9d03f9759138869216df0d7383a)
* gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253)
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 199ba233248ab279f445e0809c2077976f0711bc)
* gh-96465: Clear fractions hash lru_cache under refleak testing (GH-96689)
Automerge-Triggered-By: GH:zware
(cherry picked from commit 9c8f3794337457b1d905a9fa0f38c2978fe32abd)
* gh-95027: Fix regrtest stdout encoding on Windows (#98492)
On Windows, when the Python test suite is run with the -jN option,
the ANSI code page is now used as the encoding for the stdout
temporary file, rather than using UTF-8 which can lead to decoding
errors.
(cherry picked from commit ec1f6f5f139868dc2c1116a7c7c878c38c668d53)
* gh-98903: Test suite fails with exit code 4 if no tests ran (#98904)
The Python test suite now fails wit exit code 4 if no tests ran. It
should help detecting typos in test names and test methods.
* Add "EXITCODE_" constants to Lib/test/libregrtest/main.py.
* Fix a typo: "NO TEST RUN" becomes "NO TESTS RAN"
(cherry picked from commit c76db37c0d23174cbffd6fa978d39693890ef020)
* gh-100086: Add build info to test.libregrtest (#100093)
The Python test runner (libregrtest) now logs Python build information like
"debug" vs "release" build, or LTO and PGO optimizations.
(cherry picked from commit 3c892022472eb975360fb3f0caa6f6fcc6fbf220)
* bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (#30895)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
(cherry picked from commit 995386071f96e4cfebfa027a71ca9134e4651d2a)
* gh-82054: allow test runner to split test_asyncio to execute in parallel by sharding. (#103927)
This runs test_asyncio sub-tests in parallel using sharding from Cinder. This suite is typically the longest-pole in runs because it is a test package with a lot of further sub-tests otherwise run serially. By breaking out the sub-tests as independent modules we can run a lot more in parallel.
After porting we can see the direct impact on a multicore system.
Without this change:
Running make test is 5 min 26 seconds
With this change:
Running make test takes 3 min 39 seconds
That'll vary based on system and parallelism. On a `-j 4` run similar to what CI and buildbot systems often do, it reduced the overall test suite completion latency by 10%.
The drawbacks are that this implementation is hacky and due to the sorting of the tests it obscures when the asyncio tests occur and involves changing CPython test infrastructure but, the wall time saved it is worth it, especially in low-core count CI runs as it pulls a long tail. The win for productivity and reserved CI resource usage is significant.
Future tests that deserve to be refactored into split up suites to benefit from are test_concurrent_futures and the way the _test_multiprocessing suite gets run for all start methods. As exposed by passing the -o flag to python -m test to get a list of the 10 longest running tests.
---------
Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google, LLC]
(cherry picked from commit 9e011e7c77dad7d0bbb944c44891531606caeb21)
* Display the sanitizer config in the regrtest header. (#105301)
Display the sanitizers present in libregrtest.
Having this in the CI output for tests with the relevant environment
variable displayed will help make it easier to do what we need to
create an equivalent local test run.
(cherry picked from commit 852348ab65783601e0844b6647ea033668b45c11)
* gh-101634: regrtest reports decoding error as failed test (#106169)
When running the Python test suite with -jN option, if a worker stdout
cannot be decoded from the locale encoding report a failed testn so the
exitcode is non-zero.
(cherry picked from commit 2ac3eec103cf450aaaebeb932e51155d2e7fb37b)
* gh-108223: test.pythoninfo and libregrtest log Py_NOGIL (#108238)
Enable with --disable-gil --without-pydebug:
$ make pythoninfo|grep NOGIL
sysconfig[Py_NOGIL]: 1
$ ./python -m test
...
== Python build: nogil debug
...
(cherry picked from commit 5afe0c17ca14df430736e549542a4b85e7e7c7ac)
* gh-90791: test.pythoninfo logs ASAN_OPTIONS env var (#108289)
* Cleanup libregrtest code logging ASAN_OPTIONS.
* Fix a typo on "ASAN_OPTIONS" vs "MSAN_OPTIONS".
(cherry picked from commit 3a1ac87f8f89d3206b46a0df4908afae629d669d)
* gh-108388: regrtest splits test_asyncio package (#108393)
Currently, test_asyncio package is only splitted into sub-tests when
using command "./python -m test". With this change, it's also
splitted when passing it on the command line:
"./python -m test test_asyncio".
Remove the concept of "STDTESTS". Python is now mature enough to not
have to bother with that anymore. Removing STDTESTS simplify the
code.
(cherry picked from commit 174e9da0836844a2138cc8915dd305cb2cd7a583)
* regrtest computes statistics (#108793)
test_netrc, test_pep646_syntax and test_xml_etree now return results
in the test_main() function.
Changes:
* Rewrite TestResult as a dataclass with a new State class.
* Add test.support.TestStats class and Regrtest.stats_dict attribute.
* libregrtest.runtest functions now modify a TestResult instance
in-place.
* libregrtest summary lists the number of run tests and skipped
tests, and denied resources.
* Add TestResult.has_meaningful_duration() method.
* Compute TestResult duration in the upper function.
* Use time.perf_counter() instead of time.monotonic().
* Regrtest: rename 'resource_denieds' attribute to 'resource_denied'.
* Rename CHILD_ERROR to MULTIPROCESSING_ERROR.
* Use match/case syntadx to have different code depending on the
test state.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit d4e534cbb35678c82b3a1276826af55d7bfc23b6)
* gh-108822: Add Changelog entry for regrtest statistics (#108821)
---------
Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Zachary Ware <zach@python.org>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Joshua Herman <zitterbewegung@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-09-03 19:21:53 +02:00
|
|
|
self.check_executed_tests(output, test_names, stats=2)
|
2015-09-28 23:16:17 +02:00
|
|
|
|
|
|
|
|
# -u audio: 1 resource enabled
|
|
|
|
|
output = self.run_tests('-uaudio', *test_names)
|
|
|
|
|
self.check_executed_tests(output, test_names,
|
[3.11] gh-108822: Backport libregrtest changes from the main branch (#108820)
* Revert "[3.11] gh-101634: regrtest reports decoding error as failed test (#106169) (#106175)"
This reverts commit d5418e97fc524420011a370ba3c2c3cf6a89a74f.
* Revert "[3.11] bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (GH-30895) (GH-103342)"
This reverts commit ecb09a849689764193e0115d27e220f82b5f6d9f.
* Revert "gh-95027: Fix regrtest stdout encoding on Windows (GH-98492)"
This reverts commit b2aa28eec56d07b9c6777b02b7247cf21839de9f.
* Revert "[3.11] gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253) (GH-94408)"
This reverts commit 0122ab235b5acb52dd99fd05d8802a00f438b828.
* Revert "Run Tools/scripts/reindent.py (GH-94225)"
This reverts commit f0f3a424afb00a15ce8c0140dd218f5b33929be6.
* Revert "gh-94052: Don't re-run failed tests with --python option (GH-94054)"
This reverts commit 1347607db12012f6458ffcba48d8ad797083812e.
* Revert "[3.11] gh-84461: Fix Emscripten umask and permission issues (GH-94002) (GH-94006)"
This reverts commit 10731849184a3101ed18683b0128d689f1671c3f.
* gh-93353: regrtest checks for leaked temporary files (#93776)
When running tests with -jN, create a temporary directory per process
and mark a test as "environment changed" if a test leaks a temporary
file or directory.
(cherry picked from commit e566ce5496f1bad81c431aaee65e36d5e44771c5)
* gh-93353: Fix regrtest for -jN with N >= 2 (GH-93813)
(cherry picked from commit 36934a16e86f34d69ba2d41630fb5b4d06d59cff)
* gh-93353: regrtest supports checking tmp files with -j2 (#93909)
regrtest now also implements checking for leaked temporary files and
directories when using -jN for N >= 2. Use tempfile.mkdtemp() to
create the temporary directory. Skip this check on WASI.
(cherry picked from commit 4f85cec9e2077681b3dacc3108e646d509b720bf)
* gh-84461: Fix Emscripten umask and permission issues (GH-94002)
- Emscripten's default umask is too strict, see
https://github.com/emscripten-core/emscripten/issues/17269
- getuid/getgid and geteuid/getegid are stubs that always return 0
(root). Disable effective uid/gid syscalls and fix tests that use
chmod() current user.
- Cannot drop X bit from directory.
(cherry picked from commit 2702e408fd0e0dd7aec396b4cf8c7ce9caae81d8)
* gh-94052: Don't re-run failed tests with --python option (#94054)
(cherry picked from commit 0ff7b996f5d836e63cdaf652c7aa734285261096)
* Run Tools/scripts/reindent.py (#94225)
Reindent files which were not properly formatted (PEP 8: 4 spaces).
Remove also some trailing spaces.
(cherry picked from commit e87ada48a9e5d9d03f9759138869216df0d7383a)
* gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253)
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 199ba233248ab279f445e0809c2077976f0711bc)
* gh-96465: Clear fractions hash lru_cache under refleak testing (GH-96689)
Automerge-Triggered-By: GH:zware
(cherry picked from commit 9c8f3794337457b1d905a9fa0f38c2978fe32abd)
* gh-95027: Fix regrtest stdout encoding on Windows (#98492)
On Windows, when the Python test suite is run with the -jN option,
the ANSI code page is now used as the encoding for the stdout
temporary file, rather than using UTF-8 which can lead to decoding
errors.
(cherry picked from commit ec1f6f5f139868dc2c1116a7c7c878c38c668d53)
* gh-98903: Test suite fails with exit code 4 if no tests ran (#98904)
The Python test suite now fails wit exit code 4 if no tests ran. It
should help detecting typos in test names and test methods.
* Add "EXITCODE_" constants to Lib/test/libregrtest/main.py.
* Fix a typo: "NO TEST RUN" becomes "NO TESTS RAN"
(cherry picked from commit c76db37c0d23174cbffd6fa978d39693890ef020)
* gh-100086: Add build info to test.libregrtest (#100093)
The Python test runner (libregrtest) now logs Python build information like
"debug" vs "release" build, or LTO and PGO optimizations.
(cherry picked from commit 3c892022472eb975360fb3f0caa6f6fcc6fbf220)
* bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (#30895)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
(cherry picked from commit 995386071f96e4cfebfa027a71ca9134e4651d2a)
* gh-82054: allow test runner to split test_asyncio to execute in parallel by sharding. (#103927)
This runs test_asyncio sub-tests in parallel using sharding from Cinder. This suite is typically the longest-pole in runs because it is a test package with a lot of further sub-tests otherwise run serially. By breaking out the sub-tests as independent modules we can run a lot more in parallel.
After porting we can see the direct impact on a multicore system.
Without this change:
Running make test is 5 min 26 seconds
With this change:
Running make test takes 3 min 39 seconds
That'll vary based on system and parallelism. On a `-j 4` run similar to what CI and buildbot systems often do, it reduced the overall test suite completion latency by 10%.
The drawbacks are that this implementation is hacky and due to the sorting of the tests it obscures when the asyncio tests occur and involves changing CPython test infrastructure but, the wall time saved it is worth it, especially in low-core count CI runs as it pulls a long tail. The win for productivity and reserved CI resource usage is significant.
Future tests that deserve to be refactored into split up suites to benefit from are test_concurrent_futures and the way the _test_multiprocessing suite gets run for all start methods. As exposed by passing the -o flag to python -m test to get a list of the 10 longest running tests.
---------
Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google, LLC]
(cherry picked from commit 9e011e7c77dad7d0bbb944c44891531606caeb21)
* Display the sanitizer config in the regrtest header. (#105301)
Display the sanitizers present in libregrtest.
Having this in the CI output for tests with the relevant environment
variable displayed will help make it easier to do what we need to
create an equivalent local test run.
(cherry picked from commit 852348ab65783601e0844b6647ea033668b45c11)
* gh-101634: regrtest reports decoding error as failed test (#106169)
When running the Python test suite with -jN option, if a worker stdout
cannot be decoded from the locale encoding report a failed testn so the
exitcode is non-zero.
(cherry picked from commit 2ac3eec103cf450aaaebeb932e51155d2e7fb37b)
* gh-108223: test.pythoninfo and libregrtest log Py_NOGIL (#108238)
Enable with --disable-gil --without-pydebug:
$ make pythoninfo|grep NOGIL
sysconfig[Py_NOGIL]: 1
$ ./python -m test
...
== Python build: nogil debug
...
(cherry picked from commit 5afe0c17ca14df430736e549542a4b85e7e7c7ac)
* gh-90791: test.pythoninfo logs ASAN_OPTIONS env var (#108289)
* Cleanup libregrtest code logging ASAN_OPTIONS.
* Fix a typo on "ASAN_OPTIONS" vs "MSAN_OPTIONS".
(cherry picked from commit 3a1ac87f8f89d3206b46a0df4908afae629d669d)
* gh-108388: regrtest splits test_asyncio package (#108393)
Currently, test_asyncio package is only splitted into sub-tests when
using command "./python -m test". With this change, it's also
splitted when passing it on the command line:
"./python -m test test_asyncio".
Remove the concept of "STDTESTS". Python is now mature enough to not
have to bother with that anymore. Removing STDTESTS simplify the
code.
(cherry picked from commit 174e9da0836844a2138cc8915dd305cb2cd7a583)
* regrtest computes statistics (#108793)
test_netrc, test_pep646_syntax and test_xml_etree now return results
in the test_main() function.
Changes:
* Rewrite TestResult as a dataclass with a new State class.
* Add test.support.TestStats class and Regrtest.stats_dict attribute.
* libregrtest.runtest functions now modify a TestResult instance
in-place.
* libregrtest summary lists the number of run tests and skipped
tests, and denied resources.
* Add TestResult.has_meaningful_duration() method.
* Compute TestResult duration in the upper function.
* Use time.perf_counter() instead of time.monotonic().
* Regrtest: rename 'resource_denieds' attribute to 'resource_denied'.
* Rename CHILD_ERROR to MULTIPROCESSING_ERROR.
* Use match/case syntadx to have different code depending on the
test state.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit d4e534cbb35678c82b3a1276826af55d7bfc23b6)
* gh-108822: Add Changelog entry for regrtest statistics (#108821)
---------
Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Zachary Ware <zach@python.org>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Joshua Herman <zitterbewegung@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-09-03 19:21:53 +02:00
|
|
|
skipped=tests['network'],
|
|
|
|
|
resource_denied=tests['network'],
|
|
|
|
|
stats=1)
|
2015-09-28 23:16:17 +02:00
|
|
|
|
|
|
|
|
# no option: 0 resources enabled
|
|
|
|
|
output = self.run_tests(*test_names)
|
|
|
|
|
self.check_executed_tests(output, test_names,
|
[3.11] gh-108822: Backport libregrtest changes from the main branch (#108820)
* Revert "[3.11] gh-101634: regrtest reports decoding error as failed test (#106169) (#106175)"
This reverts commit d5418e97fc524420011a370ba3c2c3cf6a89a74f.
* Revert "[3.11] bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (GH-30895) (GH-103342)"
This reverts commit ecb09a849689764193e0115d27e220f82b5f6d9f.
* Revert "gh-95027: Fix regrtest stdout encoding on Windows (GH-98492)"
This reverts commit b2aa28eec56d07b9c6777b02b7247cf21839de9f.
* Revert "[3.11] gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253) (GH-94408)"
This reverts commit 0122ab235b5acb52dd99fd05d8802a00f438b828.
* Revert "Run Tools/scripts/reindent.py (GH-94225)"
This reverts commit f0f3a424afb00a15ce8c0140dd218f5b33929be6.
* Revert "gh-94052: Don't re-run failed tests with --python option (GH-94054)"
This reverts commit 1347607db12012f6458ffcba48d8ad797083812e.
* Revert "[3.11] gh-84461: Fix Emscripten umask and permission issues (GH-94002) (GH-94006)"
This reverts commit 10731849184a3101ed18683b0128d689f1671c3f.
* gh-93353: regrtest checks for leaked temporary files (#93776)
When running tests with -jN, create a temporary directory per process
and mark a test as "environment changed" if a test leaks a temporary
file or directory.
(cherry picked from commit e566ce5496f1bad81c431aaee65e36d5e44771c5)
* gh-93353: Fix regrtest for -jN with N >= 2 (GH-93813)
(cherry picked from commit 36934a16e86f34d69ba2d41630fb5b4d06d59cff)
* gh-93353: regrtest supports checking tmp files with -j2 (#93909)
regrtest now also implements checking for leaked temporary files and
directories when using -jN for N >= 2. Use tempfile.mkdtemp() to
create the temporary directory. Skip this check on WASI.
(cherry picked from commit 4f85cec9e2077681b3dacc3108e646d509b720bf)
* gh-84461: Fix Emscripten umask and permission issues (GH-94002)
- Emscripten's default umask is too strict, see
https://github.com/emscripten-core/emscripten/issues/17269
- getuid/getgid and geteuid/getegid are stubs that always return 0
(root). Disable effective uid/gid syscalls and fix tests that use
chmod() current user.
- Cannot drop X bit from directory.
(cherry picked from commit 2702e408fd0e0dd7aec396b4cf8c7ce9caae81d8)
* gh-94052: Don't re-run failed tests with --python option (#94054)
(cherry picked from commit 0ff7b996f5d836e63cdaf652c7aa734285261096)
* Run Tools/scripts/reindent.py (#94225)
Reindent files which were not properly formatted (PEP 8: 4 spaces).
Remove also some trailing spaces.
(cherry picked from commit e87ada48a9e5d9d03f9759138869216df0d7383a)
* gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253)
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 199ba233248ab279f445e0809c2077976f0711bc)
* gh-96465: Clear fractions hash lru_cache under refleak testing (GH-96689)
Automerge-Triggered-By: GH:zware
(cherry picked from commit 9c8f3794337457b1d905a9fa0f38c2978fe32abd)
* gh-95027: Fix regrtest stdout encoding on Windows (#98492)
On Windows, when the Python test suite is run with the -jN option,
the ANSI code page is now used as the encoding for the stdout
temporary file, rather than using UTF-8 which can lead to decoding
errors.
(cherry picked from commit ec1f6f5f139868dc2c1116a7c7c878c38c668d53)
* gh-98903: Test suite fails with exit code 4 if no tests ran (#98904)
The Python test suite now fails wit exit code 4 if no tests ran. It
should help detecting typos in test names and test methods.
* Add "EXITCODE_" constants to Lib/test/libregrtest/main.py.
* Fix a typo: "NO TEST RUN" becomes "NO TESTS RAN"
(cherry picked from commit c76db37c0d23174cbffd6fa978d39693890ef020)
* gh-100086: Add build info to test.libregrtest (#100093)
The Python test runner (libregrtest) now logs Python build information like
"debug" vs "release" build, or LTO and PGO optimizations.
(cherry picked from commit 3c892022472eb975360fb3f0caa6f6fcc6fbf220)
* bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (#30895)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
(cherry picked from commit 995386071f96e4cfebfa027a71ca9134e4651d2a)
* gh-82054: allow test runner to split test_asyncio to execute in parallel by sharding. (#103927)
This runs test_asyncio sub-tests in parallel using sharding from Cinder. This suite is typically the longest-pole in runs because it is a test package with a lot of further sub-tests otherwise run serially. By breaking out the sub-tests as independent modules we can run a lot more in parallel.
After porting we can see the direct impact on a multicore system.
Without this change:
Running make test is 5 min 26 seconds
With this change:
Running make test takes 3 min 39 seconds
That'll vary based on system and parallelism. On a `-j 4` run similar to what CI and buildbot systems often do, it reduced the overall test suite completion latency by 10%.
The drawbacks are that this implementation is hacky and due to the sorting of the tests it obscures when the asyncio tests occur and involves changing CPython test infrastructure but, the wall time saved it is worth it, especially in low-core count CI runs as it pulls a long tail. The win for productivity and reserved CI resource usage is significant.
Future tests that deserve to be refactored into split up suites to benefit from are test_concurrent_futures and the way the _test_multiprocessing suite gets run for all start methods. As exposed by passing the -o flag to python -m test to get a list of the 10 longest running tests.
---------
Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google, LLC]
(cherry picked from commit 9e011e7c77dad7d0bbb944c44891531606caeb21)
* Display the sanitizer config in the regrtest header. (#105301)
Display the sanitizers present in libregrtest.
Having this in the CI output for tests with the relevant environment
variable displayed will help make it easier to do what we need to
create an equivalent local test run.
(cherry picked from commit 852348ab65783601e0844b6647ea033668b45c11)
* gh-101634: regrtest reports decoding error as failed test (#106169)
When running the Python test suite with -jN option, if a worker stdout
cannot be decoded from the locale encoding report a failed testn so the
exitcode is non-zero.
(cherry picked from commit 2ac3eec103cf450aaaebeb932e51155d2e7fb37b)
* gh-108223: test.pythoninfo and libregrtest log Py_NOGIL (#108238)
Enable with --disable-gil --without-pydebug:
$ make pythoninfo|grep NOGIL
sysconfig[Py_NOGIL]: 1
$ ./python -m test
...
== Python build: nogil debug
...
(cherry picked from commit 5afe0c17ca14df430736e549542a4b85e7e7c7ac)
* gh-90791: test.pythoninfo logs ASAN_OPTIONS env var (#108289)
* Cleanup libregrtest code logging ASAN_OPTIONS.
* Fix a typo on "ASAN_OPTIONS" vs "MSAN_OPTIONS".
(cherry picked from commit 3a1ac87f8f89d3206b46a0df4908afae629d669d)
* gh-108388: regrtest splits test_asyncio package (#108393)
Currently, test_asyncio package is only splitted into sub-tests when
using command "./python -m test". With this change, it's also
splitted when passing it on the command line:
"./python -m test test_asyncio".
Remove the concept of "STDTESTS". Python is now mature enough to not
have to bother with that anymore. Removing STDTESTS simplify the
code.
(cherry picked from commit 174e9da0836844a2138cc8915dd305cb2cd7a583)
* regrtest computes statistics (#108793)
test_netrc, test_pep646_syntax and test_xml_etree now return results
in the test_main() function.
Changes:
* Rewrite TestResult as a dataclass with a new State class.
* Add test.support.TestStats class and Regrtest.stats_dict attribute.
* libregrtest.runtest functions now modify a TestResult instance
in-place.
* libregrtest summary lists the number of run tests and skipped
tests, and denied resources.
* Add TestResult.has_meaningful_duration() method.
* Compute TestResult duration in the upper function.
* Use time.perf_counter() instead of time.monotonic().
* Regrtest: rename 'resource_denieds' attribute to 'resource_denied'.
* Rename CHILD_ERROR to MULTIPROCESSING_ERROR.
* Use match/case syntadx to have different code depending on the
test state.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit d4e534cbb35678c82b3a1276826af55d7bfc23b6)
* gh-108822: Add Changelog entry for regrtest statistics (#108821)
---------
Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Zachary Ware <zach@python.org>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Joshua Herman <zitterbewegung@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-09-03 19:21:53 +02:00
|
|
|
skipped=test_names,
|
|
|
|
|
resource_denied=test_names,
|
|
|
|
|
stats=0)
|
2015-09-28 23:16:17 +02:00
|
|
|
|
|
|
|
|
def test_random(self):
|
|
|
|
|
# test -r and --randseed command line option
|
|
|
|
|
code = textwrap.dedent("""
|
|
|
|
|
import random
|
|
|
|
|
print("TESTRANDOM: %s" % random.randint(1, 1000))
|
|
|
|
|
""")
|
|
|
|
|
test = self.create_test('random', code)
|
|
|
|
|
|
|
|
|
|
# first run to get the output with the random seed
|
[3.11] gh-108822: Backport libregrtest changes from the main branch (#108820)
* Revert "[3.11] gh-101634: regrtest reports decoding error as failed test (#106169) (#106175)"
This reverts commit d5418e97fc524420011a370ba3c2c3cf6a89a74f.
* Revert "[3.11] bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (GH-30895) (GH-103342)"
This reverts commit ecb09a849689764193e0115d27e220f82b5f6d9f.
* Revert "gh-95027: Fix regrtest stdout encoding on Windows (GH-98492)"
This reverts commit b2aa28eec56d07b9c6777b02b7247cf21839de9f.
* Revert "[3.11] gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253) (GH-94408)"
This reverts commit 0122ab235b5acb52dd99fd05d8802a00f438b828.
* Revert "Run Tools/scripts/reindent.py (GH-94225)"
This reverts commit f0f3a424afb00a15ce8c0140dd218f5b33929be6.
* Revert "gh-94052: Don't re-run failed tests with --python option (GH-94054)"
This reverts commit 1347607db12012f6458ffcba48d8ad797083812e.
* Revert "[3.11] gh-84461: Fix Emscripten umask and permission issues (GH-94002) (GH-94006)"
This reverts commit 10731849184a3101ed18683b0128d689f1671c3f.
* gh-93353: regrtest checks for leaked temporary files (#93776)
When running tests with -jN, create a temporary directory per process
and mark a test as "environment changed" if a test leaks a temporary
file or directory.
(cherry picked from commit e566ce5496f1bad81c431aaee65e36d5e44771c5)
* gh-93353: Fix regrtest for -jN with N >= 2 (GH-93813)
(cherry picked from commit 36934a16e86f34d69ba2d41630fb5b4d06d59cff)
* gh-93353: regrtest supports checking tmp files with -j2 (#93909)
regrtest now also implements checking for leaked temporary files and
directories when using -jN for N >= 2. Use tempfile.mkdtemp() to
create the temporary directory. Skip this check on WASI.
(cherry picked from commit 4f85cec9e2077681b3dacc3108e646d509b720bf)
* gh-84461: Fix Emscripten umask and permission issues (GH-94002)
- Emscripten's default umask is too strict, see
https://github.com/emscripten-core/emscripten/issues/17269
- getuid/getgid and geteuid/getegid are stubs that always return 0
(root). Disable effective uid/gid syscalls and fix tests that use
chmod() current user.
- Cannot drop X bit from directory.
(cherry picked from commit 2702e408fd0e0dd7aec396b4cf8c7ce9caae81d8)
* gh-94052: Don't re-run failed tests with --python option (#94054)
(cherry picked from commit 0ff7b996f5d836e63cdaf652c7aa734285261096)
* Run Tools/scripts/reindent.py (#94225)
Reindent files which were not properly formatted (PEP 8: 4 spaces).
Remove also some trailing spaces.
(cherry picked from commit e87ada48a9e5d9d03f9759138869216df0d7383a)
* gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253)
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 199ba233248ab279f445e0809c2077976f0711bc)
* gh-96465: Clear fractions hash lru_cache under refleak testing (GH-96689)
Automerge-Triggered-By: GH:zware
(cherry picked from commit 9c8f3794337457b1d905a9fa0f38c2978fe32abd)
* gh-95027: Fix regrtest stdout encoding on Windows (#98492)
On Windows, when the Python test suite is run with the -jN option,
the ANSI code page is now used as the encoding for the stdout
temporary file, rather than using UTF-8 which can lead to decoding
errors.
(cherry picked from commit ec1f6f5f139868dc2c1116a7c7c878c38c668d53)
* gh-98903: Test suite fails with exit code 4 if no tests ran (#98904)
The Python test suite now fails wit exit code 4 if no tests ran. It
should help detecting typos in test names and test methods.
* Add "EXITCODE_" constants to Lib/test/libregrtest/main.py.
* Fix a typo: "NO TEST RUN" becomes "NO TESTS RAN"
(cherry picked from commit c76db37c0d23174cbffd6fa978d39693890ef020)
* gh-100086: Add build info to test.libregrtest (#100093)
The Python test runner (libregrtest) now logs Python build information like
"debug" vs "release" build, or LTO and PGO optimizations.
(cherry picked from commit 3c892022472eb975360fb3f0caa6f6fcc6fbf220)
* bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (#30895)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
(cherry picked from commit 995386071f96e4cfebfa027a71ca9134e4651d2a)
* gh-82054: allow test runner to split test_asyncio to execute in parallel by sharding. (#103927)
This runs test_asyncio sub-tests in parallel using sharding from Cinder. This suite is typically the longest-pole in runs because it is a test package with a lot of further sub-tests otherwise run serially. By breaking out the sub-tests as independent modules we can run a lot more in parallel.
After porting we can see the direct impact on a multicore system.
Without this change:
Running make test is 5 min 26 seconds
With this change:
Running make test takes 3 min 39 seconds
That'll vary based on system and parallelism. On a `-j 4` run similar to what CI and buildbot systems often do, it reduced the overall test suite completion latency by 10%.
The drawbacks are that this implementation is hacky and due to the sorting of the tests it obscures when the asyncio tests occur and involves changing CPython test infrastructure but, the wall time saved it is worth it, especially in low-core count CI runs as it pulls a long tail. The win for productivity and reserved CI resource usage is significant.
Future tests that deserve to be refactored into split up suites to benefit from are test_concurrent_futures and the way the _test_multiprocessing suite gets run for all start methods. As exposed by passing the -o flag to python -m test to get a list of the 10 longest running tests.
---------
Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google, LLC]
(cherry picked from commit 9e011e7c77dad7d0bbb944c44891531606caeb21)
* Display the sanitizer config in the regrtest header. (#105301)
Display the sanitizers present in libregrtest.
Having this in the CI output for tests with the relevant environment
variable displayed will help make it easier to do what we need to
create an equivalent local test run.
(cherry picked from commit 852348ab65783601e0844b6647ea033668b45c11)
* gh-101634: regrtest reports decoding error as failed test (#106169)
When running the Python test suite with -jN option, if a worker stdout
cannot be decoded from the locale encoding report a failed testn so the
exitcode is non-zero.
(cherry picked from commit 2ac3eec103cf450aaaebeb932e51155d2e7fb37b)
* gh-108223: test.pythoninfo and libregrtest log Py_NOGIL (#108238)
Enable with --disable-gil --without-pydebug:
$ make pythoninfo|grep NOGIL
sysconfig[Py_NOGIL]: 1
$ ./python -m test
...
== Python build: nogil debug
...
(cherry picked from commit 5afe0c17ca14df430736e549542a4b85e7e7c7ac)
* gh-90791: test.pythoninfo logs ASAN_OPTIONS env var (#108289)
* Cleanup libregrtest code logging ASAN_OPTIONS.
* Fix a typo on "ASAN_OPTIONS" vs "MSAN_OPTIONS".
(cherry picked from commit 3a1ac87f8f89d3206b46a0df4908afae629d669d)
* gh-108388: regrtest splits test_asyncio package (#108393)
Currently, test_asyncio package is only splitted into sub-tests when
using command "./python -m test". With this change, it's also
splitted when passing it on the command line:
"./python -m test test_asyncio".
Remove the concept of "STDTESTS". Python is now mature enough to not
have to bother with that anymore. Removing STDTESTS simplify the
code.
(cherry picked from commit 174e9da0836844a2138cc8915dd305cb2cd7a583)
* regrtest computes statistics (#108793)
test_netrc, test_pep646_syntax and test_xml_etree now return results
in the test_main() function.
Changes:
* Rewrite TestResult as a dataclass with a new State class.
* Add test.support.TestStats class and Regrtest.stats_dict attribute.
* libregrtest.runtest functions now modify a TestResult instance
in-place.
* libregrtest summary lists the number of run tests and skipped
tests, and denied resources.
* Add TestResult.has_meaningful_duration() method.
* Compute TestResult duration in the upper function.
* Use time.perf_counter() instead of time.monotonic().
* Regrtest: rename 'resource_denieds' attribute to 'resource_denied'.
* Rename CHILD_ERROR to MULTIPROCESSING_ERROR.
* Use match/case syntadx to have different code depending on the
test state.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit d4e534cbb35678c82b3a1276826af55d7bfc23b6)
* gh-108822: Add Changelog entry for regrtest statistics (#108821)
---------
Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Zachary Ware <zach@python.org>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Joshua Herman <zitterbewegung@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-09-03 19:21:53 +02:00
|
|
|
output = self.run_tests('-r', test, exitcode=EXITCODE_NO_TESTS_RAN)
|
2015-09-28 23:16:17 +02:00
|
|
|
randseed = self.parse_random_seed(output)
|
|
|
|
|
match = self.regex_search(r'TESTRANDOM: ([0-9]+)', output)
|
|
|
|
|
test_random = int(match.group(1))
|
|
|
|
|
|
|
|
|
|
# try to reproduce with the random seed
|
[3.11] gh-108822: Backport libregrtest changes from the main branch (#108820)
* Revert "[3.11] gh-101634: regrtest reports decoding error as failed test (#106169) (#106175)"
This reverts commit d5418e97fc524420011a370ba3c2c3cf6a89a74f.
* Revert "[3.11] bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (GH-30895) (GH-103342)"
This reverts commit ecb09a849689764193e0115d27e220f82b5f6d9f.
* Revert "gh-95027: Fix regrtest stdout encoding on Windows (GH-98492)"
This reverts commit b2aa28eec56d07b9c6777b02b7247cf21839de9f.
* Revert "[3.11] gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253) (GH-94408)"
This reverts commit 0122ab235b5acb52dd99fd05d8802a00f438b828.
* Revert "Run Tools/scripts/reindent.py (GH-94225)"
This reverts commit f0f3a424afb00a15ce8c0140dd218f5b33929be6.
* Revert "gh-94052: Don't re-run failed tests with --python option (GH-94054)"
This reverts commit 1347607db12012f6458ffcba48d8ad797083812e.
* Revert "[3.11] gh-84461: Fix Emscripten umask and permission issues (GH-94002) (GH-94006)"
This reverts commit 10731849184a3101ed18683b0128d689f1671c3f.
* gh-93353: regrtest checks for leaked temporary files (#93776)
When running tests with -jN, create a temporary directory per process
and mark a test as "environment changed" if a test leaks a temporary
file or directory.
(cherry picked from commit e566ce5496f1bad81c431aaee65e36d5e44771c5)
* gh-93353: Fix regrtest for -jN with N >= 2 (GH-93813)
(cherry picked from commit 36934a16e86f34d69ba2d41630fb5b4d06d59cff)
* gh-93353: regrtest supports checking tmp files with -j2 (#93909)
regrtest now also implements checking for leaked temporary files and
directories when using -jN for N >= 2. Use tempfile.mkdtemp() to
create the temporary directory. Skip this check on WASI.
(cherry picked from commit 4f85cec9e2077681b3dacc3108e646d509b720bf)
* gh-84461: Fix Emscripten umask and permission issues (GH-94002)
- Emscripten's default umask is too strict, see
https://github.com/emscripten-core/emscripten/issues/17269
- getuid/getgid and geteuid/getegid are stubs that always return 0
(root). Disable effective uid/gid syscalls and fix tests that use
chmod() current user.
- Cannot drop X bit from directory.
(cherry picked from commit 2702e408fd0e0dd7aec396b4cf8c7ce9caae81d8)
* gh-94052: Don't re-run failed tests with --python option (#94054)
(cherry picked from commit 0ff7b996f5d836e63cdaf652c7aa734285261096)
* Run Tools/scripts/reindent.py (#94225)
Reindent files which were not properly formatted (PEP 8: 4 spaces).
Remove also some trailing spaces.
(cherry picked from commit e87ada48a9e5d9d03f9759138869216df0d7383a)
* gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253)
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 199ba233248ab279f445e0809c2077976f0711bc)
* gh-96465: Clear fractions hash lru_cache under refleak testing (GH-96689)
Automerge-Triggered-By: GH:zware
(cherry picked from commit 9c8f3794337457b1d905a9fa0f38c2978fe32abd)
* gh-95027: Fix regrtest stdout encoding on Windows (#98492)
On Windows, when the Python test suite is run with the -jN option,
the ANSI code page is now used as the encoding for the stdout
temporary file, rather than using UTF-8 which can lead to decoding
errors.
(cherry picked from commit ec1f6f5f139868dc2c1116a7c7c878c38c668d53)
* gh-98903: Test suite fails with exit code 4 if no tests ran (#98904)
The Python test suite now fails wit exit code 4 if no tests ran. It
should help detecting typos in test names and test methods.
* Add "EXITCODE_" constants to Lib/test/libregrtest/main.py.
* Fix a typo: "NO TEST RUN" becomes "NO TESTS RAN"
(cherry picked from commit c76db37c0d23174cbffd6fa978d39693890ef020)
* gh-100086: Add build info to test.libregrtest (#100093)
The Python test runner (libregrtest) now logs Python build information like
"debug" vs "release" build, or LTO and PGO optimizations.
(cherry picked from commit 3c892022472eb975360fb3f0caa6f6fcc6fbf220)
* bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (#30895)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
(cherry picked from commit 995386071f96e4cfebfa027a71ca9134e4651d2a)
* gh-82054: allow test runner to split test_asyncio to execute in parallel by sharding. (#103927)
This runs test_asyncio sub-tests in parallel using sharding from Cinder. This suite is typically the longest-pole in runs because it is a test package with a lot of further sub-tests otherwise run serially. By breaking out the sub-tests as independent modules we can run a lot more in parallel.
After porting we can see the direct impact on a multicore system.
Without this change:
Running make test is 5 min 26 seconds
With this change:
Running make test takes 3 min 39 seconds
That'll vary based on system and parallelism. On a `-j 4` run similar to what CI and buildbot systems often do, it reduced the overall test suite completion latency by 10%.
The drawbacks are that this implementation is hacky and due to the sorting of the tests it obscures when the asyncio tests occur and involves changing CPython test infrastructure but, the wall time saved it is worth it, especially in low-core count CI runs as it pulls a long tail. The win for productivity and reserved CI resource usage is significant.
Future tests that deserve to be refactored into split up suites to benefit from are test_concurrent_futures and the way the _test_multiprocessing suite gets run for all start methods. As exposed by passing the -o flag to python -m test to get a list of the 10 longest running tests.
---------
Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google, LLC]
(cherry picked from commit 9e011e7c77dad7d0bbb944c44891531606caeb21)
* Display the sanitizer config in the regrtest header. (#105301)
Display the sanitizers present in libregrtest.
Having this in the CI output for tests with the relevant environment
variable displayed will help make it easier to do what we need to
create an equivalent local test run.
(cherry picked from commit 852348ab65783601e0844b6647ea033668b45c11)
* gh-101634: regrtest reports decoding error as failed test (#106169)
When running the Python test suite with -jN option, if a worker stdout
cannot be decoded from the locale encoding report a failed testn so the
exitcode is non-zero.
(cherry picked from commit 2ac3eec103cf450aaaebeb932e51155d2e7fb37b)
* gh-108223: test.pythoninfo and libregrtest log Py_NOGIL (#108238)
Enable with --disable-gil --without-pydebug:
$ make pythoninfo|grep NOGIL
sysconfig[Py_NOGIL]: 1
$ ./python -m test
...
== Python build: nogil debug
...
(cherry picked from commit 5afe0c17ca14df430736e549542a4b85e7e7c7ac)
* gh-90791: test.pythoninfo logs ASAN_OPTIONS env var (#108289)
* Cleanup libregrtest code logging ASAN_OPTIONS.
* Fix a typo on "ASAN_OPTIONS" vs "MSAN_OPTIONS".
(cherry picked from commit 3a1ac87f8f89d3206b46a0df4908afae629d669d)
* gh-108388: regrtest splits test_asyncio package (#108393)
Currently, test_asyncio package is only splitted into sub-tests when
using command "./python -m test". With this change, it's also
splitted when passing it on the command line:
"./python -m test test_asyncio".
Remove the concept of "STDTESTS". Python is now mature enough to not
have to bother with that anymore. Removing STDTESTS simplify the
code.
(cherry picked from commit 174e9da0836844a2138cc8915dd305cb2cd7a583)
* regrtest computes statistics (#108793)
test_netrc, test_pep646_syntax and test_xml_etree now return results
in the test_main() function.
Changes:
* Rewrite TestResult as a dataclass with a new State class.
* Add test.support.TestStats class and Regrtest.stats_dict attribute.
* libregrtest.runtest functions now modify a TestResult instance
in-place.
* libregrtest summary lists the number of run tests and skipped
tests, and denied resources.
* Add TestResult.has_meaningful_duration() method.
* Compute TestResult duration in the upper function.
* Use time.perf_counter() instead of time.monotonic().
* Regrtest: rename 'resource_denieds' attribute to 'resource_denied'.
* Rename CHILD_ERROR to MULTIPROCESSING_ERROR.
* Use match/case syntadx to have different code depending on the
test state.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit d4e534cbb35678c82b3a1276826af55d7bfc23b6)
* gh-108822: Add Changelog entry for regrtest statistics (#108821)
---------
Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Zachary Ware <zach@python.org>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Joshua Herman <zitterbewegung@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-09-03 19:21:53 +02:00
|
|
|
output = self.run_tests('-r', '--randseed=%s' % randseed, test,
|
|
|
|
|
exitcode=EXITCODE_NO_TESTS_RAN)
|
2015-09-28 23:16:17 +02:00
|
|
|
randseed2 = self.parse_random_seed(output)
|
|
|
|
|
self.assertEqual(randseed2, randseed)
|
|
|
|
|
|
|
|
|
|
match = self.regex_search(r'TESTRANDOM: ([0-9]+)', output)
|
|
|
|
|
test_random2 = int(match.group(1))
|
|
|
|
|
self.assertEqual(test_random2, test_random)
|
|
|
|
|
|
|
|
|
|
def test_fromfile(self):
|
|
|
|
|
# test --fromfile
|
|
|
|
|
tests = [self.create_test() for index in range(5)]
|
|
|
|
|
|
|
|
|
|
# Write the list of files using a format similar to regrtest output:
|
|
|
|
|
# [1/2] test_1
|
|
|
|
|
# [2/2] test_2
|
2020-06-30 21:46:06 +08:00
|
|
|
filename = os_helper.TESTFN
|
|
|
|
|
self.addCleanup(os_helper.unlink, filename)
|
2016-03-24 09:43:00 +01:00
|
|
|
|
|
|
|
|
# test format '0:00:00 [2/7] test_opcodes -- test_grammar took 0 sec'
|
|
|
|
|
with open(filename, "w") as fp:
|
|
|
|
|
previous = None
|
|
|
|
|
for index, name in enumerate(tests, 1):
|
|
|
|
|
line = ("00:00:%02i [%s/%s] %s"
|
|
|
|
|
% (index, index, len(tests), name))
|
|
|
|
|
if previous:
|
|
|
|
|
line += " -- %s took 0 sec" % previous
|
|
|
|
|
print(line, file=fp)
|
|
|
|
|
previous = name
|
|
|
|
|
|
|
|
|
|
output = self.run_tests('--fromfile', filename)
|
[3.11] gh-108822: Backport libregrtest changes from the main branch (#108820)
* Revert "[3.11] gh-101634: regrtest reports decoding error as failed test (#106169) (#106175)"
This reverts commit d5418e97fc524420011a370ba3c2c3cf6a89a74f.
* Revert "[3.11] bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (GH-30895) (GH-103342)"
This reverts commit ecb09a849689764193e0115d27e220f82b5f6d9f.
* Revert "gh-95027: Fix regrtest stdout encoding on Windows (GH-98492)"
This reverts commit b2aa28eec56d07b9c6777b02b7247cf21839de9f.
* Revert "[3.11] gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253) (GH-94408)"
This reverts commit 0122ab235b5acb52dd99fd05d8802a00f438b828.
* Revert "Run Tools/scripts/reindent.py (GH-94225)"
This reverts commit f0f3a424afb00a15ce8c0140dd218f5b33929be6.
* Revert "gh-94052: Don't re-run failed tests with --python option (GH-94054)"
This reverts commit 1347607db12012f6458ffcba48d8ad797083812e.
* Revert "[3.11] gh-84461: Fix Emscripten umask and permission issues (GH-94002) (GH-94006)"
This reverts commit 10731849184a3101ed18683b0128d689f1671c3f.
* gh-93353: regrtest checks for leaked temporary files (#93776)
When running tests with -jN, create a temporary directory per process
and mark a test as "environment changed" if a test leaks a temporary
file or directory.
(cherry picked from commit e566ce5496f1bad81c431aaee65e36d5e44771c5)
* gh-93353: Fix regrtest for -jN with N >= 2 (GH-93813)
(cherry picked from commit 36934a16e86f34d69ba2d41630fb5b4d06d59cff)
* gh-93353: regrtest supports checking tmp files with -j2 (#93909)
regrtest now also implements checking for leaked temporary files and
directories when using -jN for N >= 2. Use tempfile.mkdtemp() to
create the temporary directory. Skip this check on WASI.
(cherry picked from commit 4f85cec9e2077681b3dacc3108e646d509b720bf)
* gh-84461: Fix Emscripten umask and permission issues (GH-94002)
- Emscripten's default umask is too strict, see
https://github.com/emscripten-core/emscripten/issues/17269
- getuid/getgid and geteuid/getegid are stubs that always return 0
(root). Disable effective uid/gid syscalls and fix tests that use
chmod() current user.
- Cannot drop X bit from directory.
(cherry picked from commit 2702e408fd0e0dd7aec396b4cf8c7ce9caae81d8)
* gh-94052: Don't re-run failed tests with --python option (#94054)
(cherry picked from commit 0ff7b996f5d836e63cdaf652c7aa734285261096)
* Run Tools/scripts/reindent.py (#94225)
Reindent files which were not properly formatted (PEP 8: 4 spaces).
Remove also some trailing spaces.
(cherry picked from commit e87ada48a9e5d9d03f9759138869216df0d7383a)
* gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253)
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 199ba233248ab279f445e0809c2077976f0711bc)
* gh-96465: Clear fractions hash lru_cache under refleak testing (GH-96689)
Automerge-Triggered-By: GH:zware
(cherry picked from commit 9c8f3794337457b1d905a9fa0f38c2978fe32abd)
* gh-95027: Fix regrtest stdout encoding on Windows (#98492)
On Windows, when the Python test suite is run with the -jN option,
the ANSI code page is now used as the encoding for the stdout
temporary file, rather than using UTF-8 which can lead to decoding
errors.
(cherry picked from commit ec1f6f5f139868dc2c1116a7c7c878c38c668d53)
* gh-98903: Test suite fails with exit code 4 if no tests ran (#98904)
The Python test suite now fails wit exit code 4 if no tests ran. It
should help detecting typos in test names and test methods.
* Add "EXITCODE_" constants to Lib/test/libregrtest/main.py.
* Fix a typo: "NO TEST RUN" becomes "NO TESTS RAN"
(cherry picked from commit c76db37c0d23174cbffd6fa978d39693890ef020)
* gh-100086: Add build info to test.libregrtest (#100093)
The Python test runner (libregrtest) now logs Python build information like
"debug" vs "release" build, or LTO and PGO optimizations.
(cherry picked from commit 3c892022472eb975360fb3f0caa6f6fcc6fbf220)
* bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (#30895)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
(cherry picked from commit 995386071f96e4cfebfa027a71ca9134e4651d2a)
* gh-82054: allow test runner to split test_asyncio to execute in parallel by sharding. (#103927)
This runs test_asyncio sub-tests in parallel using sharding from Cinder. This suite is typically the longest-pole in runs because it is a test package with a lot of further sub-tests otherwise run serially. By breaking out the sub-tests as independent modules we can run a lot more in parallel.
After porting we can see the direct impact on a multicore system.
Without this change:
Running make test is 5 min 26 seconds
With this change:
Running make test takes 3 min 39 seconds
That'll vary based on system and parallelism. On a `-j 4` run similar to what CI and buildbot systems often do, it reduced the overall test suite completion latency by 10%.
The drawbacks are that this implementation is hacky and due to the sorting of the tests it obscures when the asyncio tests occur and involves changing CPython test infrastructure but, the wall time saved it is worth it, especially in low-core count CI runs as it pulls a long tail. The win for productivity and reserved CI resource usage is significant.
Future tests that deserve to be refactored into split up suites to benefit from are test_concurrent_futures and the way the _test_multiprocessing suite gets run for all start methods. As exposed by passing the -o flag to python -m test to get a list of the 10 longest running tests.
---------
Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google, LLC]
(cherry picked from commit 9e011e7c77dad7d0bbb944c44891531606caeb21)
* Display the sanitizer config in the regrtest header. (#105301)
Display the sanitizers present in libregrtest.
Having this in the CI output for tests with the relevant environment
variable displayed will help make it easier to do what we need to
create an equivalent local test run.
(cherry picked from commit 852348ab65783601e0844b6647ea033668b45c11)
* gh-101634: regrtest reports decoding error as failed test (#106169)
When running the Python test suite with -jN option, if a worker stdout
cannot be decoded from the locale encoding report a failed testn so the
exitcode is non-zero.
(cherry picked from commit 2ac3eec103cf450aaaebeb932e51155d2e7fb37b)
* gh-108223: test.pythoninfo and libregrtest log Py_NOGIL (#108238)
Enable with --disable-gil --without-pydebug:
$ make pythoninfo|grep NOGIL
sysconfig[Py_NOGIL]: 1
$ ./python -m test
...
== Python build: nogil debug
...
(cherry picked from commit 5afe0c17ca14df430736e549542a4b85e7e7c7ac)
* gh-90791: test.pythoninfo logs ASAN_OPTIONS env var (#108289)
* Cleanup libregrtest code logging ASAN_OPTIONS.
* Fix a typo on "ASAN_OPTIONS" vs "MSAN_OPTIONS".
(cherry picked from commit 3a1ac87f8f89d3206b46a0df4908afae629d669d)
* gh-108388: regrtest splits test_asyncio package (#108393)
Currently, test_asyncio package is only splitted into sub-tests when
using command "./python -m test". With this change, it's also
splitted when passing it on the command line:
"./python -m test test_asyncio".
Remove the concept of "STDTESTS". Python is now mature enough to not
have to bother with that anymore. Removing STDTESTS simplify the
code.
(cherry picked from commit 174e9da0836844a2138cc8915dd305cb2cd7a583)
* regrtest computes statistics (#108793)
test_netrc, test_pep646_syntax and test_xml_etree now return results
in the test_main() function.
Changes:
* Rewrite TestResult as a dataclass with a new State class.
* Add test.support.TestStats class and Regrtest.stats_dict attribute.
* libregrtest.runtest functions now modify a TestResult instance
in-place.
* libregrtest summary lists the number of run tests and skipped
tests, and denied resources.
* Add TestResult.has_meaningful_duration() method.
* Compute TestResult duration in the upper function.
* Use time.perf_counter() instead of time.monotonic().
* Regrtest: rename 'resource_denieds' attribute to 'resource_denied'.
* Rename CHILD_ERROR to MULTIPROCESSING_ERROR.
* Use match/case syntadx to have different code depending on the
test state.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit d4e534cbb35678c82b3a1276826af55d7bfc23b6)
* gh-108822: Add Changelog entry for regrtest statistics (#108821)
---------
Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Zachary Ware <zach@python.org>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Joshua Herman <zitterbewegung@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-09-03 19:21:53 +02:00
|
|
|
stats = len(tests)
|
|
|
|
|
self.check_executed_tests(output, tests, stats=stats)
|
2016-03-24 09:43:00 +01:00
|
|
|
|
|
|
|
|
# test format '[2/7] test_opcodes'
|
2015-09-28 23:16:17 +02:00
|
|
|
with open(filename, "w") as fp:
|
|
|
|
|
for index, name in enumerate(tests, 1):
|
|
|
|
|
print("[%s/%s] %s" % (index, len(tests), name), file=fp)
|
|
|
|
|
|
|
|
|
|
output = self.run_tests('--fromfile', filename)
|
[3.11] gh-108822: Backport libregrtest changes from the main branch (#108820)
* Revert "[3.11] gh-101634: regrtest reports decoding error as failed test (#106169) (#106175)"
This reverts commit d5418e97fc524420011a370ba3c2c3cf6a89a74f.
* Revert "[3.11] bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (GH-30895) (GH-103342)"
This reverts commit ecb09a849689764193e0115d27e220f82b5f6d9f.
* Revert "gh-95027: Fix regrtest stdout encoding on Windows (GH-98492)"
This reverts commit b2aa28eec56d07b9c6777b02b7247cf21839de9f.
* Revert "[3.11] gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253) (GH-94408)"
This reverts commit 0122ab235b5acb52dd99fd05d8802a00f438b828.
* Revert "Run Tools/scripts/reindent.py (GH-94225)"
This reverts commit f0f3a424afb00a15ce8c0140dd218f5b33929be6.
* Revert "gh-94052: Don't re-run failed tests with --python option (GH-94054)"
This reverts commit 1347607db12012f6458ffcba48d8ad797083812e.
* Revert "[3.11] gh-84461: Fix Emscripten umask and permission issues (GH-94002) (GH-94006)"
This reverts commit 10731849184a3101ed18683b0128d689f1671c3f.
* gh-93353: regrtest checks for leaked temporary files (#93776)
When running tests with -jN, create a temporary directory per process
and mark a test as "environment changed" if a test leaks a temporary
file or directory.
(cherry picked from commit e566ce5496f1bad81c431aaee65e36d5e44771c5)
* gh-93353: Fix regrtest for -jN with N >= 2 (GH-93813)
(cherry picked from commit 36934a16e86f34d69ba2d41630fb5b4d06d59cff)
* gh-93353: regrtest supports checking tmp files with -j2 (#93909)
regrtest now also implements checking for leaked temporary files and
directories when using -jN for N >= 2. Use tempfile.mkdtemp() to
create the temporary directory. Skip this check on WASI.
(cherry picked from commit 4f85cec9e2077681b3dacc3108e646d509b720bf)
* gh-84461: Fix Emscripten umask and permission issues (GH-94002)
- Emscripten's default umask is too strict, see
https://github.com/emscripten-core/emscripten/issues/17269
- getuid/getgid and geteuid/getegid are stubs that always return 0
(root). Disable effective uid/gid syscalls and fix tests that use
chmod() current user.
- Cannot drop X bit from directory.
(cherry picked from commit 2702e408fd0e0dd7aec396b4cf8c7ce9caae81d8)
* gh-94052: Don't re-run failed tests with --python option (#94054)
(cherry picked from commit 0ff7b996f5d836e63cdaf652c7aa734285261096)
* Run Tools/scripts/reindent.py (#94225)
Reindent files which were not properly formatted (PEP 8: 4 spaces).
Remove also some trailing spaces.
(cherry picked from commit e87ada48a9e5d9d03f9759138869216df0d7383a)
* gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253)
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 199ba233248ab279f445e0809c2077976f0711bc)
* gh-96465: Clear fractions hash lru_cache under refleak testing (GH-96689)
Automerge-Triggered-By: GH:zware
(cherry picked from commit 9c8f3794337457b1d905a9fa0f38c2978fe32abd)
* gh-95027: Fix regrtest stdout encoding on Windows (#98492)
On Windows, when the Python test suite is run with the -jN option,
the ANSI code page is now used as the encoding for the stdout
temporary file, rather than using UTF-8 which can lead to decoding
errors.
(cherry picked from commit ec1f6f5f139868dc2c1116a7c7c878c38c668d53)
* gh-98903: Test suite fails with exit code 4 if no tests ran (#98904)
The Python test suite now fails wit exit code 4 if no tests ran. It
should help detecting typos in test names and test methods.
* Add "EXITCODE_" constants to Lib/test/libregrtest/main.py.
* Fix a typo: "NO TEST RUN" becomes "NO TESTS RAN"
(cherry picked from commit c76db37c0d23174cbffd6fa978d39693890ef020)
* gh-100086: Add build info to test.libregrtest (#100093)
The Python test runner (libregrtest) now logs Python build information like
"debug" vs "release" build, or LTO and PGO optimizations.
(cherry picked from commit 3c892022472eb975360fb3f0caa6f6fcc6fbf220)
* bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (#30895)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
(cherry picked from commit 995386071f96e4cfebfa027a71ca9134e4651d2a)
* gh-82054: allow test runner to split test_asyncio to execute in parallel by sharding. (#103927)
This runs test_asyncio sub-tests in parallel using sharding from Cinder. This suite is typically the longest-pole in runs because it is a test package with a lot of further sub-tests otherwise run serially. By breaking out the sub-tests as independent modules we can run a lot more in parallel.
After porting we can see the direct impact on a multicore system.
Without this change:
Running make test is 5 min 26 seconds
With this change:
Running make test takes 3 min 39 seconds
That'll vary based on system and parallelism. On a `-j 4` run similar to what CI and buildbot systems often do, it reduced the overall test suite completion latency by 10%.
The drawbacks are that this implementation is hacky and due to the sorting of the tests it obscures when the asyncio tests occur and involves changing CPython test infrastructure but, the wall time saved it is worth it, especially in low-core count CI runs as it pulls a long tail. The win for productivity and reserved CI resource usage is significant.
Future tests that deserve to be refactored into split up suites to benefit from are test_concurrent_futures and the way the _test_multiprocessing suite gets run for all start methods. As exposed by passing the -o flag to python -m test to get a list of the 10 longest running tests.
---------
Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google, LLC]
(cherry picked from commit 9e011e7c77dad7d0bbb944c44891531606caeb21)
* Display the sanitizer config in the regrtest header. (#105301)
Display the sanitizers present in libregrtest.
Having this in the CI output for tests with the relevant environment
variable displayed will help make it easier to do what we need to
create an equivalent local test run.
(cherry picked from commit 852348ab65783601e0844b6647ea033668b45c11)
* gh-101634: regrtest reports decoding error as failed test (#106169)
When running the Python test suite with -jN option, if a worker stdout
cannot be decoded from the locale encoding report a failed testn so the
exitcode is non-zero.
(cherry picked from commit 2ac3eec103cf450aaaebeb932e51155d2e7fb37b)
* gh-108223: test.pythoninfo and libregrtest log Py_NOGIL (#108238)
Enable with --disable-gil --without-pydebug:
$ make pythoninfo|grep NOGIL
sysconfig[Py_NOGIL]: 1
$ ./python -m test
...
== Python build: nogil debug
...
(cherry picked from commit 5afe0c17ca14df430736e549542a4b85e7e7c7ac)
* gh-90791: test.pythoninfo logs ASAN_OPTIONS env var (#108289)
* Cleanup libregrtest code logging ASAN_OPTIONS.
* Fix a typo on "ASAN_OPTIONS" vs "MSAN_OPTIONS".
(cherry picked from commit 3a1ac87f8f89d3206b46a0df4908afae629d669d)
* gh-108388: regrtest splits test_asyncio package (#108393)
Currently, test_asyncio package is only splitted into sub-tests when
using command "./python -m test". With this change, it's also
splitted when passing it on the command line:
"./python -m test test_asyncio".
Remove the concept of "STDTESTS". Python is now mature enough to not
have to bother with that anymore. Removing STDTESTS simplify the
code.
(cherry picked from commit 174e9da0836844a2138cc8915dd305cb2cd7a583)
* regrtest computes statistics (#108793)
test_netrc, test_pep646_syntax and test_xml_etree now return results
in the test_main() function.
Changes:
* Rewrite TestResult as a dataclass with a new State class.
* Add test.support.TestStats class and Regrtest.stats_dict attribute.
* libregrtest.runtest functions now modify a TestResult instance
in-place.
* libregrtest summary lists the number of run tests and skipped
tests, and denied resources.
* Add TestResult.has_meaningful_duration() method.
* Compute TestResult duration in the upper function.
* Use time.perf_counter() instead of time.monotonic().
* Regrtest: rename 'resource_denieds' attribute to 'resource_denied'.
* Rename CHILD_ERROR to MULTIPROCESSING_ERROR.
* Use match/case syntadx to have different code depending on the
test state.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit d4e534cbb35678c82b3a1276826af55d7bfc23b6)
* gh-108822: Add Changelog entry for regrtest statistics (#108821)
---------
Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Zachary Ware <zach@python.org>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Joshua Herman <zitterbewegung@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-09-03 19:21:53 +02:00
|
|
|
self.check_executed_tests(output, tests, stats=stats)
|
2015-09-28 23:16:17 +02:00
|
|
|
|
2016-03-24 09:43:00 +01:00
|
|
|
# test format 'test_opcodes'
|
|
|
|
|
with open(filename, "w") as fp:
|
|
|
|
|
for name in tests:
|
|
|
|
|
print(name, file=fp)
|
|
|
|
|
|
|
|
|
|
output = self.run_tests('--fromfile', filename)
|
[3.11] gh-108822: Backport libregrtest changes from the main branch (#108820)
* Revert "[3.11] gh-101634: regrtest reports decoding error as failed test (#106169) (#106175)"
This reverts commit d5418e97fc524420011a370ba3c2c3cf6a89a74f.
* Revert "[3.11] bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (GH-30895) (GH-103342)"
This reverts commit ecb09a849689764193e0115d27e220f82b5f6d9f.
* Revert "gh-95027: Fix regrtest stdout encoding on Windows (GH-98492)"
This reverts commit b2aa28eec56d07b9c6777b02b7247cf21839de9f.
* Revert "[3.11] gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253) (GH-94408)"
This reverts commit 0122ab235b5acb52dd99fd05d8802a00f438b828.
* Revert "Run Tools/scripts/reindent.py (GH-94225)"
This reverts commit f0f3a424afb00a15ce8c0140dd218f5b33929be6.
* Revert "gh-94052: Don't re-run failed tests with --python option (GH-94054)"
This reverts commit 1347607db12012f6458ffcba48d8ad797083812e.
* Revert "[3.11] gh-84461: Fix Emscripten umask and permission issues (GH-94002) (GH-94006)"
This reverts commit 10731849184a3101ed18683b0128d689f1671c3f.
* gh-93353: regrtest checks for leaked temporary files (#93776)
When running tests with -jN, create a temporary directory per process
and mark a test as "environment changed" if a test leaks a temporary
file or directory.
(cherry picked from commit e566ce5496f1bad81c431aaee65e36d5e44771c5)
* gh-93353: Fix regrtest for -jN with N >= 2 (GH-93813)
(cherry picked from commit 36934a16e86f34d69ba2d41630fb5b4d06d59cff)
* gh-93353: regrtest supports checking tmp files with -j2 (#93909)
regrtest now also implements checking for leaked temporary files and
directories when using -jN for N >= 2. Use tempfile.mkdtemp() to
create the temporary directory. Skip this check on WASI.
(cherry picked from commit 4f85cec9e2077681b3dacc3108e646d509b720bf)
* gh-84461: Fix Emscripten umask and permission issues (GH-94002)
- Emscripten's default umask is too strict, see
https://github.com/emscripten-core/emscripten/issues/17269
- getuid/getgid and geteuid/getegid are stubs that always return 0
(root). Disable effective uid/gid syscalls and fix tests that use
chmod() current user.
- Cannot drop X bit from directory.
(cherry picked from commit 2702e408fd0e0dd7aec396b4cf8c7ce9caae81d8)
* gh-94052: Don't re-run failed tests with --python option (#94054)
(cherry picked from commit 0ff7b996f5d836e63cdaf652c7aa734285261096)
* Run Tools/scripts/reindent.py (#94225)
Reindent files which were not properly formatted (PEP 8: 4 spaces).
Remove also some trailing spaces.
(cherry picked from commit e87ada48a9e5d9d03f9759138869216df0d7383a)
* gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253)
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 199ba233248ab279f445e0809c2077976f0711bc)
* gh-96465: Clear fractions hash lru_cache under refleak testing (GH-96689)
Automerge-Triggered-By: GH:zware
(cherry picked from commit 9c8f3794337457b1d905a9fa0f38c2978fe32abd)
* gh-95027: Fix regrtest stdout encoding on Windows (#98492)
On Windows, when the Python test suite is run with the -jN option,
the ANSI code page is now used as the encoding for the stdout
temporary file, rather than using UTF-8 which can lead to decoding
errors.
(cherry picked from commit ec1f6f5f139868dc2c1116a7c7c878c38c668d53)
* gh-98903: Test suite fails with exit code 4 if no tests ran (#98904)
The Python test suite now fails wit exit code 4 if no tests ran. It
should help detecting typos in test names and test methods.
* Add "EXITCODE_" constants to Lib/test/libregrtest/main.py.
* Fix a typo: "NO TEST RUN" becomes "NO TESTS RAN"
(cherry picked from commit c76db37c0d23174cbffd6fa978d39693890ef020)
* gh-100086: Add build info to test.libregrtest (#100093)
The Python test runner (libregrtest) now logs Python build information like
"debug" vs "release" build, or LTO and PGO optimizations.
(cherry picked from commit 3c892022472eb975360fb3f0caa6f6fcc6fbf220)
* bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (#30895)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
(cherry picked from commit 995386071f96e4cfebfa027a71ca9134e4651d2a)
* gh-82054: allow test runner to split test_asyncio to execute in parallel by sharding. (#103927)
This runs test_asyncio sub-tests in parallel using sharding from Cinder. This suite is typically the longest-pole in runs because it is a test package with a lot of further sub-tests otherwise run serially. By breaking out the sub-tests as independent modules we can run a lot more in parallel.
After porting we can see the direct impact on a multicore system.
Without this change:
Running make test is 5 min 26 seconds
With this change:
Running make test takes 3 min 39 seconds
That'll vary based on system and parallelism. On a `-j 4` run similar to what CI and buildbot systems often do, it reduced the overall test suite completion latency by 10%.
The drawbacks are that this implementation is hacky and due to the sorting of the tests it obscures when the asyncio tests occur and involves changing CPython test infrastructure but, the wall time saved it is worth it, especially in low-core count CI runs as it pulls a long tail. The win for productivity and reserved CI resource usage is significant.
Future tests that deserve to be refactored into split up suites to benefit from are test_concurrent_futures and the way the _test_multiprocessing suite gets run for all start methods. As exposed by passing the -o flag to python -m test to get a list of the 10 longest running tests.
---------
Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google, LLC]
(cherry picked from commit 9e011e7c77dad7d0bbb944c44891531606caeb21)
* Display the sanitizer config in the regrtest header. (#105301)
Display the sanitizers present in libregrtest.
Having this in the CI output for tests with the relevant environment
variable displayed will help make it easier to do what we need to
create an equivalent local test run.
(cherry picked from commit 852348ab65783601e0844b6647ea033668b45c11)
* gh-101634: regrtest reports decoding error as failed test (#106169)
When running the Python test suite with -jN option, if a worker stdout
cannot be decoded from the locale encoding report a failed testn so the
exitcode is non-zero.
(cherry picked from commit 2ac3eec103cf450aaaebeb932e51155d2e7fb37b)
* gh-108223: test.pythoninfo and libregrtest log Py_NOGIL (#108238)
Enable with --disable-gil --without-pydebug:
$ make pythoninfo|grep NOGIL
sysconfig[Py_NOGIL]: 1
$ ./python -m test
...
== Python build: nogil debug
...
(cherry picked from commit 5afe0c17ca14df430736e549542a4b85e7e7c7ac)
* gh-90791: test.pythoninfo logs ASAN_OPTIONS env var (#108289)
* Cleanup libregrtest code logging ASAN_OPTIONS.
* Fix a typo on "ASAN_OPTIONS" vs "MSAN_OPTIONS".
(cherry picked from commit 3a1ac87f8f89d3206b46a0df4908afae629d669d)
* gh-108388: regrtest splits test_asyncio package (#108393)
Currently, test_asyncio package is only splitted into sub-tests when
using command "./python -m test". With this change, it's also
splitted when passing it on the command line:
"./python -m test test_asyncio".
Remove the concept of "STDTESTS". Python is now mature enough to not
have to bother with that anymore. Removing STDTESTS simplify the
code.
(cherry picked from commit 174e9da0836844a2138cc8915dd305cb2cd7a583)
* regrtest computes statistics (#108793)
test_netrc, test_pep646_syntax and test_xml_etree now return results
in the test_main() function.
Changes:
* Rewrite TestResult as a dataclass with a new State class.
* Add test.support.TestStats class and Regrtest.stats_dict attribute.
* libregrtest.runtest functions now modify a TestResult instance
in-place.
* libregrtest summary lists the number of run tests and skipped
tests, and denied resources.
* Add TestResult.has_meaningful_duration() method.
* Compute TestResult duration in the upper function.
* Use time.perf_counter() instead of time.monotonic().
* Regrtest: rename 'resource_denieds' attribute to 'resource_denied'.
* Rename CHILD_ERROR to MULTIPROCESSING_ERROR.
* Use match/case syntadx to have different code depending on the
test state.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit d4e534cbb35678c82b3a1276826af55d7bfc23b6)
* gh-108822: Add Changelog entry for regrtest statistics (#108821)
---------
Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Zachary Ware <zach@python.org>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Joshua Herman <zitterbewegung@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-09-03 19:21:53 +02:00
|
|
|
self.check_executed_tests(output, tests, stats=stats)
|
2016-03-24 09:43:00 +01:00
|
|
|
|
2017-01-03 01:38:58 +01:00
|
|
|
# test format 'Lib/test/test_opcodes.py'
|
|
|
|
|
with open(filename, "w") as fp:
|
|
|
|
|
for name in tests:
|
|
|
|
|
print('Lib/test/%s.py' % name, file=fp)
|
|
|
|
|
|
|
|
|
|
output = self.run_tests('--fromfile', filename)
|
[3.11] gh-108822: Backport libregrtest changes from the main branch (#108820)
* Revert "[3.11] gh-101634: regrtest reports decoding error as failed test (#106169) (#106175)"
This reverts commit d5418e97fc524420011a370ba3c2c3cf6a89a74f.
* Revert "[3.11] bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (GH-30895) (GH-103342)"
This reverts commit ecb09a849689764193e0115d27e220f82b5f6d9f.
* Revert "gh-95027: Fix regrtest stdout encoding on Windows (GH-98492)"
This reverts commit b2aa28eec56d07b9c6777b02b7247cf21839de9f.
* Revert "[3.11] gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253) (GH-94408)"
This reverts commit 0122ab235b5acb52dd99fd05d8802a00f438b828.
* Revert "Run Tools/scripts/reindent.py (GH-94225)"
This reverts commit f0f3a424afb00a15ce8c0140dd218f5b33929be6.
* Revert "gh-94052: Don't re-run failed tests with --python option (GH-94054)"
This reverts commit 1347607db12012f6458ffcba48d8ad797083812e.
* Revert "[3.11] gh-84461: Fix Emscripten umask and permission issues (GH-94002) (GH-94006)"
This reverts commit 10731849184a3101ed18683b0128d689f1671c3f.
* gh-93353: regrtest checks for leaked temporary files (#93776)
When running tests with -jN, create a temporary directory per process
and mark a test as "environment changed" if a test leaks a temporary
file or directory.
(cherry picked from commit e566ce5496f1bad81c431aaee65e36d5e44771c5)
* gh-93353: Fix regrtest for -jN with N >= 2 (GH-93813)
(cherry picked from commit 36934a16e86f34d69ba2d41630fb5b4d06d59cff)
* gh-93353: regrtest supports checking tmp files with -j2 (#93909)
regrtest now also implements checking for leaked temporary files and
directories when using -jN for N >= 2. Use tempfile.mkdtemp() to
create the temporary directory. Skip this check on WASI.
(cherry picked from commit 4f85cec9e2077681b3dacc3108e646d509b720bf)
* gh-84461: Fix Emscripten umask and permission issues (GH-94002)
- Emscripten's default umask is too strict, see
https://github.com/emscripten-core/emscripten/issues/17269
- getuid/getgid and geteuid/getegid are stubs that always return 0
(root). Disable effective uid/gid syscalls and fix tests that use
chmod() current user.
- Cannot drop X bit from directory.
(cherry picked from commit 2702e408fd0e0dd7aec396b4cf8c7ce9caae81d8)
* gh-94052: Don't re-run failed tests with --python option (#94054)
(cherry picked from commit 0ff7b996f5d836e63cdaf652c7aa734285261096)
* Run Tools/scripts/reindent.py (#94225)
Reindent files which were not properly formatted (PEP 8: 4 spaces).
Remove also some trailing spaces.
(cherry picked from commit e87ada48a9e5d9d03f9759138869216df0d7383a)
* gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253)
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 199ba233248ab279f445e0809c2077976f0711bc)
* gh-96465: Clear fractions hash lru_cache under refleak testing (GH-96689)
Automerge-Triggered-By: GH:zware
(cherry picked from commit 9c8f3794337457b1d905a9fa0f38c2978fe32abd)
* gh-95027: Fix regrtest stdout encoding on Windows (#98492)
On Windows, when the Python test suite is run with the -jN option,
the ANSI code page is now used as the encoding for the stdout
temporary file, rather than using UTF-8 which can lead to decoding
errors.
(cherry picked from commit ec1f6f5f139868dc2c1116a7c7c878c38c668d53)
* gh-98903: Test suite fails with exit code 4 if no tests ran (#98904)
The Python test suite now fails wit exit code 4 if no tests ran. It
should help detecting typos in test names and test methods.
* Add "EXITCODE_" constants to Lib/test/libregrtest/main.py.
* Fix a typo: "NO TEST RUN" becomes "NO TESTS RAN"
(cherry picked from commit c76db37c0d23174cbffd6fa978d39693890ef020)
* gh-100086: Add build info to test.libregrtest (#100093)
The Python test runner (libregrtest) now logs Python build information like
"debug" vs "release" build, or LTO and PGO optimizations.
(cherry picked from commit 3c892022472eb975360fb3f0caa6f6fcc6fbf220)
* bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (#30895)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
(cherry picked from commit 995386071f96e4cfebfa027a71ca9134e4651d2a)
* gh-82054: allow test runner to split test_asyncio to execute in parallel by sharding. (#103927)
This runs test_asyncio sub-tests in parallel using sharding from Cinder. This suite is typically the longest-pole in runs because it is a test package with a lot of further sub-tests otherwise run serially. By breaking out the sub-tests as independent modules we can run a lot more in parallel.
After porting we can see the direct impact on a multicore system.
Without this change:
Running make test is 5 min 26 seconds
With this change:
Running make test takes 3 min 39 seconds
That'll vary based on system and parallelism. On a `-j 4` run similar to what CI and buildbot systems often do, it reduced the overall test suite completion latency by 10%.
The drawbacks are that this implementation is hacky and due to the sorting of the tests it obscures when the asyncio tests occur and involves changing CPython test infrastructure but, the wall time saved it is worth it, especially in low-core count CI runs as it pulls a long tail. The win for productivity and reserved CI resource usage is significant.
Future tests that deserve to be refactored into split up suites to benefit from are test_concurrent_futures and the way the _test_multiprocessing suite gets run for all start methods. As exposed by passing the -o flag to python -m test to get a list of the 10 longest running tests.
---------
Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google, LLC]
(cherry picked from commit 9e011e7c77dad7d0bbb944c44891531606caeb21)
* Display the sanitizer config in the regrtest header. (#105301)
Display the sanitizers present in libregrtest.
Having this in the CI output for tests with the relevant environment
variable displayed will help make it easier to do what we need to
create an equivalent local test run.
(cherry picked from commit 852348ab65783601e0844b6647ea033668b45c11)
* gh-101634: regrtest reports decoding error as failed test (#106169)
When running the Python test suite with -jN option, if a worker stdout
cannot be decoded from the locale encoding report a failed testn so the
exitcode is non-zero.
(cherry picked from commit 2ac3eec103cf450aaaebeb932e51155d2e7fb37b)
* gh-108223: test.pythoninfo and libregrtest log Py_NOGIL (#108238)
Enable with --disable-gil --without-pydebug:
$ make pythoninfo|grep NOGIL
sysconfig[Py_NOGIL]: 1
$ ./python -m test
...
== Python build: nogil debug
...
(cherry picked from commit 5afe0c17ca14df430736e549542a4b85e7e7c7ac)
* gh-90791: test.pythoninfo logs ASAN_OPTIONS env var (#108289)
* Cleanup libregrtest code logging ASAN_OPTIONS.
* Fix a typo on "ASAN_OPTIONS" vs "MSAN_OPTIONS".
(cherry picked from commit 3a1ac87f8f89d3206b46a0df4908afae629d669d)
* gh-108388: regrtest splits test_asyncio package (#108393)
Currently, test_asyncio package is only splitted into sub-tests when
using command "./python -m test". With this change, it's also
splitted when passing it on the command line:
"./python -m test test_asyncio".
Remove the concept of "STDTESTS". Python is now mature enough to not
have to bother with that anymore. Removing STDTESTS simplify the
code.
(cherry picked from commit 174e9da0836844a2138cc8915dd305cb2cd7a583)
* regrtest computes statistics (#108793)
test_netrc, test_pep646_syntax and test_xml_etree now return results
in the test_main() function.
Changes:
* Rewrite TestResult as a dataclass with a new State class.
* Add test.support.TestStats class and Regrtest.stats_dict attribute.
* libregrtest.runtest functions now modify a TestResult instance
in-place.
* libregrtest summary lists the number of run tests and skipped
tests, and denied resources.
* Add TestResult.has_meaningful_duration() method.
* Compute TestResult duration in the upper function.
* Use time.perf_counter() instead of time.monotonic().
* Regrtest: rename 'resource_denieds' attribute to 'resource_denied'.
* Rename CHILD_ERROR to MULTIPROCESSING_ERROR.
* Use match/case syntadx to have different code depending on the
test state.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit d4e534cbb35678c82b3a1276826af55d7bfc23b6)
* gh-108822: Add Changelog entry for regrtest statistics (#108821)
---------
Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Zachary Ware <zach@python.org>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Joshua Herman <zitterbewegung@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-09-03 19:21:53 +02:00
|
|
|
self.check_executed_tests(output, tests, stats=stats)
|
2017-01-03 01:38:58 +01:00
|
|
|
|
2015-10-11 10:37:25 +02:00
|
|
|
def test_interrupted(self):
|
|
|
|
|
code = TEST_INTERRUPTED
|
2016-03-30 02:33:52 +02:00
|
|
|
test = self.create_test('sigint', code=code)
|
[3.11] gh-108822: Backport libregrtest changes from the main branch (#108820)
* Revert "[3.11] gh-101634: regrtest reports decoding error as failed test (#106169) (#106175)"
This reverts commit d5418e97fc524420011a370ba3c2c3cf6a89a74f.
* Revert "[3.11] bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (GH-30895) (GH-103342)"
This reverts commit ecb09a849689764193e0115d27e220f82b5f6d9f.
* Revert "gh-95027: Fix regrtest stdout encoding on Windows (GH-98492)"
This reverts commit b2aa28eec56d07b9c6777b02b7247cf21839de9f.
* Revert "[3.11] gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253) (GH-94408)"
This reverts commit 0122ab235b5acb52dd99fd05d8802a00f438b828.
* Revert "Run Tools/scripts/reindent.py (GH-94225)"
This reverts commit f0f3a424afb00a15ce8c0140dd218f5b33929be6.
* Revert "gh-94052: Don't re-run failed tests with --python option (GH-94054)"
This reverts commit 1347607db12012f6458ffcba48d8ad797083812e.
* Revert "[3.11] gh-84461: Fix Emscripten umask and permission issues (GH-94002) (GH-94006)"
This reverts commit 10731849184a3101ed18683b0128d689f1671c3f.
* gh-93353: regrtest checks for leaked temporary files (#93776)
When running tests with -jN, create a temporary directory per process
and mark a test as "environment changed" if a test leaks a temporary
file or directory.
(cherry picked from commit e566ce5496f1bad81c431aaee65e36d5e44771c5)
* gh-93353: Fix regrtest for -jN with N >= 2 (GH-93813)
(cherry picked from commit 36934a16e86f34d69ba2d41630fb5b4d06d59cff)
* gh-93353: regrtest supports checking tmp files with -j2 (#93909)
regrtest now also implements checking for leaked temporary files and
directories when using -jN for N >= 2. Use tempfile.mkdtemp() to
create the temporary directory. Skip this check on WASI.
(cherry picked from commit 4f85cec9e2077681b3dacc3108e646d509b720bf)
* gh-84461: Fix Emscripten umask and permission issues (GH-94002)
- Emscripten's default umask is too strict, see
https://github.com/emscripten-core/emscripten/issues/17269
- getuid/getgid and geteuid/getegid are stubs that always return 0
(root). Disable effective uid/gid syscalls and fix tests that use
chmod() current user.
- Cannot drop X bit from directory.
(cherry picked from commit 2702e408fd0e0dd7aec396b4cf8c7ce9caae81d8)
* gh-94052: Don't re-run failed tests with --python option (#94054)
(cherry picked from commit 0ff7b996f5d836e63cdaf652c7aa734285261096)
* Run Tools/scripts/reindent.py (#94225)
Reindent files which were not properly formatted (PEP 8: 4 spaces).
Remove also some trailing spaces.
(cherry picked from commit e87ada48a9e5d9d03f9759138869216df0d7383a)
* gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253)
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 199ba233248ab279f445e0809c2077976f0711bc)
* gh-96465: Clear fractions hash lru_cache under refleak testing (GH-96689)
Automerge-Triggered-By: GH:zware
(cherry picked from commit 9c8f3794337457b1d905a9fa0f38c2978fe32abd)
* gh-95027: Fix regrtest stdout encoding on Windows (#98492)
On Windows, when the Python test suite is run with the -jN option,
the ANSI code page is now used as the encoding for the stdout
temporary file, rather than using UTF-8 which can lead to decoding
errors.
(cherry picked from commit ec1f6f5f139868dc2c1116a7c7c878c38c668d53)
* gh-98903: Test suite fails with exit code 4 if no tests ran (#98904)
The Python test suite now fails wit exit code 4 if no tests ran. It
should help detecting typos in test names and test methods.
* Add "EXITCODE_" constants to Lib/test/libregrtest/main.py.
* Fix a typo: "NO TEST RUN" becomes "NO TESTS RAN"
(cherry picked from commit c76db37c0d23174cbffd6fa978d39693890ef020)
* gh-100086: Add build info to test.libregrtest (#100093)
The Python test runner (libregrtest) now logs Python build information like
"debug" vs "release" build, or LTO and PGO optimizations.
(cherry picked from commit 3c892022472eb975360fb3f0caa6f6fcc6fbf220)
* bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (#30895)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
(cherry picked from commit 995386071f96e4cfebfa027a71ca9134e4651d2a)
* gh-82054: allow test runner to split test_asyncio to execute in parallel by sharding. (#103927)
This runs test_asyncio sub-tests in parallel using sharding from Cinder. This suite is typically the longest-pole in runs because it is a test package with a lot of further sub-tests otherwise run serially. By breaking out the sub-tests as independent modules we can run a lot more in parallel.
After porting we can see the direct impact on a multicore system.
Without this change:
Running make test is 5 min 26 seconds
With this change:
Running make test takes 3 min 39 seconds
That'll vary based on system and parallelism. On a `-j 4` run similar to what CI and buildbot systems often do, it reduced the overall test suite completion latency by 10%.
The drawbacks are that this implementation is hacky and due to the sorting of the tests it obscures when the asyncio tests occur and involves changing CPython test infrastructure but, the wall time saved it is worth it, especially in low-core count CI runs as it pulls a long tail. The win for productivity and reserved CI resource usage is significant.
Future tests that deserve to be refactored into split up suites to benefit from are test_concurrent_futures and the way the _test_multiprocessing suite gets run for all start methods. As exposed by passing the -o flag to python -m test to get a list of the 10 longest running tests.
---------
Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google, LLC]
(cherry picked from commit 9e011e7c77dad7d0bbb944c44891531606caeb21)
* Display the sanitizer config in the regrtest header. (#105301)
Display the sanitizers present in libregrtest.
Having this in the CI output for tests with the relevant environment
variable displayed will help make it easier to do what we need to
create an equivalent local test run.
(cherry picked from commit 852348ab65783601e0844b6647ea033668b45c11)
* gh-101634: regrtest reports decoding error as failed test (#106169)
When running the Python test suite with -jN option, if a worker stdout
cannot be decoded from the locale encoding report a failed testn so the
exitcode is non-zero.
(cherry picked from commit 2ac3eec103cf450aaaebeb932e51155d2e7fb37b)
* gh-108223: test.pythoninfo and libregrtest log Py_NOGIL (#108238)
Enable with --disable-gil --without-pydebug:
$ make pythoninfo|grep NOGIL
sysconfig[Py_NOGIL]: 1
$ ./python -m test
...
== Python build: nogil debug
...
(cherry picked from commit 5afe0c17ca14df430736e549542a4b85e7e7c7ac)
* gh-90791: test.pythoninfo logs ASAN_OPTIONS env var (#108289)
* Cleanup libregrtest code logging ASAN_OPTIONS.
* Fix a typo on "ASAN_OPTIONS" vs "MSAN_OPTIONS".
(cherry picked from commit 3a1ac87f8f89d3206b46a0df4908afae629d669d)
* gh-108388: regrtest splits test_asyncio package (#108393)
Currently, test_asyncio package is only splitted into sub-tests when
using command "./python -m test". With this change, it's also
splitted when passing it on the command line:
"./python -m test test_asyncio".
Remove the concept of "STDTESTS". Python is now mature enough to not
have to bother with that anymore. Removing STDTESTS simplify the
code.
(cherry picked from commit 174e9da0836844a2138cc8915dd305cb2cd7a583)
* regrtest computes statistics (#108793)
test_netrc, test_pep646_syntax and test_xml_etree now return results
in the test_main() function.
Changes:
* Rewrite TestResult as a dataclass with a new State class.
* Add test.support.TestStats class and Regrtest.stats_dict attribute.
* libregrtest.runtest functions now modify a TestResult instance
in-place.
* libregrtest summary lists the number of run tests and skipped
tests, and denied resources.
* Add TestResult.has_meaningful_duration() method.
* Compute TestResult duration in the upper function.
* Use time.perf_counter() instead of time.monotonic().
* Regrtest: rename 'resource_denieds' attribute to 'resource_denied'.
* Rename CHILD_ERROR to MULTIPROCESSING_ERROR.
* Use match/case syntadx to have different code depending on the
test state.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit d4e534cbb35678c82b3a1276826af55d7bfc23b6)
* gh-108822: Add Changelog entry for regrtest statistics (#108821)
---------
Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Zachary Ware <zach@python.org>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Joshua Herman <zitterbewegung@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-09-03 19:21:53 +02:00
|
|
|
output = self.run_tests(test, exitcode=EXITCODE_INTERRUPTED)
|
2016-08-17 16:12:16 +02:00
|
|
|
self.check_executed_tests(output, test, omitted=test,
|
[3.11] gh-108822: Backport libregrtest changes from the main branch (#108820)
* Revert "[3.11] gh-101634: regrtest reports decoding error as failed test (#106169) (#106175)"
This reverts commit d5418e97fc524420011a370ba3c2c3cf6a89a74f.
* Revert "[3.11] bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (GH-30895) (GH-103342)"
This reverts commit ecb09a849689764193e0115d27e220f82b5f6d9f.
* Revert "gh-95027: Fix regrtest stdout encoding on Windows (GH-98492)"
This reverts commit b2aa28eec56d07b9c6777b02b7247cf21839de9f.
* Revert "[3.11] gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253) (GH-94408)"
This reverts commit 0122ab235b5acb52dd99fd05d8802a00f438b828.
* Revert "Run Tools/scripts/reindent.py (GH-94225)"
This reverts commit f0f3a424afb00a15ce8c0140dd218f5b33929be6.
* Revert "gh-94052: Don't re-run failed tests with --python option (GH-94054)"
This reverts commit 1347607db12012f6458ffcba48d8ad797083812e.
* Revert "[3.11] gh-84461: Fix Emscripten umask and permission issues (GH-94002) (GH-94006)"
This reverts commit 10731849184a3101ed18683b0128d689f1671c3f.
* gh-93353: regrtest checks for leaked temporary files (#93776)
When running tests with -jN, create a temporary directory per process
and mark a test as "environment changed" if a test leaks a temporary
file or directory.
(cherry picked from commit e566ce5496f1bad81c431aaee65e36d5e44771c5)
* gh-93353: Fix regrtest for -jN with N >= 2 (GH-93813)
(cherry picked from commit 36934a16e86f34d69ba2d41630fb5b4d06d59cff)
* gh-93353: regrtest supports checking tmp files with -j2 (#93909)
regrtest now also implements checking for leaked temporary files and
directories when using -jN for N >= 2. Use tempfile.mkdtemp() to
create the temporary directory. Skip this check on WASI.
(cherry picked from commit 4f85cec9e2077681b3dacc3108e646d509b720bf)
* gh-84461: Fix Emscripten umask and permission issues (GH-94002)
- Emscripten's default umask is too strict, see
https://github.com/emscripten-core/emscripten/issues/17269
- getuid/getgid and geteuid/getegid are stubs that always return 0
(root). Disable effective uid/gid syscalls and fix tests that use
chmod() current user.
- Cannot drop X bit from directory.
(cherry picked from commit 2702e408fd0e0dd7aec396b4cf8c7ce9caae81d8)
* gh-94052: Don't re-run failed tests with --python option (#94054)
(cherry picked from commit 0ff7b996f5d836e63cdaf652c7aa734285261096)
* Run Tools/scripts/reindent.py (#94225)
Reindent files which were not properly formatted (PEP 8: 4 spaces).
Remove also some trailing spaces.
(cherry picked from commit e87ada48a9e5d9d03f9759138869216df0d7383a)
* gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253)
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 199ba233248ab279f445e0809c2077976f0711bc)
* gh-96465: Clear fractions hash lru_cache under refleak testing (GH-96689)
Automerge-Triggered-By: GH:zware
(cherry picked from commit 9c8f3794337457b1d905a9fa0f38c2978fe32abd)
* gh-95027: Fix regrtest stdout encoding on Windows (#98492)
On Windows, when the Python test suite is run with the -jN option,
the ANSI code page is now used as the encoding for the stdout
temporary file, rather than using UTF-8 which can lead to decoding
errors.
(cherry picked from commit ec1f6f5f139868dc2c1116a7c7c878c38c668d53)
* gh-98903: Test suite fails with exit code 4 if no tests ran (#98904)
The Python test suite now fails wit exit code 4 if no tests ran. It
should help detecting typos in test names and test methods.
* Add "EXITCODE_" constants to Lib/test/libregrtest/main.py.
* Fix a typo: "NO TEST RUN" becomes "NO TESTS RAN"
(cherry picked from commit c76db37c0d23174cbffd6fa978d39693890ef020)
* gh-100086: Add build info to test.libregrtest (#100093)
The Python test runner (libregrtest) now logs Python build information like
"debug" vs "release" build, or LTO and PGO optimizations.
(cherry picked from commit 3c892022472eb975360fb3f0caa6f6fcc6fbf220)
* bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (#30895)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
(cherry picked from commit 995386071f96e4cfebfa027a71ca9134e4651d2a)
* gh-82054: allow test runner to split test_asyncio to execute in parallel by sharding. (#103927)
This runs test_asyncio sub-tests in parallel using sharding from Cinder. This suite is typically the longest-pole in runs because it is a test package with a lot of further sub-tests otherwise run serially. By breaking out the sub-tests as independent modules we can run a lot more in parallel.
After porting we can see the direct impact on a multicore system.
Without this change:
Running make test is 5 min 26 seconds
With this change:
Running make test takes 3 min 39 seconds
That'll vary based on system and parallelism. On a `-j 4` run similar to what CI and buildbot systems often do, it reduced the overall test suite completion latency by 10%.
The drawbacks are that this implementation is hacky and due to the sorting of the tests it obscures when the asyncio tests occur and involves changing CPython test infrastructure but, the wall time saved it is worth it, especially in low-core count CI runs as it pulls a long tail. The win for productivity and reserved CI resource usage is significant.
Future tests that deserve to be refactored into split up suites to benefit from are test_concurrent_futures and the way the _test_multiprocessing suite gets run for all start methods. As exposed by passing the -o flag to python -m test to get a list of the 10 longest running tests.
---------
Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google, LLC]
(cherry picked from commit 9e011e7c77dad7d0bbb944c44891531606caeb21)
* Display the sanitizer config in the regrtest header. (#105301)
Display the sanitizers present in libregrtest.
Having this in the CI output for tests with the relevant environment
variable displayed will help make it easier to do what we need to
create an equivalent local test run.
(cherry picked from commit 852348ab65783601e0844b6647ea033668b45c11)
* gh-101634: regrtest reports decoding error as failed test (#106169)
When running the Python test suite with -jN option, if a worker stdout
cannot be decoded from the locale encoding report a failed testn so the
exitcode is non-zero.
(cherry picked from commit 2ac3eec103cf450aaaebeb932e51155d2e7fb37b)
* gh-108223: test.pythoninfo and libregrtest log Py_NOGIL (#108238)
Enable with --disable-gil --without-pydebug:
$ make pythoninfo|grep NOGIL
sysconfig[Py_NOGIL]: 1
$ ./python -m test
...
== Python build: nogil debug
...
(cherry picked from commit 5afe0c17ca14df430736e549542a4b85e7e7c7ac)
* gh-90791: test.pythoninfo logs ASAN_OPTIONS env var (#108289)
* Cleanup libregrtest code logging ASAN_OPTIONS.
* Fix a typo on "ASAN_OPTIONS" vs "MSAN_OPTIONS".
(cherry picked from commit 3a1ac87f8f89d3206b46a0df4908afae629d669d)
* gh-108388: regrtest splits test_asyncio package (#108393)
Currently, test_asyncio package is only splitted into sub-tests when
using command "./python -m test". With this change, it's also
splitted when passing it on the command line:
"./python -m test test_asyncio".
Remove the concept of "STDTESTS". Python is now mature enough to not
have to bother with that anymore. Removing STDTESTS simplify the
code.
(cherry picked from commit 174e9da0836844a2138cc8915dd305cb2cd7a583)
* regrtest computes statistics (#108793)
test_netrc, test_pep646_syntax and test_xml_etree now return results
in the test_main() function.
Changes:
* Rewrite TestResult as a dataclass with a new State class.
* Add test.support.TestStats class and Regrtest.stats_dict attribute.
* libregrtest.runtest functions now modify a TestResult instance
in-place.
* libregrtest summary lists the number of run tests and skipped
tests, and denied resources.
* Add TestResult.has_meaningful_duration() method.
* Compute TestResult duration in the upper function.
* Use time.perf_counter() instead of time.monotonic().
* Regrtest: rename 'resource_denieds' attribute to 'resource_denied'.
* Rename CHILD_ERROR to MULTIPROCESSING_ERROR.
* Use match/case syntadx to have different code depending on the
test state.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit d4e534cbb35678c82b3a1276826af55d7bfc23b6)
* gh-108822: Add Changelog entry for regrtest statistics (#108821)
---------
Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Zachary Ware <zach@python.org>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Joshua Herman <zitterbewegung@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-09-03 19:21:53 +02:00
|
|
|
interrupted=True, stats=0)
|
2015-10-11 10:37:25 +02:00
|
|
|
|
2016-08-17 12:22:52 +02:00
|
|
|
def test_slowest(self):
|
2016-08-17 11:25:43 +02:00
|
|
|
# test --slowest
|
2015-09-28 23:16:17 +02:00
|
|
|
tests = [self.create_test() for index in range(3)]
|
2016-08-17 11:25:43 +02:00
|
|
|
output = self.run_tests("--slowest", *tests)
|
[3.11] gh-108822: Backport libregrtest changes from the main branch (#108820)
* Revert "[3.11] gh-101634: regrtest reports decoding error as failed test (#106169) (#106175)"
This reverts commit d5418e97fc524420011a370ba3c2c3cf6a89a74f.
* Revert "[3.11] bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (GH-30895) (GH-103342)"
This reverts commit ecb09a849689764193e0115d27e220f82b5f6d9f.
* Revert "gh-95027: Fix regrtest stdout encoding on Windows (GH-98492)"
This reverts commit b2aa28eec56d07b9c6777b02b7247cf21839de9f.
* Revert "[3.11] gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253) (GH-94408)"
This reverts commit 0122ab235b5acb52dd99fd05d8802a00f438b828.
* Revert "Run Tools/scripts/reindent.py (GH-94225)"
This reverts commit f0f3a424afb00a15ce8c0140dd218f5b33929be6.
* Revert "gh-94052: Don't re-run failed tests with --python option (GH-94054)"
This reverts commit 1347607db12012f6458ffcba48d8ad797083812e.
* Revert "[3.11] gh-84461: Fix Emscripten umask and permission issues (GH-94002) (GH-94006)"
This reverts commit 10731849184a3101ed18683b0128d689f1671c3f.
* gh-93353: regrtest checks for leaked temporary files (#93776)
When running tests with -jN, create a temporary directory per process
and mark a test as "environment changed" if a test leaks a temporary
file or directory.
(cherry picked from commit e566ce5496f1bad81c431aaee65e36d5e44771c5)
* gh-93353: Fix regrtest for -jN with N >= 2 (GH-93813)
(cherry picked from commit 36934a16e86f34d69ba2d41630fb5b4d06d59cff)
* gh-93353: regrtest supports checking tmp files with -j2 (#93909)
regrtest now also implements checking for leaked temporary files and
directories when using -jN for N >= 2. Use tempfile.mkdtemp() to
create the temporary directory. Skip this check on WASI.
(cherry picked from commit 4f85cec9e2077681b3dacc3108e646d509b720bf)
* gh-84461: Fix Emscripten umask and permission issues (GH-94002)
- Emscripten's default umask is too strict, see
https://github.com/emscripten-core/emscripten/issues/17269
- getuid/getgid and geteuid/getegid are stubs that always return 0
(root). Disable effective uid/gid syscalls and fix tests that use
chmod() current user.
- Cannot drop X bit from directory.
(cherry picked from commit 2702e408fd0e0dd7aec396b4cf8c7ce9caae81d8)
* gh-94052: Don't re-run failed tests with --python option (#94054)
(cherry picked from commit 0ff7b996f5d836e63cdaf652c7aa734285261096)
* Run Tools/scripts/reindent.py (#94225)
Reindent files which were not properly formatted (PEP 8: 4 spaces).
Remove also some trailing spaces.
(cherry picked from commit e87ada48a9e5d9d03f9759138869216df0d7383a)
* gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253)
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 199ba233248ab279f445e0809c2077976f0711bc)
* gh-96465: Clear fractions hash lru_cache under refleak testing (GH-96689)
Automerge-Triggered-By: GH:zware
(cherry picked from commit 9c8f3794337457b1d905a9fa0f38c2978fe32abd)
* gh-95027: Fix regrtest stdout encoding on Windows (#98492)
On Windows, when the Python test suite is run with the -jN option,
the ANSI code page is now used as the encoding for the stdout
temporary file, rather than using UTF-8 which can lead to decoding
errors.
(cherry picked from commit ec1f6f5f139868dc2c1116a7c7c878c38c668d53)
* gh-98903: Test suite fails with exit code 4 if no tests ran (#98904)
The Python test suite now fails wit exit code 4 if no tests ran. It
should help detecting typos in test names and test methods.
* Add "EXITCODE_" constants to Lib/test/libregrtest/main.py.
* Fix a typo: "NO TEST RUN" becomes "NO TESTS RAN"
(cherry picked from commit c76db37c0d23174cbffd6fa978d39693890ef020)
* gh-100086: Add build info to test.libregrtest (#100093)
The Python test runner (libregrtest) now logs Python build information like
"debug" vs "release" build, or LTO and PGO optimizations.
(cherry picked from commit 3c892022472eb975360fb3f0caa6f6fcc6fbf220)
* bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (#30895)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
(cherry picked from commit 995386071f96e4cfebfa027a71ca9134e4651d2a)
* gh-82054: allow test runner to split test_asyncio to execute in parallel by sharding. (#103927)
This runs test_asyncio sub-tests in parallel using sharding from Cinder. This suite is typically the longest-pole in runs because it is a test package with a lot of further sub-tests otherwise run serially. By breaking out the sub-tests as independent modules we can run a lot more in parallel.
After porting we can see the direct impact on a multicore system.
Without this change:
Running make test is 5 min 26 seconds
With this change:
Running make test takes 3 min 39 seconds
That'll vary based on system and parallelism. On a `-j 4` run similar to what CI and buildbot systems often do, it reduced the overall test suite completion latency by 10%.
The drawbacks are that this implementation is hacky and due to the sorting of the tests it obscures when the asyncio tests occur and involves changing CPython test infrastructure but, the wall time saved it is worth it, especially in low-core count CI runs as it pulls a long tail. The win for productivity and reserved CI resource usage is significant.
Future tests that deserve to be refactored into split up suites to benefit from are test_concurrent_futures and the way the _test_multiprocessing suite gets run for all start methods. As exposed by passing the -o flag to python -m test to get a list of the 10 longest running tests.
---------
Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google, LLC]
(cherry picked from commit 9e011e7c77dad7d0bbb944c44891531606caeb21)
* Display the sanitizer config in the regrtest header. (#105301)
Display the sanitizers present in libregrtest.
Having this in the CI output for tests with the relevant environment
variable displayed will help make it easier to do what we need to
create an equivalent local test run.
(cherry picked from commit 852348ab65783601e0844b6647ea033668b45c11)
* gh-101634: regrtest reports decoding error as failed test (#106169)
When running the Python test suite with -jN option, if a worker stdout
cannot be decoded from the locale encoding report a failed testn so the
exitcode is non-zero.
(cherry picked from commit 2ac3eec103cf450aaaebeb932e51155d2e7fb37b)
* gh-108223: test.pythoninfo and libregrtest log Py_NOGIL (#108238)
Enable with --disable-gil --without-pydebug:
$ make pythoninfo|grep NOGIL
sysconfig[Py_NOGIL]: 1
$ ./python -m test
...
== Python build: nogil debug
...
(cherry picked from commit 5afe0c17ca14df430736e549542a4b85e7e7c7ac)
* gh-90791: test.pythoninfo logs ASAN_OPTIONS env var (#108289)
* Cleanup libregrtest code logging ASAN_OPTIONS.
* Fix a typo on "ASAN_OPTIONS" vs "MSAN_OPTIONS".
(cherry picked from commit 3a1ac87f8f89d3206b46a0df4908afae629d669d)
* gh-108388: regrtest splits test_asyncio package (#108393)
Currently, test_asyncio package is only splitted into sub-tests when
using command "./python -m test". With this change, it's also
splitted when passing it on the command line:
"./python -m test test_asyncio".
Remove the concept of "STDTESTS". Python is now mature enough to not
have to bother with that anymore. Removing STDTESTS simplify the
code.
(cherry picked from commit 174e9da0836844a2138cc8915dd305cb2cd7a583)
* regrtest computes statistics (#108793)
test_netrc, test_pep646_syntax and test_xml_etree now return results
in the test_main() function.
Changes:
* Rewrite TestResult as a dataclass with a new State class.
* Add test.support.TestStats class and Regrtest.stats_dict attribute.
* libregrtest.runtest functions now modify a TestResult instance
in-place.
* libregrtest summary lists the number of run tests and skipped
tests, and denied resources.
* Add TestResult.has_meaningful_duration() method.
* Compute TestResult duration in the upper function.
* Use time.perf_counter() instead of time.monotonic().
* Regrtest: rename 'resource_denieds' attribute to 'resource_denied'.
* Rename CHILD_ERROR to MULTIPROCESSING_ERROR.
* Use match/case syntadx to have different code depending on the
test state.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit d4e534cbb35678c82b3a1276826af55d7bfc23b6)
* gh-108822: Add Changelog entry for regrtest statistics (#108821)
---------
Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Zachary Ware <zach@python.org>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Joshua Herman <zitterbewegung@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-09-03 19:21:53 +02:00
|
|
|
self.check_executed_tests(output, tests, stats=len(tests))
|
2015-09-28 23:16:17 +02:00
|
|
|
regex = ('10 slowest tests:\n'
|
2016-08-17 12:22:52 +02:00
|
|
|
'(?:- %s: .*\n){%s}'
|
2015-09-28 23:16:17 +02:00
|
|
|
% (self.TESTNAME_REGEX, len(tests)))
|
|
|
|
|
self.check_line(output, regex)
|
|
|
|
|
|
2019-04-26 04:08:53 +02:00
|
|
|
def test_slowest_interrupted(self):
|
2016-08-17 11:25:43 +02:00
|
|
|
# Issue #25373: test --slowest with an interrupted test
|
2015-10-11 10:37:25 +02:00
|
|
|
code = TEST_INTERRUPTED
|
|
|
|
|
test = self.create_test("sigint", code=code)
|
|
|
|
|
|
2017-09-07 18:56:24 +02:00
|
|
|
for multiprocessing in (False, True):
|
2019-04-26 04:08:53 +02:00
|
|
|
with self.subTest(multiprocessing=multiprocessing):
|
|
|
|
|
if multiprocessing:
|
|
|
|
|
args = ("--slowest", "-j2", test)
|
|
|
|
|
else:
|
|
|
|
|
args = ("--slowest", test)
|
[3.11] gh-108822: Backport libregrtest changes from the main branch (#108820)
* Revert "[3.11] gh-101634: regrtest reports decoding error as failed test (#106169) (#106175)"
This reverts commit d5418e97fc524420011a370ba3c2c3cf6a89a74f.
* Revert "[3.11] bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (GH-30895) (GH-103342)"
This reverts commit ecb09a849689764193e0115d27e220f82b5f6d9f.
* Revert "gh-95027: Fix regrtest stdout encoding on Windows (GH-98492)"
This reverts commit b2aa28eec56d07b9c6777b02b7247cf21839de9f.
* Revert "[3.11] gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253) (GH-94408)"
This reverts commit 0122ab235b5acb52dd99fd05d8802a00f438b828.
* Revert "Run Tools/scripts/reindent.py (GH-94225)"
This reverts commit f0f3a424afb00a15ce8c0140dd218f5b33929be6.
* Revert "gh-94052: Don't re-run failed tests with --python option (GH-94054)"
This reverts commit 1347607db12012f6458ffcba48d8ad797083812e.
* Revert "[3.11] gh-84461: Fix Emscripten umask and permission issues (GH-94002) (GH-94006)"
This reverts commit 10731849184a3101ed18683b0128d689f1671c3f.
* gh-93353: regrtest checks for leaked temporary files (#93776)
When running tests with -jN, create a temporary directory per process
and mark a test as "environment changed" if a test leaks a temporary
file or directory.
(cherry picked from commit e566ce5496f1bad81c431aaee65e36d5e44771c5)
* gh-93353: Fix regrtest for -jN with N >= 2 (GH-93813)
(cherry picked from commit 36934a16e86f34d69ba2d41630fb5b4d06d59cff)
* gh-93353: regrtest supports checking tmp files with -j2 (#93909)
regrtest now also implements checking for leaked temporary files and
directories when using -jN for N >= 2. Use tempfile.mkdtemp() to
create the temporary directory. Skip this check on WASI.
(cherry picked from commit 4f85cec9e2077681b3dacc3108e646d509b720bf)
* gh-84461: Fix Emscripten umask and permission issues (GH-94002)
- Emscripten's default umask is too strict, see
https://github.com/emscripten-core/emscripten/issues/17269
- getuid/getgid and geteuid/getegid are stubs that always return 0
(root). Disable effective uid/gid syscalls and fix tests that use
chmod() current user.
- Cannot drop X bit from directory.
(cherry picked from commit 2702e408fd0e0dd7aec396b4cf8c7ce9caae81d8)
* gh-94052: Don't re-run failed tests with --python option (#94054)
(cherry picked from commit 0ff7b996f5d836e63cdaf652c7aa734285261096)
* Run Tools/scripts/reindent.py (#94225)
Reindent files which were not properly formatted (PEP 8: 4 spaces).
Remove also some trailing spaces.
(cherry picked from commit e87ada48a9e5d9d03f9759138869216df0d7383a)
* gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253)
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 199ba233248ab279f445e0809c2077976f0711bc)
* gh-96465: Clear fractions hash lru_cache under refleak testing (GH-96689)
Automerge-Triggered-By: GH:zware
(cherry picked from commit 9c8f3794337457b1d905a9fa0f38c2978fe32abd)
* gh-95027: Fix regrtest stdout encoding on Windows (#98492)
On Windows, when the Python test suite is run with the -jN option,
the ANSI code page is now used as the encoding for the stdout
temporary file, rather than using UTF-8 which can lead to decoding
errors.
(cherry picked from commit ec1f6f5f139868dc2c1116a7c7c878c38c668d53)
* gh-98903: Test suite fails with exit code 4 if no tests ran (#98904)
The Python test suite now fails wit exit code 4 if no tests ran. It
should help detecting typos in test names and test methods.
* Add "EXITCODE_" constants to Lib/test/libregrtest/main.py.
* Fix a typo: "NO TEST RUN" becomes "NO TESTS RAN"
(cherry picked from commit c76db37c0d23174cbffd6fa978d39693890ef020)
* gh-100086: Add build info to test.libregrtest (#100093)
The Python test runner (libregrtest) now logs Python build information like
"debug" vs "release" build, or LTO and PGO optimizations.
(cherry picked from commit 3c892022472eb975360fb3f0caa6f6fcc6fbf220)
* bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (#30895)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
(cherry picked from commit 995386071f96e4cfebfa027a71ca9134e4651d2a)
* gh-82054: allow test runner to split test_asyncio to execute in parallel by sharding. (#103927)
This runs test_asyncio sub-tests in parallel using sharding from Cinder. This suite is typically the longest-pole in runs because it is a test package with a lot of further sub-tests otherwise run serially. By breaking out the sub-tests as independent modules we can run a lot more in parallel.
After porting we can see the direct impact on a multicore system.
Without this change:
Running make test is 5 min 26 seconds
With this change:
Running make test takes 3 min 39 seconds
That'll vary based on system and parallelism. On a `-j 4` run similar to what CI and buildbot systems often do, it reduced the overall test suite completion latency by 10%.
The drawbacks are that this implementation is hacky and due to the sorting of the tests it obscures when the asyncio tests occur and involves changing CPython test infrastructure but, the wall time saved it is worth it, especially in low-core count CI runs as it pulls a long tail. The win for productivity and reserved CI resource usage is significant.
Future tests that deserve to be refactored into split up suites to benefit from are test_concurrent_futures and the way the _test_multiprocessing suite gets run for all start methods. As exposed by passing the -o flag to python -m test to get a list of the 10 longest running tests.
---------
Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google, LLC]
(cherry picked from commit 9e011e7c77dad7d0bbb944c44891531606caeb21)
* Display the sanitizer config in the regrtest header. (#105301)
Display the sanitizers present in libregrtest.
Having this in the CI output for tests with the relevant environment
variable displayed will help make it easier to do what we need to
create an equivalent local test run.
(cherry picked from commit 852348ab65783601e0844b6647ea033668b45c11)
* gh-101634: regrtest reports decoding error as failed test (#106169)
When running the Python test suite with -jN option, if a worker stdout
cannot be decoded from the locale encoding report a failed testn so the
exitcode is non-zero.
(cherry picked from commit 2ac3eec103cf450aaaebeb932e51155d2e7fb37b)
* gh-108223: test.pythoninfo and libregrtest log Py_NOGIL (#108238)
Enable with --disable-gil --without-pydebug:
$ make pythoninfo|grep NOGIL
sysconfig[Py_NOGIL]: 1
$ ./python -m test
...
== Python build: nogil debug
...
(cherry picked from commit 5afe0c17ca14df430736e549542a4b85e7e7c7ac)
* gh-90791: test.pythoninfo logs ASAN_OPTIONS env var (#108289)
* Cleanup libregrtest code logging ASAN_OPTIONS.
* Fix a typo on "ASAN_OPTIONS" vs "MSAN_OPTIONS".
(cherry picked from commit 3a1ac87f8f89d3206b46a0df4908afae629d669d)
* gh-108388: regrtest splits test_asyncio package (#108393)
Currently, test_asyncio package is only splitted into sub-tests when
using command "./python -m test". With this change, it's also
splitted when passing it on the command line:
"./python -m test test_asyncio".
Remove the concept of "STDTESTS". Python is now mature enough to not
have to bother with that anymore. Removing STDTESTS simplify the
code.
(cherry picked from commit 174e9da0836844a2138cc8915dd305cb2cd7a583)
* regrtest computes statistics (#108793)
test_netrc, test_pep646_syntax and test_xml_etree now return results
in the test_main() function.
Changes:
* Rewrite TestResult as a dataclass with a new State class.
* Add test.support.TestStats class and Regrtest.stats_dict attribute.
* libregrtest.runtest functions now modify a TestResult instance
in-place.
* libregrtest summary lists the number of run tests and skipped
tests, and denied resources.
* Add TestResult.has_meaningful_duration() method.
* Compute TestResult duration in the upper function.
* Use time.perf_counter() instead of time.monotonic().
* Regrtest: rename 'resource_denieds' attribute to 'resource_denied'.
* Rename CHILD_ERROR to MULTIPROCESSING_ERROR.
* Use match/case syntadx to have different code depending on the
test state.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit d4e534cbb35678c82b3a1276826af55d7bfc23b6)
* gh-108822: Add Changelog entry for regrtest statistics (#108821)
---------
Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Zachary Ware <zach@python.org>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Joshua Herman <zitterbewegung@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-09-03 19:21:53 +02:00
|
|
|
output = self.run_tests(*args, exitcode=EXITCODE_INTERRUPTED)
|
2019-04-26 04:08:53 +02:00
|
|
|
self.check_executed_tests(output, test,
|
[3.11] gh-108822: Backport libregrtest changes from the main branch (#108820)
* Revert "[3.11] gh-101634: regrtest reports decoding error as failed test (#106169) (#106175)"
This reverts commit d5418e97fc524420011a370ba3c2c3cf6a89a74f.
* Revert "[3.11] bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (GH-30895) (GH-103342)"
This reverts commit ecb09a849689764193e0115d27e220f82b5f6d9f.
* Revert "gh-95027: Fix regrtest stdout encoding on Windows (GH-98492)"
This reverts commit b2aa28eec56d07b9c6777b02b7247cf21839de9f.
* Revert "[3.11] gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253) (GH-94408)"
This reverts commit 0122ab235b5acb52dd99fd05d8802a00f438b828.
* Revert "Run Tools/scripts/reindent.py (GH-94225)"
This reverts commit f0f3a424afb00a15ce8c0140dd218f5b33929be6.
* Revert "gh-94052: Don't re-run failed tests with --python option (GH-94054)"
This reverts commit 1347607db12012f6458ffcba48d8ad797083812e.
* Revert "[3.11] gh-84461: Fix Emscripten umask and permission issues (GH-94002) (GH-94006)"
This reverts commit 10731849184a3101ed18683b0128d689f1671c3f.
* gh-93353: regrtest checks for leaked temporary files (#93776)
When running tests with -jN, create a temporary directory per process
and mark a test as "environment changed" if a test leaks a temporary
file or directory.
(cherry picked from commit e566ce5496f1bad81c431aaee65e36d5e44771c5)
* gh-93353: Fix regrtest for -jN with N >= 2 (GH-93813)
(cherry picked from commit 36934a16e86f34d69ba2d41630fb5b4d06d59cff)
* gh-93353: regrtest supports checking tmp files with -j2 (#93909)
regrtest now also implements checking for leaked temporary files and
directories when using -jN for N >= 2. Use tempfile.mkdtemp() to
create the temporary directory. Skip this check on WASI.
(cherry picked from commit 4f85cec9e2077681b3dacc3108e646d509b720bf)
* gh-84461: Fix Emscripten umask and permission issues (GH-94002)
- Emscripten's default umask is too strict, see
https://github.com/emscripten-core/emscripten/issues/17269
- getuid/getgid and geteuid/getegid are stubs that always return 0
(root). Disable effective uid/gid syscalls and fix tests that use
chmod() current user.
- Cannot drop X bit from directory.
(cherry picked from commit 2702e408fd0e0dd7aec396b4cf8c7ce9caae81d8)
* gh-94052: Don't re-run failed tests with --python option (#94054)
(cherry picked from commit 0ff7b996f5d836e63cdaf652c7aa734285261096)
* Run Tools/scripts/reindent.py (#94225)
Reindent files which were not properly formatted (PEP 8: 4 spaces).
Remove also some trailing spaces.
(cherry picked from commit e87ada48a9e5d9d03f9759138869216df0d7383a)
* gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253)
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 199ba233248ab279f445e0809c2077976f0711bc)
* gh-96465: Clear fractions hash lru_cache under refleak testing (GH-96689)
Automerge-Triggered-By: GH:zware
(cherry picked from commit 9c8f3794337457b1d905a9fa0f38c2978fe32abd)
* gh-95027: Fix regrtest stdout encoding on Windows (#98492)
On Windows, when the Python test suite is run with the -jN option,
the ANSI code page is now used as the encoding for the stdout
temporary file, rather than using UTF-8 which can lead to decoding
errors.
(cherry picked from commit ec1f6f5f139868dc2c1116a7c7c878c38c668d53)
* gh-98903: Test suite fails with exit code 4 if no tests ran (#98904)
The Python test suite now fails wit exit code 4 if no tests ran. It
should help detecting typos in test names and test methods.
* Add "EXITCODE_" constants to Lib/test/libregrtest/main.py.
* Fix a typo: "NO TEST RUN" becomes "NO TESTS RAN"
(cherry picked from commit c76db37c0d23174cbffd6fa978d39693890ef020)
* gh-100086: Add build info to test.libregrtest (#100093)
The Python test runner (libregrtest) now logs Python build information like
"debug" vs "release" build, or LTO and PGO optimizations.
(cherry picked from commit 3c892022472eb975360fb3f0caa6f6fcc6fbf220)
* bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (#30895)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
(cherry picked from commit 995386071f96e4cfebfa027a71ca9134e4651d2a)
* gh-82054: allow test runner to split test_asyncio to execute in parallel by sharding. (#103927)
This runs test_asyncio sub-tests in parallel using sharding from Cinder. This suite is typically the longest-pole in runs because it is a test package with a lot of further sub-tests otherwise run serially. By breaking out the sub-tests as independent modules we can run a lot more in parallel.
After porting we can see the direct impact on a multicore system.
Without this change:
Running make test is 5 min 26 seconds
With this change:
Running make test takes 3 min 39 seconds
That'll vary based on system and parallelism. On a `-j 4` run similar to what CI and buildbot systems often do, it reduced the overall test suite completion latency by 10%.
The drawbacks are that this implementation is hacky and due to the sorting of the tests it obscures when the asyncio tests occur and involves changing CPython test infrastructure but, the wall time saved it is worth it, especially in low-core count CI runs as it pulls a long tail. The win for productivity and reserved CI resource usage is significant.
Future tests that deserve to be refactored into split up suites to benefit from are test_concurrent_futures and the way the _test_multiprocessing suite gets run for all start methods. As exposed by passing the -o flag to python -m test to get a list of the 10 longest running tests.
---------
Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google, LLC]
(cherry picked from commit 9e011e7c77dad7d0bbb944c44891531606caeb21)
* Display the sanitizer config in the regrtest header. (#105301)
Display the sanitizers present in libregrtest.
Having this in the CI output for tests with the relevant environment
variable displayed will help make it easier to do what we need to
create an equivalent local test run.
(cherry picked from commit 852348ab65783601e0844b6647ea033668b45c11)
* gh-101634: regrtest reports decoding error as failed test (#106169)
When running the Python test suite with -jN option, if a worker stdout
cannot be decoded from the locale encoding report a failed testn so the
exitcode is non-zero.
(cherry picked from commit 2ac3eec103cf450aaaebeb932e51155d2e7fb37b)
* gh-108223: test.pythoninfo and libregrtest log Py_NOGIL (#108238)
Enable with --disable-gil --without-pydebug:
$ make pythoninfo|grep NOGIL
sysconfig[Py_NOGIL]: 1
$ ./python -m test
...
== Python build: nogil debug
...
(cherry picked from commit 5afe0c17ca14df430736e549542a4b85e7e7c7ac)
* gh-90791: test.pythoninfo logs ASAN_OPTIONS env var (#108289)
* Cleanup libregrtest code logging ASAN_OPTIONS.
* Fix a typo on "ASAN_OPTIONS" vs "MSAN_OPTIONS".
(cherry picked from commit 3a1ac87f8f89d3206b46a0df4908afae629d669d)
* gh-108388: regrtest splits test_asyncio package (#108393)
Currently, test_asyncio package is only splitted into sub-tests when
using command "./python -m test". With this change, it's also
splitted when passing it on the command line:
"./python -m test test_asyncio".
Remove the concept of "STDTESTS". Python is now mature enough to not
have to bother with that anymore. Removing STDTESTS simplify the
code.
(cherry picked from commit 174e9da0836844a2138cc8915dd305cb2cd7a583)
* regrtest computes statistics (#108793)
test_netrc, test_pep646_syntax and test_xml_etree now return results
in the test_main() function.
Changes:
* Rewrite TestResult as a dataclass with a new State class.
* Add test.support.TestStats class and Regrtest.stats_dict attribute.
* libregrtest.runtest functions now modify a TestResult instance
in-place.
* libregrtest summary lists the number of run tests and skipped
tests, and denied resources.
* Add TestResult.has_meaningful_duration() method.
* Compute TestResult duration in the upper function.
* Use time.perf_counter() instead of time.monotonic().
* Regrtest: rename 'resource_denieds' attribute to 'resource_denied'.
* Rename CHILD_ERROR to MULTIPROCESSING_ERROR.
* Use match/case syntadx to have different code depending on the
test state.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit d4e534cbb35678c82b3a1276826af55d7bfc23b6)
* gh-108822: Add Changelog entry for regrtest statistics (#108821)
---------
Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Zachary Ware <zach@python.org>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Joshua Herman <zitterbewegung@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-09-03 19:21:53 +02:00
|
|
|
omitted=test, interrupted=True,
|
|
|
|
|
stats=0)
|
2019-04-26 04:08:53 +02:00
|
|
|
|
|
|
|
|
regex = ('10 slowest tests:\n')
|
|
|
|
|
self.check_line(output, regex)
|
2015-10-11 10:37:25 +02:00
|
|
|
|
2015-09-28 23:16:17 +02:00
|
|
|
def test_coverage(self):
|
|
|
|
|
# test --coverage
|
2016-03-30 02:33:52 +02:00
|
|
|
test = self.create_test('coverage')
|
2015-09-28 23:16:17 +02:00
|
|
|
output = self.run_tests("--coverage", test)
|
[3.11] gh-108822: Backport libregrtest changes from the main branch (#108820)
* Revert "[3.11] gh-101634: regrtest reports decoding error as failed test (#106169) (#106175)"
This reverts commit d5418e97fc524420011a370ba3c2c3cf6a89a74f.
* Revert "[3.11] bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (GH-30895) (GH-103342)"
This reverts commit ecb09a849689764193e0115d27e220f82b5f6d9f.
* Revert "gh-95027: Fix regrtest stdout encoding on Windows (GH-98492)"
This reverts commit b2aa28eec56d07b9c6777b02b7247cf21839de9f.
* Revert "[3.11] gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253) (GH-94408)"
This reverts commit 0122ab235b5acb52dd99fd05d8802a00f438b828.
* Revert "Run Tools/scripts/reindent.py (GH-94225)"
This reverts commit f0f3a424afb00a15ce8c0140dd218f5b33929be6.
* Revert "gh-94052: Don't re-run failed tests with --python option (GH-94054)"
This reverts commit 1347607db12012f6458ffcba48d8ad797083812e.
* Revert "[3.11] gh-84461: Fix Emscripten umask and permission issues (GH-94002) (GH-94006)"
This reverts commit 10731849184a3101ed18683b0128d689f1671c3f.
* gh-93353: regrtest checks for leaked temporary files (#93776)
When running tests with -jN, create a temporary directory per process
and mark a test as "environment changed" if a test leaks a temporary
file or directory.
(cherry picked from commit e566ce5496f1bad81c431aaee65e36d5e44771c5)
* gh-93353: Fix regrtest for -jN with N >= 2 (GH-93813)
(cherry picked from commit 36934a16e86f34d69ba2d41630fb5b4d06d59cff)
* gh-93353: regrtest supports checking tmp files with -j2 (#93909)
regrtest now also implements checking for leaked temporary files and
directories when using -jN for N >= 2. Use tempfile.mkdtemp() to
create the temporary directory. Skip this check on WASI.
(cherry picked from commit 4f85cec9e2077681b3dacc3108e646d509b720bf)
* gh-84461: Fix Emscripten umask and permission issues (GH-94002)
- Emscripten's default umask is too strict, see
https://github.com/emscripten-core/emscripten/issues/17269
- getuid/getgid and geteuid/getegid are stubs that always return 0
(root). Disable effective uid/gid syscalls and fix tests that use
chmod() current user.
- Cannot drop X bit from directory.
(cherry picked from commit 2702e408fd0e0dd7aec396b4cf8c7ce9caae81d8)
* gh-94052: Don't re-run failed tests with --python option (#94054)
(cherry picked from commit 0ff7b996f5d836e63cdaf652c7aa734285261096)
* Run Tools/scripts/reindent.py (#94225)
Reindent files which were not properly formatted (PEP 8: 4 spaces).
Remove also some trailing spaces.
(cherry picked from commit e87ada48a9e5d9d03f9759138869216df0d7383a)
* gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253)
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 199ba233248ab279f445e0809c2077976f0711bc)
* gh-96465: Clear fractions hash lru_cache under refleak testing (GH-96689)
Automerge-Triggered-By: GH:zware
(cherry picked from commit 9c8f3794337457b1d905a9fa0f38c2978fe32abd)
* gh-95027: Fix regrtest stdout encoding on Windows (#98492)
On Windows, when the Python test suite is run with the -jN option,
the ANSI code page is now used as the encoding for the stdout
temporary file, rather than using UTF-8 which can lead to decoding
errors.
(cherry picked from commit ec1f6f5f139868dc2c1116a7c7c878c38c668d53)
* gh-98903: Test suite fails with exit code 4 if no tests ran (#98904)
The Python test suite now fails wit exit code 4 if no tests ran. It
should help detecting typos in test names and test methods.
* Add "EXITCODE_" constants to Lib/test/libregrtest/main.py.
* Fix a typo: "NO TEST RUN" becomes "NO TESTS RAN"
(cherry picked from commit c76db37c0d23174cbffd6fa978d39693890ef020)
* gh-100086: Add build info to test.libregrtest (#100093)
The Python test runner (libregrtest) now logs Python build information like
"debug" vs "release" build, or LTO and PGO optimizations.
(cherry picked from commit 3c892022472eb975360fb3f0caa6f6fcc6fbf220)
* bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (#30895)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
(cherry picked from commit 995386071f96e4cfebfa027a71ca9134e4651d2a)
* gh-82054: allow test runner to split test_asyncio to execute in parallel by sharding. (#103927)
This runs test_asyncio sub-tests in parallel using sharding from Cinder. This suite is typically the longest-pole in runs because it is a test package with a lot of further sub-tests otherwise run serially. By breaking out the sub-tests as independent modules we can run a lot more in parallel.
After porting we can see the direct impact on a multicore system.
Without this change:
Running make test is 5 min 26 seconds
With this change:
Running make test takes 3 min 39 seconds
That'll vary based on system and parallelism. On a `-j 4` run similar to what CI and buildbot systems often do, it reduced the overall test suite completion latency by 10%.
The drawbacks are that this implementation is hacky and due to the sorting of the tests it obscures when the asyncio tests occur and involves changing CPython test infrastructure but, the wall time saved it is worth it, especially in low-core count CI runs as it pulls a long tail. The win for productivity and reserved CI resource usage is significant.
Future tests that deserve to be refactored into split up suites to benefit from are test_concurrent_futures and the way the _test_multiprocessing suite gets run for all start methods. As exposed by passing the -o flag to python -m test to get a list of the 10 longest running tests.
---------
Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google, LLC]
(cherry picked from commit 9e011e7c77dad7d0bbb944c44891531606caeb21)
* Display the sanitizer config in the regrtest header. (#105301)
Display the sanitizers present in libregrtest.
Having this in the CI output for tests with the relevant environment
variable displayed will help make it easier to do what we need to
create an equivalent local test run.
(cherry picked from commit 852348ab65783601e0844b6647ea033668b45c11)
* gh-101634: regrtest reports decoding error as failed test (#106169)
When running the Python test suite with -jN option, if a worker stdout
cannot be decoded from the locale encoding report a failed testn so the
exitcode is non-zero.
(cherry picked from commit 2ac3eec103cf450aaaebeb932e51155d2e7fb37b)
* gh-108223: test.pythoninfo and libregrtest log Py_NOGIL (#108238)
Enable with --disable-gil --without-pydebug:
$ make pythoninfo|grep NOGIL
sysconfig[Py_NOGIL]: 1
$ ./python -m test
...
== Python build: nogil debug
...
(cherry picked from commit 5afe0c17ca14df430736e549542a4b85e7e7c7ac)
* gh-90791: test.pythoninfo logs ASAN_OPTIONS env var (#108289)
* Cleanup libregrtest code logging ASAN_OPTIONS.
* Fix a typo on "ASAN_OPTIONS" vs "MSAN_OPTIONS".
(cherry picked from commit 3a1ac87f8f89d3206b46a0df4908afae629d669d)
* gh-108388: regrtest splits test_asyncio package (#108393)
Currently, test_asyncio package is only splitted into sub-tests when
using command "./python -m test". With this change, it's also
splitted when passing it on the command line:
"./python -m test test_asyncio".
Remove the concept of "STDTESTS". Python is now mature enough to not
have to bother with that anymore. Removing STDTESTS simplify the
code.
(cherry picked from commit 174e9da0836844a2138cc8915dd305cb2cd7a583)
* regrtest computes statistics (#108793)
test_netrc, test_pep646_syntax and test_xml_etree now return results
in the test_main() function.
Changes:
* Rewrite TestResult as a dataclass with a new State class.
* Add test.support.TestStats class and Regrtest.stats_dict attribute.
* libregrtest.runtest functions now modify a TestResult instance
in-place.
* libregrtest summary lists the number of run tests and skipped
tests, and denied resources.
* Add TestResult.has_meaningful_duration() method.
* Compute TestResult duration in the upper function.
* Use time.perf_counter() instead of time.monotonic().
* Regrtest: rename 'resource_denieds' attribute to 'resource_denied'.
* Rename CHILD_ERROR to MULTIPROCESSING_ERROR.
* Use match/case syntadx to have different code depending on the
test state.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit d4e534cbb35678c82b3a1276826af55d7bfc23b6)
* gh-108822: Add Changelog entry for regrtest statistics (#108821)
---------
Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Zachary Ware <zach@python.org>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Joshua Herman <zitterbewegung@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-09-03 19:21:53 +02:00
|
|
|
self.check_executed_tests(output, [test], stats=1)
|
2016-09-08 13:59:53 -04:00
|
|
|
regex = (r'lines +cov% +module +\(path\)\n'
|
|
|
|
|
r'(?: *[0-9]+ *[0-9]{1,2}% *[^ ]+ +\([^)]+\)+)+')
|
2015-09-28 23:16:17 +02:00
|
|
|
self.check_line(output, regex)
|
|
|
|
|
|
2015-09-29 14:17:09 +02:00
|
|
|
def test_wait(self):
|
|
|
|
|
# test --wait
|
2016-03-30 02:33:52 +02:00
|
|
|
test = self.create_test('wait')
|
2015-09-29 14:17:09 +02:00
|
|
|
output = self.run_tests("--wait", test, input='key')
|
|
|
|
|
self.check_line(output, 'Press any key to continue')
|
|
|
|
|
|
2015-09-30 13:51:17 +02:00
|
|
|
def test_forever(self):
|
|
|
|
|
# test --forever
|
|
|
|
|
code = textwrap.dedent("""
|
2016-03-30 02:33:52 +02:00
|
|
|
import builtins
|
2015-09-30 13:51:17 +02:00
|
|
|
import unittest
|
|
|
|
|
|
|
|
|
|
class ForeverTester(unittest.TestCase):
|
|
|
|
|
def test_run(self):
|
2016-03-30 02:33:52 +02:00
|
|
|
# Store the state in the builtins module, because the test
|
|
|
|
|
# module is reload at each run
|
|
|
|
|
if 'RUN' in builtins.__dict__:
|
|
|
|
|
builtins.__dict__['RUN'] += 1
|
|
|
|
|
if builtins.__dict__['RUN'] >= 3:
|
|
|
|
|
self.fail("fail at the 3rd runs")
|
|
|
|
|
else:
|
|
|
|
|
builtins.__dict__['RUN'] = 1
|
2015-09-30 13:51:17 +02:00
|
|
|
""")
|
2016-03-30 02:33:52 +02:00
|
|
|
test = self.create_test('forever', code=code)
|
[3.11] gh-108822: Backport libregrtest changes from the main branch (#108820)
* Revert "[3.11] gh-101634: regrtest reports decoding error as failed test (#106169) (#106175)"
This reverts commit d5418e97fc524420011a370ba3c2c3cf6a89a74f.
* Revert "[3.11] bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (GH-30895) (GH-103342)"
This reverts commit ecb09a849689764193e0115d27e220f82b5f6d9f.
* Revert "gh-95027: Fix regrtest stdout encoding on Windows (GH-98492)"
This reverts commit b2aa28eec56d07b9c6777b02b7247cf21839de9f.
* Revert "[3.11] gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253) (GH-94408)"
This reverts commit 0122ab235b5acb52dd99fd05d8802a00f438b828.
* Revert "Run Tools/scripts/reindent.py (GH-94225)"
This reverts commit f0f3a424afb00a15ce8c0140dd218f5b33929be6.
* Revert "gh-94052: Don't re-run failed tests with --python option (GH-94054)"
This reverts commit 1347607db12012f6458ffcba48d8ad797083812e.
* Revert "[3.11] gh-84461: Fix Emscripten umask and permission issues (GH-94002) (GH-94006)"
This reverts commit 10731849184a3101ed18683b0128d689f1671c3f.
* gh-93353: regrtest checks for leaked temporary files (#93776)
When running tests with -jN, create a temporary directory per process
and mark a test as "environment changed" if a test leaks a temporary
file or directory.
(cherry picked from commit e566ce5496f1bad81c431aaee65e36d5e44771c5)
* gh-93353: Fix regrtest for -jN with N >= 2 (GH-93813)
(cherry picked from commit 36934a16e86f34d69ba2d41630fb5b4d06d59cff)
* gh-93353: regrtest supports checking tmp files with -j2 (#93909)
regrtest now also implements checking for leaked temporary files and
directories when using -jN for N >= 2. Use tempfile.mkdtemp() to
create the temporary directory. Skip this check on WASI.
(cherry picked from commit 4f85cec9e2077681b3dacc3108e646d509b720bf)
* gh-84461: Fix Emscripten umask and permission issues (GH-94002)
- Emscripten's default umask is too strict, see
https://github.com/emscripten-core/emscripten/issues/17269
- getuid/getgid and geteuid/getegid are stubs that always return 0
(root). Disable effective uid/gid syscalls and fix tests that use
chmod() current user.
- Cannot drop X bit from directory.
(cherry picked from commit 2702e408fd0e0dd7aec396b4cf8c7ce9caae81d8)
* gh-94052: Don't re-run failed tests with --python option (#94054)
(cherry picked from commit 0ff7b996f5d836e63cdaf652c7aa734285261096)
* Run Tools/scripts/reindent.py (#94225)
Reindent files which were not properly formatted (PEP 8: 4 spaces).
Remove also some trailing spaces.
(cherry picked from commit e87ada48a9e5d9d03f9759138869216df0d7383a)
* gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253)
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 199ba233248ab279f445e0809c2077976f0711bc)
* gh-96465: Clear fractions hash lru_cache under refleak testing (GH-96689)
Automerge-Triggered-By: GH:zware
(cherry picked from commit 9c8f3794337457b1d905a9fa0f38c2978fe32abd)
* gh-95027: Fix regrtest stdout encoding on Windows (#98492)
On Windows, when the Python test suite is run with the -jN option,
the ANSI code page is now used as the encoding for the stdout
temporary file, rather than using UTF-8 which can lead to decoding
errors.
(cherry picked from commit ec1f6f5f139868dc2c1116a7c7c878c38c668d53)
* gh-98903: Test suite fails with exit code 4 if no tests ran (#98904)
The Python test suite now fails wit exit code 4 if no tests ran. It
should help detecting typos in test names and test methods.
* Add "EXITCODE_" constants to Lib/test/libregrtest/main.py.
* Fix a typo: "NO TEST RUN" becomes "NO TESTS RAN"
(cherry picked from commit c76db37c0d23174cbffd6fa978d39693890ef020)
* gh-100086: Add build info to test.libregrtest (#100093)
The Python test runner (libregrtest) now logs Python build information like
"debug" vs "release" build, or LTO and PGO optimizations.
(cherry picked from commit 3c892022472eb975360fb3f0caa6f6fcc6fbf220)
* bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (#30895)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
(cherry picked from commit 995386071f96e4cfebfa027a71ca9134e4651d2a)
* gh-82054: allow test runner to split test_asyncio to execute in parallel by sharding. (#103927)
This runs test_asyncio sub-tests in parallel using sharding from Cinder. This suite is typically the longest-pole in runs because it is a test package with a lot of further sub-tests otherwise run serially. By breaking out the sub-tests as independent modules we can run a lot more in parallel.
After porting we can see the direct impact on a multicore system.
Without this change:
Running make test is 5 min 26 seconds
With this change:
Running make test takes 3 min 39 seconds
That'll vary based on system and parallelism. On a `-j 4` run similar to what CI and buildbot systems often do, it reduced the overall test suite completion latency by 10%.
The drawbacks are that this implementation is hacky and due to the sorting of the tests it obscures when the asyncio tests occur and involves changing CPython test infrastructure but, the wall time saved it is worth it, especially in low-core count CI runs as it pulls a long tail. The win for productivity and reserved CI resource usage is significant.
Future tests that deserve to be refactored into split up suites to benefit from are test_concurrent_futures and the way the _test_multiprocessing suite gets run for all start methods. As exposed by passing the -o flag to python -m test to get a list of the 10 longest running tests.
---------
Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google, LLC]
(cherry picked from commit 9e011e7c77dad7d0bbb944c44891531606caeb21)
* Display the sanitizer config in the regrtest header. (#105301)
Display the sanitizers present in libregrtest.
Having this in the CI output for tests with the relevant environment
variable displayed will help make it easier to do what we need to
create an equivalent local test run.
(cherry picked from commit 852348ab65783601e0844b6647ea033668b45c11)
* gh-101634: regrtest reports decoding error as failed test (#106169)
When running the Python test suite with -jN option, if a worker stdout
cannot be decoded from the locale encoding report a failed testn so the
exitcode is non-zero.
(cherry picked from commit 2ac3eec103cf450aaaebeb932e51155d2e7fb37b)
* gh-108223: test.pythoninfo and libregrtest log Py_NOGIL (#108238)
Enable with --disable-gil --without-pydebug:
$ make pythoninfo|grep NOGIL
sysconfig[Py_NOGIL]: 1
$ ./python -m test
...
== Python build: nogil debug
...
(cherry picked from commit 5afe0c17ca14df430736e549542a4b85e7e7c7ac)
* gh-90791: test.pythoninfo logs ASAN_OPTIONS env var (#108289)
* Cleanup libregrtest code logging ASAN_OPTIONS.
* Fix a typo on "ASAN_OPTIONS" vs "MSAN_OPTIONS".
(cherry picked from commit 3a1ac87f8f89d3206b46a0df4908afae629d669d)
* gh-108388: regrtest splits test_asyncio package (#108393)
Currently, test_asyncio package is only splitted into sub-tests when
using command "./python -m test". With this change, it's also
splitted when passing it on the command line:
"./python -m test test_asyncio".
Remove the concept of "STDTESTS". Python is now mature enough to not
have to bother with that anymore. Removing STDTESTS simplify the
code.
(cherry picked from commit 174e9da0836844a2138cc8915dd305cb2cd7a583)
* regrtest computes statistics (#108793)
test_netrc, test_pep646_syntax and test_xml_etree now return results
in the test_main() function.
Changes:
* Rewrite TestResult as a dataclass with a new State class.
* Add test.support.TestStats class and Regrtest.stats_dict attribute.
* libregrtest.runtest functions now modify a TestResult instance
in-place.
* libregrtest summary lists the number of run tests and skipped
tests, and denied resources.
* Add TestResult.has_meaningful_duration() method.
* Compute TestResult duration in the upper function.
* Use time.perf_counter() instead of time.monotonic().
* Regrtest: rename 'resource_denieds' attribute to 'resource_denied'.
* Rename CHILD_ERROR to MULTIPROCESSING_ERROR.
* Use match/case syntadx to have different code depending on the
test state.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit d4e534cbb35678c82b3a1276826af55d7bfc23b6)
* gh-108822: Add Changelog entry for regrtest statistics (#108821)
---------
Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Zachary Ware <zach@python.org>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Joshua Herman <zitterbewegung@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-09-03 19:21:53 +02:00
|
|
|
output = self.run_tests('--forever', test, exitcode=EXITCODE_BAD_TEST)
|
|
|
|
|
self.check_executed_tests(output, [test]*3, failed=test,
|
|
|
|
|
stats=TestStats(1, 1))
|
2015-09-30 13:51:17 +02:00
|
|
|
|
2017-06-27 02:02:04 +02:00
|
|
|
def check_leak(self, code, what):
|
|
|
|
|
test = self.create_test('huntrleaks', code=code)
|
|
|
|
|
|
|
|
|
|
filename = 'reflog.txt'
|
2020-06-30 21:46:06 +08:00
|
|
|
self.addCleanup(os_helper.unlink, filename)
|
2017-06-27 02:02:04 +02:00
|
|
|
output = self.run_tests('--huntrleaks', '3:3:', test,
|
[3.11] gh-108822: Backport libregrtest changes from the main branch (#108820)
* Revert "[3.11] gh-101634: regrtest reports decoding error as failed test (#106169) (#106175)"
This reverts commit d5418e97fc524420011a370ba3c2c3cf6a89a74f.
* Revert "[3.11] bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (GH-30895) (GH-103342)"
This reverts commit ecb09a849689764193e0115d27e220f82b5f6d9f.
* Revert "gh-95027: Fix regrtest stdout encoding on Windows (GH-98492)"
This reverts commit b2aa28eec56d07b9c6777b02b7247cf21839de9f.
* Revert "[3.11] gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253) (GH-94408)"
This reverts commit 0122ab235b5acb52dd99fd05d8802a00f438b828.
* Revert "Run Tools/scripts/reindent.py (GH-94225)"
This reverts commit f0f3a424afb00a15ce8c0140dd218f5b33929be6.
* Revert "gh-94052: Don't re-run failed tests with --python option (GH-94054)"
This reverts commit 1347607db12012f6458ffcba48d8ad797083812e.
* Revert "[3.11] gh-84461: Fix Emscripten umask and permission issues (GH-94002) (GH-94006)"
This reverts commit 10731849184a3101ed18683b0128d689f1671c3f.
* gh-93353: regrtest checks for leaked temporary files (#93776)
When running tests with -jN, create a temporary directory per process
and mark a test as "environment changed" if a test leaks a temporary
file or directory.
(cherry picked from commit e566ce5496f1bad81c431aaee65e36d5e44771c5)
* gh-93353: Fix regrtest for -jN with N >= 2 (GH-93813)
(cherry picked from commit 36934a16e86f34d69ba2d41630fb5b4d06d59cff)
* gh-93353: regrtest supports checking tmp files with -j2 (#93909)
regrtest now also implements checking for leaked temporary files and
directories when using -jN for N >= 2. Use tempfile.mkdtemp() to
create the temporary directory. Skip this check on WASI.
(cherry picked from commit 4f85cec9e2077681b3dacc3108e646d509b720bf)
* gh-84461: Fix Emscripten umask and permission issues (GH-94002)
- Emscripten's default umask is too strict, see
https://github.com/emscripten-core/emscripten/issues/17269
- getuid/getgid and geteuid/getegid are stubs that always return 0
(root). Disable effective uid/gid syscalls and fix tests that use
chmod() current user.
- Cannot drop X bit from directory.
(cherry picked from commit 2702e408fd0e0dd7aec396b4cf8c7ce9caae81d8)
* gh-94052: Don't re-run failed tests with --python option (#94054)
(cherry picked from commit 0ff7b996f5d836e63cdaf652c7aa734285261096)
* Run Tools/scripts/reindent.py (#94225)
Reindent files which were not properly formatted (PEP 8: 4 spaces).
Remove also some trailing spaces.
(cherry picked from commit e87ada48a9e5d9d03f9759138869216df0d7383a)
* gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253)
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 199ba233248ab279f445e0809c2077976f0711bc)
* gh-96465: Clear fractions hash lru_cache under refleak testing (GH-96689)
Automerge-Triggered-By: GH:zware
(cherry picked from commit 9c8f3794337457b1d905a9fa0f38c2978fe32abd)
* gh-95027: Fix regrtest stdout encoding on Windows (#98492)
On Windows, when the Python test suite is run with the -jN option,
the ANSI code page is now used as the encoding for the stdout
temporary file, rather than using UTF-8 which can lead to decoding
errors.
(cherry picked from commit ec1f6f5f139868dc2c1116a7c7c878c38c668d53)
* gh-98903: Test suite fails with exit code 4 if no tests ran (#98904)
The Python test suite now fails wit exit code 4 if no tests ran. It
should help detecting typos in test names and test methods.
* Add "EXITCODE_" constants to Lib/test/libregrtest/main.py.
* Fix a typo: "NO TEST RUN" becomes "NO TESTS RAN"
(cherry picked from commit c76db37c0d23174cbffd6fa978d39693890ef020)
* gh-100086: Add build info to test.libregrtest (#100093)
The Python test runner (libregrtest) now logs Python build information like
"debug" vs "release" build, or LTO and PGO optimizations.
(cherry picked from commit 3c892022472eb975360fb3f0caa6f6fcc6fbf220)
* bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (#30895)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
(cherry picked from commit 995386071f96e4cfebfa027a71ca9134e4651d2a)
* gh-82054: allow test runner to split test_asyncio to execute in parallel by sharding. (#103927)
This runs test_asyncio sub-tests in parallel using sharding from Cinder. This suite is typically the longest-pole in runs because it is a test package with a lot of further sub-tests otherwise run serially. By breaking out the sub-tests as independent modules we can run a lot more in parallel.
After porting we can see the direct impact on a multicore system.
Without this change:
Running make test is 5 min 26 seconds
With this change:
Running make test takes 3 min 39 seconds
That'll vary based on system and parallelism. On a `-j 4` run similar to what CI and buildbot systems often do, it reduced the overall test suite completion latency by 10%.
The drawbacks are that this implementation is hacky and due to the sorting of the tests it obscures when the asyncio tests occur and involves changing CPython test infrastructure but, the wall time saved it is worth it, especially in low-core count CI runs as it pulls a long tail. The win for productivity and reserved CI resource usage is significant.
Future tests that deserve to be refactored into split up suites to benefit from are test_concurrent_futures and the way the _test_multiprocessing suite gets run for all start methods. As exposed by passing the -o flag to python -m test to get a list of the 10 longest running tests.
---------
Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google, LLC]
(cherry picked from commit 9e011e7c77dad7d0bbb944c44891531606caeb21)
* Display the sanitizer config in the regrtest header. (#105301)
Display the sanitizers present in libregrtest.
Having this in the CI output for tests with the relevant environment
variable displayed will help make it easier to do what we need to
create an equivalent local test run.
(cherry picked from commit 852348ab65783601e0844b6647ea033668b45c11)
* gh-101634: regrtest reports decoding error as failed test (#106169)
When running the Python test suite with -jN option, if a worker stdout
cannot be decoded from the locale encoding report a failed testn so the
exitcode is non-zero.
(cherry picked from commit 2ac3eec103cf450aaaebeb932e51155d2e7fb37b)
* gh-108223: test.pythoninfo and libregrtest log Py_NOGIL (#108238)
Enable with --disable-gil --without-pydebug:
$ make pythoninfo|grep NOGIL
sysconfig[Py_NOGIL]: 1
$ ./python -m test
...
== Python build: nogil debug
...
(cherry picked from commit 5afe0c17ca14df430736e549542a4b85e7e7c7ac)
* gh-90791: test.pythoninfo logs ASAN_OPTIONS env var (#108289)
* Cleanup libregrtest code logging ASAN_OPTIONS.
* Fix a typo on "ASAN_OPTIONS" vs "MSAN_OPTIONS".
(cherry picked from commit 3a1ac87f8f89d3206b46a0df4908afae629d669d)
* gh-108388: regrtest splits test_asyncio package (#108393)
Currently, test_asyncio package is only splitted into sub-tests when
using command "./python -m test". With this change, it's also
splitted when passing it on the command line:
"./python -m test test_asyncio".
Remove the concept of "STDTESTS". Python is now mature enough to not
have to bother with that anymore. Removing STDTESTS simplify the
code.
(cherry picked from commit 174e9da0836844a2138cc8915dd305cb2cd7a583)
* regrtest computes statistics (#108793)
test_netrc, test_pep646_syntax and test_xml_etree now return results
in the test_main() function.
Changes:
* Rewrite TestResult as a dataclass with a new State class.
* Add test.support.TestStats class and Regrtest.stats_dict attribute.
* libregrtest.runtest functions now modify a TestResult instance
in-place.
* libregrtest summary lists the number of run tests and skipped
tests, and denied resources.
* Add TestResult.has_meaningful_duration() method.
* Compute TestResult duration in the upper function.
* Use time.perf_counter() instead of time.monotonic().
* Regrtest: rename 'resource_denieds' attribute to 'resource_denied'.
* Rename CHILD_ERROR to MULTIPROCESSING_ERROR.
* Use match/case syntadx to have different code depending on the
test state.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit d4e534cbb35678c82b3a1276826af55d7bfc23b6)
* gh-108822: Add Changelog entry for regrtest statistics (#108821)
---------
Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Zachary Ware <zach@python.org>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Joshua Herman <zitterbewegung@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-09-03 19:21:53 +02:00
|
|
|
exitcode=EXITCODE_BAD_TEST,
|
2017-06-27 02:02:04 +02:00
|
|
|
stderr=subprocess.STDOUT)
|
[3.11] gh-108822: Backport libregrtest changes from the main branch (#108820)
* Revert "[3.11] gh-101634: regrtest reports decoding error as failed test (#106169) (#106175)"
This reverts commit d5418e97fc524420011a370ba3c2c3cf6a89a74f.
* Revert "[3.11] bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (GH-30895) (GH-103342)"
This reverts commit ecb09a849689764193e0115d27e220f82b5f6d9f.
* Revert "gh-95027: Fix regrtest stdout encoding on Windows (GH-98492)"
This reverts commit b2aa28eec56d07b9c6777b02b7247cf21839de9f.
* Revert "[3.11] gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253) (GH-94408)"
This reverts commit 0122ab235b5acb52dd99fd05d8802a00f438b828.
* Revert "Run Tools/scripts/reindent.py (GH-94225)"
This reverts commit f0f3a424afb00a15ce8c0140dd218f5b33929be6.
* Revert "gh-94052: Don't re-run failed tests with --python option (GH-94054)"
This reverts commit 1347607db12012f6458ffcba48d8ad797083812e.
* Revert "[3.11] gh-84461: Fix Emscripten umask and permission issues (GH-94002) (GH-94006)"
This reverts commit 10731849184a3101ed18683b0128d689f1671c3f.
* gh-93353: regrtest checks for leaked temporary files (#93776)
When running tests with -jN, create a temporary directory per process
and mark a test as "environment changed" if a test leaks a temporary
file or directory.
(cherry picked from commit e566ce5496f1bad81c431aaee65e36d5e44771c5)
* gh-93353: Fix regrtest for -jN with N >= 2 (GH-93813)
(cherry picked from commit 36934a16e86f34d69ba2d41630fb5b4d06d59cff)
* gh-93353: regrtest supports checking tmp files with -j2 (#93909)
regrtest now also implements checking for leaked temporary files and
directories when using -jN for N >= 2. Use tempfile.mkdtemp() to
create the temporary directory. Skip this check on WASI.
(cherry picked from commit 4f85cec9e2077681b3dacc3108e646d509b720bf)
* gh-84461: Fix Emscripten umask and permission issues (GH-94002)
- Emscripten's default umask is too strict, see
https://github.com/emscripten-core/emscripten/issues/17269
- getuid/getgid and geteuid/getegid are stubs that always return 0
(root). Disable effective uid/gid syscalls and fix tests that use
chmod() current user.
- Cannot drop X bit from directory.
(cherry picked from commit 2702e408fd0e0dd7aec396b4cf8c7ce9caae81d8)
* gh-94052: Don't re-run failed tests with --python option (#94054)
(cherry picked from commit 0ff7b996f5d836e63cdaf652c7aa734285261096)
* Run Tools/scripts/reindent.py (#94225)
Reindent files which were not properly formatted (PEP 8: 4 spaces).
Remove also some trailing spaces.
(cherry picked from commit e87ada48a9e5d9d03f9759138869216df0d7383a)
* gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253)
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 199ba233248ab279f445e0809c2077976f0711bc)
* gh-96465: Clear fractions hash lru_cache under refleak testing (GH-96689)
Automerge-Triggered-By: GH:zware
(cherry picked from commit 9c8f3794337457b1d905a9fa0f38c2978fe32abd)
* gh-95027: Fix regrtest stdout encoding on Windows (#98492)
On Windows, when the Python test suite is run with the -jN option,
the ANSI code page is now used as the encoding for the stdout
temporary file, rather than using UTF-8 which can lead to decoding
errors.
(cherry picked from commit ec1f6f5f139868dc2c1116a7c7c878c38c668d53)
* gh-98903: Test suite fails with exit code 4 if no tests ran (#98904)
The Python test suite now fails wit exit code 4 if no tests ran. It
should help detecting typos in test names and test methods.
* Add "EXITCODE_" constants to Lib/test/libregrtest/main.py.
* Fix a typo: "NO TEST RUN" becomes "NO TESTS RAN"
(cherry picked from commit c76db37c0d23174cbffd6fa978d39693890ef020)
* gh-100086: Add build info to test.libregrtest (#100093)
The Python test runner (libregrtest) now logs Python build information like
"debug" vs "release" build, or LTO and PGO optimizations.
(cherry picked from commit 3c892022472eb975360fb3f0caa6f6fcc6fbf220)
* bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (#30895)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
(cherry picked from commit 995386071f96e4cfebfa027a71ca9134e4651d2a)
* gh-82054: allow test runner to split test_asyncio to execute in parallel by sharding. (#103927)
This runs test_asyncio sub-tests in parallel using sharding from Cinder. This suite is typically the longest-pole in runs because it is a test package with a lot of further sub-tests otherwise run serially. By breaking out the sub-tests as independent modules we can run a lot more in parallel.
After porting we can see the direct impact on a multicore system.
Without this change:
Running make test is 5 min 26 seconds
With this change:
Running make test takes 3 min 39 seconds
That'll vary based on system and parallelism. On a `-j 4` run similar to what CI and buildbot systems often do, it reduced the overall test suite completion latency by 10%.
The drawbacks are that this implementation is hacky and due to the sorting of the tests it obscures when the asyncio tests occur and involves changing CPython test infrastructure but, the wall time saved it is worth it, especially in low-core count CI runs as it pulls a long tail. The win for productivity and reserved CI resource usage is significant.
Future tests that deserve to be refactored into split up suites to benefit from are test_concurrent_futures and the way the _test_multiprocessing suite gets run for all start methods. As exposed by passing the -o flag to python -m test to get a list of the 10 longest running tests.
---------
Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google, LLC]
(cherry picked from commit 9e011e7c77dad7d0bbb944c44891531606caeb21)
* Display the sanitizer config in the regrtest header. (#105301)
Display the sanitizers present in libregrtest.
Having this in the CI output for tests with the relevant environment
variable displayed will help make it easier to do what we need to
create an equivalent local test run.
(cherry picked from commit 852348ab65783601e0844b6647ea033668b45c11)
* gh-101634: regrtest reports decoding error as failed test (#106169)
When running the Python test suite with -jN option, if a worker stdout
cannot be decoded from the locale encoding report a failed testn so the
exitcode is non-zero.
(cherry picked from commit 2ac3eec103cf450aaaebeb932e51155d2e7fb37b)
* gh-108223: test.pythoninfo and libregrtest log Py_NOGIL (#108238)
Enable with --disable-gil --without-pydebug:
$ make pythoninfo|grep NOGIL
sysconfig[Py_NOGIL]: 1
$ ./python -m test
...
== Python build: nogil debug
...
(cherry picked from commit 5afe0c17ca14df430736e549542a4b85e7e7c7ac)
* gh-90791: test.pythoninfo logs ASAN_OPTIONS env var (#108289)
* Cleanup libregrtest code logging ASAN_OPTIONS.
* Fix a typo on "ASAN_OPTIONS" vs "MSAN_OPTIONS".
(cherry picked from commit 3a1ac87f8f89d3206b46a0df4908afae629d669d)
* gh-108388: regrtest splits test_asyncio package (#108393)
Currently, test_asyncio package is only splitted into sub-tests when
using command "./python -m test". With this change, it's also
splitted when passing it on the command line:
"./python -m test test_asyncio".
Remove the concept of "STDTESTS". Python is now mature enough to not
have to bother with that anymore. Removing STDTESTS simplify the
code.
(cherry picked from commit 174e9da0836844a2138cc8915dd305cb2cd7a583)
* regrtest computes statistics (#108793)
test_netrc, test_pep646_syntax and test_xml_etree now return results
in the test_main() function.
Changes:
* Rewrite TestResult as a dataclass with a new State class.
* Add test.support.TestStats class and Regrtest.stats_dict attribute.
* libregrtest.runtest functions now modify a TestResult instance
in-place.
* libregrtest summary lists the number of run tests and skipped
tests, and denied resources.
* Add TestResult.has_meaningful_duration() method.
* Compute TestResult duration in the upper function.
* Use time.perf_counter() instead of time.monotonic().
* Regrtest: rename 'resource_denieds' attribute to 'resource_denied'.
* Rename CHILD_ERROR to MULTIPROCESSING_ERROR.
* Use match/case syntadx to have different code depending on the
test state.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit d4e534cbb35678c82b3a1276826af55d7bfc23b6)
* gh-108822: Add Changelog entry for regrtest statistics (#108821)
---------
Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Zachary Ware <zach@python.org>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Joshua Herman <zitterbewegung@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-09-03 19:21:53 +02:00
|
|
|
self.check_executed_tests(output, [test], failed=test, stats=1)
|
2017-06-27 02:02:04 +02:00
|
|
|
|
|
|
|
|
line = 'beginning 6 repetitions\n123456\n......\n'
|
|
|
|
|
self.check_line(output, re.escape(line))
|
|
|
|
|
|
|
|
|
|
line2 = '%s leaked [1, 1, 1] %s, sum=3\n' % (test, what)
|
|
|
|
|
self.assertIn(line2, output)
|
|
|
|
|
|
|
|
|
|
with open(filename) as fp:
|
|
|
|
|
reflog = fp.read()
|
|
|
|
|
self.assertIn(line2, reflog)
|
|
|
|
|
|
|
|
|
|
@unittest.skipUnless(Py_DEBUG, 'need a debug build')
|
|
|
|
|
def test_huntrleaks(self):
|
|
|
|
|
# test --huntrleaks
|
|
|
|
|
code = textwrap.dedent("""
|
|
|
|
|
import unittest
|
|
|
|
|
|
|
|
|
|
GLOBAL_LIST = []
|
|
|
|
|
|
|
|
|
|
class RefLeakTest(unittest.TestCase):
|
|
|
|
|
def test_leak(self):
|
|
|
|
|
GLOBAL_LIST.append(object())
|
|
|
|
|
""")
|
|
|
|
|
self.check_leak(code, 'references')
|
|
|
|
|
|
2015-10-03 02:21:35 +02:00
|
|
|
@unittest.skipUnless(Py_DEBUG, 'need a debug build')
|
2015-10-03 00:20:56 +02:00
|
|
|
def test_huntrleaks_fd_leak(self):
|
|
|
|
|
# test --huntrleaks for file descriptor leak
|
|
|
|
|
code = textwrap.dedent("""
|
|
|
|
|
import os
|
|
|
|
|
import unittest
|
|
|
|
|
|
|
|
|
|
class FDLeakTest(unittest.TestCase):
|
|
|
|
|
def test_leak(self):
|
|
|
|
|
fd = os.open(__file__, os.O_RDONLY)
|
2017-07-25 17:45:53 +02:00
|
|
|
# bug: never close the file descriptor
|
2015-10-03 00:20:56 +02:00
|
|
|
""")
|
2017-06-27 02:02:04 +02:00
|
|
|
self.check_leak(code, 'file descriptors')
|
2015-10-03 00:20:56 +02:00
|
|
|
|
2015-10-03 00:21:12 +02:00
|
|
|
def test_list_tests(self):
|
|
|
|
|
# test --list-tests
|
|
|
|
|
tests = [self.create_test() for i in range(5)]
|
|
|
|
|
output = self.run_tests('--list-tests', *tests)
|
|
|
|
|
self.assertEqual(output.rstrip().splitlines(),
|
|
|
|
|
tests)
|
|
|
|
|
|
2017-06-16 19:15:28 +08:00
|
|
|
def test_list_cases(self):
|
|
|
|
|
# test --list-cases
|
|
|
|
|
code = textwrap.dedent("""
|
|
|
|
|
import unittest
|
|
|
|
|
|
|
|
|
|
class Tests(unittest.TestCase):
|
|
|
|
|
def test_method1(self):
|
|
|
|
|
pass
|
|
|
|
|
def test_method2(self):
|
|
|
|
|
pass
|
|
|
|
|
""")
|
|
|
|
|
testname = self.create_test(code=code)
|
2017-06-26 14:18:51 +02:00
|
|
|
|
|
|
|
|
# Test --list-cases
|
2017-06-16 19:15:28 +08:00
|
|
|
all_methods = ['%s.Tests.test_method1' % testname,
|
|
|
|
|
'%s.Tests.test_method2' % testname]
|
|
|
|
|
output = self.run_tests('--list-cases', testname)
|
|
|
|
|
self.assertEqual(output.splitlines(), all_methods)
|
2017-06-26 14:18:51 +02:00
|
|
|
|
|
|
|
|
# Test --list-cases with --match
|
|
|
|
|
all_methods = ['%s.Tests.test_method1' % testname]
|
|
|
|
|
output = self.run_tests('--list-cases',
|
|
|
|
|
'-m', 'test_method1',
|
|
|
|
|
testname)
|
|
|
|
|
self.assertEqual(output.splitlines(), all_methods)
|
2017-06-16 19:15:28 +08:00
|
|
|
|
2019-04-26 08:40:25 +02:00
|
|
|
@support.cpython_only
|
2017-02-06 12:42:00 +01:00
|
|
|
def test_crashed(self):
|
|
|
|
|
# Any code which causes a crash
|
|
|
|
|
code = 'import faulthandler; faulthandler._sigsegv()'
|
|
|
|
|
crash_test = self.create_test(name="crash", code=code)
|
|
|
|
|
|
2019-04-26 08:40:25 +02:00
|
|
|
tests = [crash_test]
|
[3.11] gh-108822: Backport libregrtest changes from the main branch (#108820)
* Revert "[3.11] gh-101634: regrtest reports decoding error as failed test (#106169) (#106175)"
This reverts commit d5418e97fc524420011a370ba3c2c3cf6a89a74f.
* Revert "[3.11] bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (GH-30895) (GH-103342)"
This reverts commit ecb09a849689764193e0115d27e220f82b5f6d9f.
* Revert "gh-95027: Fix regrtest stdout encoding on Windows (GH-98492)"
This reverts commit b2aa28eec56d07b9c6777b02b7247cf21839de9f.
* Revert "[3.11] gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253) (GH-94408)"
This reverts commit 0122ab235b5acb52dd99fd05d8802a00f438b828.
* Revert "Run Tools/scripts/reindent.py (GH-94225)"
This reverts commit f0f3a424afb00a15ce8c0140dd218f5b33929be6.
* Revert "gh-94052: Don't re-run failed tests with --python option (GH-94054)"
This reverts commit 1347607db12012f6458ffcba48d8ad797083812e.
* Revert "[3.11] gh-84461: Fix Emscripten umask and permission issues (GH-94002) (GH-94006)"
This reverts commit 10731849184a3101ed18683b0128d689f1671c3f.
* gh-93353: regrtest checks for leaked temporary files (#93776)
When running tests with -jN, create a temporary directory per process
and mark a test as "environment changed" if a test leaks a temporary
file or directory.
(cherry picked from commit e566ce5496f1bad81c431aaee65e36d5e44771c5)
* gh-93353: Fix regrtest for -jN with N >= 2 (GH-93813)
(cherry picked from commit 36934a16e86f34d69ba2d41630fb5b4d06d59cff)
* gh-93353: regrtest supports checking tmp files with -j2 (#93909)
regrtest now also implements checking for leaked temporary files and
directories when using -jN for N >= 2. Use tempfile.mkdtemp() to
create the temporary directory. Skip this check on WASI.
(cherry picked from commit 4f85cec9e2077681b3dacc3108e646d509b720bf)
* gh-84461: Fix Emscripten umask and permission issues (GH-94002)
- Emscripten's default umask is too strict, see
https://github.com/emscripten-core/emscripten/issues/17269
- getuid/getgid and geteuid/getegid are stubs that always return 0
(root). Disable effective uid/gid syscalls and fix tests that use
chmod() current user.
- Cannot drop X bit from directory.
(cherry picked from commit 2702e408fd0e0dd7aec396b4cf8c7ce9caae81d8)
* gh-94052: Don't re-run failed tests with --python option (#94054)
(cherry picked from commit 0ff7b996f5d836e63cdaf652c7aa734285261096)
* Run Tools/scripts/reindent.py (#94225)
Reindent files which were not properly formatted (PEP 8: 4 spaces).
Remove also some trailing spaces.
(cherry picked from commit e87ada48a9e5d9d03f9759138869216df0d7383a)
* gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253)
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 199ba233248ab279f445e0809c2077976f0711bc)
* gh-96465: Clear fractions hash lru_cache under refleak testing (GH-96689)
Automerge-Triggered-By: GH:zware
(cherry picked from commit 9c8f3794337457b1d905a9fa0f38c2978fe32abd)
* gh-95027: Fix regrtest stdout encoding on Windows (#98492)
On Windows, when the Python test suite is run with the -jN option,
the ANSI code page is now used as the encoding for the stdout
temporary file, rather than using UTF-8 which can lead to decoding
errors.
(cherry picked from commit ec1f6f5f139868dc2c1116a7c7c878c38c668d53)
* gh-98903: Test suite fails with exit code 4 if no tests ran (#98904)
The Python test suite now fails wit exit code 4 if no tests ran. It
should help detecting typos in test names and test methods.
* Add "EXITCODE_" constants to Lib/test/libregrtest/main.py.
* Fix a typo: "NO TEST RUN" becomes "NO TESTS RAN"
(cherry picked from commit c76db37c0d23174cbffd6fa978d39693890ef020)
* gh-100086: Add build info to test.libregrtest (#100093)
The Python test runner (libregrtest) now logs Python build information like
"debug" vs "release" build, or LTO and PGO optimizations.
(cherry picked from commit 3c892022472eb975360fb3f0caa6f6fcc6fbf220)
* bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (#30895)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
(cherry picked from commit 995386071f96e4cfebfa027a71ca9134e4651d2a)
* gh-82054: allow test runner to split test_asyncio to execute in parallel by sharding. (#103927)
This runs test_asyncio sub-tests in parallel using sharding from Cinder. This suite is typically the longest-pole in runs because it is a test package with a lot of further sub-tests otherwise run serially. By breaking out the sub-tests as independent modules we can run a lot more in parallel.
After porting we can see the direct impact on a multicore system.
Without this change:
Running make test is 5 min 26 seconds
With this change:
Running make test takes 3 min 39 seconds
That'll vary based on system and parallelism. On a `-j 4` run similar to what CI and buildbot systems often do, it reduced the overall test suite completion latency by 10%.
The drawbacks are that this implementation is hacky and due to the sorting of the tests it obscures when the asyncio tests occur and involves changing CPython test infrastructure but, the wall time saved it is worth it, especially in low-core count CI runs as it pulls a long tail. The win for productivity and reserved CI resource usage is significant.
Future tests that deserve to be refactored into split up suites to benefit from are test_concurrent_futures and the way the _test_multiprocessing suite gets run for all start methods. As exposed by passing the -o flag to python -m test to get a list of the 10 longest running tests.
---------
Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google, LLC]
(cherry picked from commit 9e011e7c77dad7d0bbb944c44891531606caeb21)
* Display the sanitizer config in the regrtest header. (#105301)
Display the sanitizers present in libregrtest.
Having this in the CI output for tests with the relevant environment
variable displayed will help make it easier to do what we need to
create an equivalent local test run.
(cherry picked from commit 852348ab65783601e0844b6647ea033668b45c11)
* gh-101634: regrtest reports decoding error as failed test (#106169)
When running the Python test suite with -jN option, if a worker stdout
cannot be decoded from the locale encoding report a failed testn so the
exitcode is non-zero.
(cherry picked from commit 2ac3eec103cf450aaaebeb932e51155d2e7fb37b)
* gh-108223: test.pythoninfo and libregrtest log Py_NOGIL (#108238)
Enable with --disable-gil --without-pydebug:
$ make pythoninfo|grep NOGIL
sysconfig[Py_NOGIL]: 1
$ ./python -m test
...
== Python build: nogil debug
...
(cherry picked from commit 5afe0c17ca14df430736e549542a4b85e7e7c7ac)
* gh-90791: test.pythoninfo logs ASAN_OPTIONS env var (#108289)
* Cleanup libregrtest code logging ASAN_OPTIONS.
* Fix a typo on "ASAN_OPTIONS" vs "MSAN_OPTIONS".
(cherry picked from commit 3a1ac87f8f89d3206b46a0df4908afae629d669d)
* gh-108388: regrtest splits test_asyncio package (#108393)
Currently, test_asyncio package is only splitted into sub-tests when
using command "./python -m test". With this change, it's also
splitted when passing it on the command line:
"./python -m test test_asyncio".
Remove the concept of "STDTESTS". Python is now mature enough to not
have to bother with that anymore. Removing STDTESTS simplify the
code.
(cherry picked from commit 174e9da0836844a2138cc8915dd305cb2cd7a583)
* regrtest computes statistics (#108793)
test_netrc, test_pep646_syntax and test_xml_etree now return results
in the test_main() function.
Changes:
* Rewrite TestResult as a dataclass with a new State class.
* Add test.support.TestStats class and Regrtest.stats_dict attribute.
* libregrtest.runtest functions now modify a TestResult instance
in-place.
* libregrtest summary lists the number of run tests and skipped
tests, and denied resources.
* Add TestResult.has_meaningful_duration() method.
* Compute TestResult duration in the upper function.
* Use time.perf_counter() instead of time.monotonic().
* Regrtest: rename 'resource_denieds' attribute to 'resource_denied'.
* Rename CHILD_ERROR to MULTIPROCESSING_ERROR.
* Use match/case syntadx to have different code depending on the
test state.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit d4e534cbb35678c82b3a1276826af55d7bfc23b6)
* gh-108822: Add Changelog entry for regrtest statistics (#108821)
---------
Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Zachary Ware <zach@python.org>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Joshua Herman <zitterbewegung@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-09-03 19:21:53 +02:00
|
|
|
output = self.run_tests("-j2", *tests, exitcode=EXITCODE_BAD_TEST)
|
2017-02-06 12:42:00 +01:00
|
|
|
self.check_executed_tests(output, tests, failed=crash_test,
|
[3.11] gh-108822: Backport libregrtest changes from the main branch (#108820)
* Revert "[3.11] gh-101634: regrtest reports decoding error as failed test (#106169) (#106175)"
This reverts commit d5418e97fc524420011a370ba3c2c3cf6a89a74f.
* Revert "[3.11] bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (GH-30895) (GH-103342)"
This reverts commit ecb09a849689764193e0115d27e220f82b5f6d9f.
* Revert "gh-95027: Fix regrtest stdout encoding on Windows (GH-98492)"
This reverts commit b2aa28eec56d07b9c6777b02b7247cf21839de9f.
* Revert "[3.11] gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253) (GH-94408)"
This reverts commit 0122ab235b5acb52dd99fd05d8802a00f438b828.
* Revert "Run Tools/scripts/reindent.py (GH-94225)"
This reverts commit f0f3a424afb00a15ce8c0140dd218f5b33929be6.
* Revert "gh-94052: Don't re-run failed tests with --python option (GH-94054)"
This reverts commit 1347607db12012f6458ffcba48d8ad797083812e.
* Revert "[3.11] gh-84461: Fix Emscripten umask and permission issues (GH-94002) (GH-94006)"
This reverts commit 10731849184a3101ed18683b0128d689f1671c3f.
* gh-93353: regrtest checks for leaked temporary files (#93776)
When running tests with -jN, create a temporary directory per process
and mark a test as "environment changed" if a test leaks a temporary
file or directory.
(cherry picked from commit e566ce5496f1bad81c431aaee65e36d5e44771c5)
* gh-93353: Fix regrtest for -jN with N >= 2 (GH-93813)
(cherry picked from commit 36934a16e86f34d69ba2d41630fb5b4d06d59cff)
* gh-93353: regrtest supports checking tmp files with -j2 (#93909)
regrtest now also implements checking for leaked temporary files and
directories when using -jN for N >= 2. Use tempfile.mkdtemp() to
create the temporary directory. Skip this check on WASI.
(cherry picked from commit 4f85cec9e2077681b3dacc3108e646d509b720bf)
* gh-84461: Fix Emscripten umask and permission issues (GH-94002)
- Emscripten's default umask is too strict, see
https://github.com/emscripten-core/emscripten/issues/17269
- getuid/getgid and geteuid/getegid are stubs that always return 0
(root). Disable effective uid/gid syscalls and fix tests that use
chmod() current user.
- Cannot drop X bit from directory.
(cherry picked from commit 2702e408fd0e0dd7aec396b4cf8c7ce9caae81d8)
* gh-94052: Don't re-run failed tests with --python option (#94054)
(cherry picked from commit 0ff7b996f5d836e63cdaf652c7aa734285261096)
* Run Tools/scripts/reindent.py (#94225)
Reindent files which were not properly formatted (PEP 8: 4 spaces).
Remove also some trailing spaces.
(cherry picked from commit e87ada48a9e5d9d03f9759138869216df0d7383a)
* gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253)
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 199ba233248ab279f445e0809c2077976f0711bc)
* gh-96465: Clear fractions hash lru_cache under refleak testing (GH-96689)
Automerge-Triggered-By: GH:zware
(cherry picked from commit 9c8f3794337457b1d905a9fa0f38c2978fe32abd)
* gh-95027: Fix regrtest stdout encoding on Windows (#98492)
On Windows, when the Python test suite is run with the -jN option,
the ANSI code page is now used as the encoding for the stdout
temporary file, rather than using UTF-8 which can lead to decoding
errors.
(cherry picked from commit ec1f6f5f139868dc2c1116a7c7c878c38c668d53)
* gh-98903: Test suite fails with exit code 4 if no tests ran (#98904)
The Python test suite now fails wit exit code 4 if no tests ran. It
should help detecting typos in test names and test methods.
* Add "EXITCODE_" constants to Lib/test/libregrtest/main.py.
* Fix a typo: "NO TEST RUN" becomes "NO TESTS RAN"
(cherry picked from commit c76db37c0d23174cbffd6fa978d39693890ef020)
* gh-100086: Add build info to test.libregrtest (#100093)
The Python test runner (libregrtest) now logs Python build information like
"debug" vs "release" build, or LTO and PGO optimizations.
(cherry picked from commit 3c892022472eb975360fb3f0caa6f6fcc6fbf220)
* bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (#30895)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
(cherry picked from commit 995386071f96e4cfebfa027a71ca9134e4651d2a)
* gh-82054: allow test runner to split test_asyncio to execute in parallel by sharding. (#103927)
This runs test_asyncio sub-tests in parallel using sharding from Cinder. This suite is typically the longest-pole in runs because it is a test package with a lot of further sub-tests otherwise run serially. By breaking out the sub-tests as independent modules we can run a lot more in parallel.
After porting we can see the direct impact on a multicore system.
Without this change:
Running make test is 5 min 26 seconds
With this change:
Running make test takes 3 min 39 seconds
That'll vary based on system and parallelism. On a `-j 4` run similar to what CI and buildbot systems often do, it reduced the overall test suite completion latency by 10%.
The drawbacks are that this implementation is hacky and due to the sorting of the tests it obscures when the asyncio tests occur and involves changing CPython test infrastructure but, the wall time saved it is worth it, especially in low-core count CI runs as it pulls a long tail. The win for productivity and reserved CI resource usage is significant.
Future tests that deserve to be refactored into split up suites to benefit from are test_concurrent_futures and the way the _test_multiprocessing suite gets run for all start methods. As exposed by passing the -o flag to python -m test to get a list of the 10 longest running tests.
---------
Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google, LLC]
(cherry picked from commit 9e011e7c77dad7d0bbb944c44891531606caeb21)
* Display the sanitizer config in the regrtest header. (#105301)
Display the sanitizers present in libregrtest.
Having this in the CI output for tests with the relevant environment
variable displayed will help make it easier to do what we need to
create an equivalent local test run.
(cherry picked from commit 852348ab65783601e0844b6647ea033668b45c11)
* gh-101634: regrtest reports decoding error as failed test (#106169)
When running the Python test suite with -jN option, if a worker stdout
cannot be decoded from the locale encoding report a failed testn so the
exitcode is non-zero.
(cherry picked from commit 2ac3eec103cf450aaaebeb932e51155d2e7fb37b)
* gh-108223: test.pythoninfo and libregrtest log Py_NOGIL (#108238)
Enable with --disable-gil --without-pydebug:
$ make pythoninfo|grep NOGIL
sysconfig[Py_NOGIL]: 1
$ ./python -m test
...
== Python build: nogil debug
...
(cherry picked from commit 5afe0c17ca14df430736e549542a4b85e7e7c7ac)
* gh-90791: test.pythoninfo logs ASAN_OPTIONS env var (#108289)
* Cleanup libregrtest code logging ASAN_OPTIONS.
* Fix a typo on "ASAN_OPTIONS" vs "MSAN_OPTIONS".
(cherry picked from commit 3a1ac87f8f89d3206b46a0df4908afae629d669d)
* gh-108388: regrtest splits test_asyncio package (#108393)
Currently, test_asyncio package is only splitted into sub-tests when
using command "./python -m test". With this change, it's also
splitted when passing it on the command line:
"./python -m test test_asyncio".
Remove the concept of "STDTESTS". Python is now mature enough to not
have to bother with that anymore. Removing STDTESTS simplify the
code.
(cherry picked from commit 174e9da0836844a2138cc8915dd305cb2cd7a583)
* regrtest computes statistics (#108793)
test_netrc, test_pep646_syntax and test_xml_etree now return results
in the test_main() function.
Changes:
* Rewrite TestResult as a dataclass with a new State class.
* Add test.support.TestStats class and Regrtest.stats_dict attribute.
* libregrtest.runtest functions now modify a TestResult instance
in-place.
* libregrtest summary lists the number of run tests and skipped
tests, and denied resources.
* Add TestResult.has_meaningful_duration() method.
* Compute TestResult duration in the upper function.
* Use time.perf_counter() instead of time.monotonic().
* Regrtest: rename 'resource_denieds' attribute to 'resource_denied'.
* Rename CHILD_ERROR to MULTIPROCESSING_ERROR.
* Use match/case syntadx to have different code depending on the
test state.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit d4e534cbb35678c82b3a1276826af55d7bfc23b6)
* gh-108822: Add Changelog entry for regrtest statistics (#108821)
---------
Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Zachary Ware <zach@python.org>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Joshua Herman <zitterbewegung@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-09-03 19:21:53 +02:00
|
|
|
randomize=True, stats=0)
|
2017-02-06 12:42:00 +01:00
|
|
|
|
2017-06-09 10:18:48 +02:00
|
|
|
def parse_methods(self, output):
|
|
|
|
|
regex = re.compile("^(test[^ ]+).*ok$", flags=re.MULTILINE)
|
|
|
|
|
return [match.group(1) for match in regex.finditer(output)]
|
|
|
|
|
|
2019-11-19 23:46:49 +00:00
|
|
|
def test_ignorefile(self):
|
|
|
|
|
code = textwrap.dedent("""
|
|
|
|
|
import unittest
|
|
|
|
|
|
|
|
|
|
class Tests(unittest.TestCase):
|
|
|
|
|
def test_method1(self):
|
|
|
|
|
pass
|
|
|
|
|
def test_method2(self):
|
|
|
|
|
pass
|
|
|
|
|
def test_method3(self):
|
|
|
|
|
pass
|
|
|
|
|
def test_method4(self):
|
|
|
|
|
pass
|
|
|
|
|
""")
|
|
|
|
|
all_methods = ['test_method1', 'test_method2',
|
|
|
|
|
'test_method3', 'test_method4']
|
|
|
|
|
testname = self.create_test(code=code)
|
|
|
|
|
|
|
|
|
|
# only run a subset
|
2020-06-30 21:46:06 +08:00
|
|
|
filename = os_helper.TESTFN
|
|
|
|
|
self.addCleanup(os_helper.unlink, filename)
|
2019-11-19 23:46:49 +00:00
|
|
|
|
|
|
|
|
subset = [
|
|
|
|
|
# only ignore the method name
|
|
|
|
|
'test_method1',
|
|
|
|
|
# ignore the full identifier
|
|
|
|
|
'%s.Tests.test_method3' % testname]
|
|
|
|
|
with open(filename, "w") as fp:
|
|
|
|
|
for name in subset:
|
|
|
|
|
print(name, file=fp)
|
|
|
|
|
|
|
|
|
|
output = self.run_tests("-v", "--ignorefile", filename, testname)
|
|
|
|
|
methods = self.parse_methods(output)
|
|
|
|
|
subset = ['test_method2', 'test_method4']
|
|
|
|
|
self.assertEqual(methods, subset)
|
|
|
|
|
|
2017-06-09 10:18:48 +02:00
|
|
|
def test_matchfile(self):
|
|
|
|
|
code = textwrap.dedent("""
|
|
|
|
|
import unittest
|
|
|
|
|
|
|
|
|
|
class Tests(unittest.TestCase):
|
|
|
|
|
def test_method1(self):
|
|
|
|
|
pass
|
|
|
|
|
def test_method2(self):
|
|
|
|
|
pass
|
|
|
|
|
def test_method3(self):
|
|
|
|
|
pass
|
|
|
|
|
def test_method4(self):
|
|
|
|
|
pass
|
|
|
|
|
""")
|
|
|
|
|
all_methods = ['test_method1', 'test_method2',
|
|
|
|
|
'test_method3', 'test_method4']
|
|
|
|
|
testname = self.create_test(code=code)
|
|
|
|
|
|
|
|
|
|
# by default, all methods should be run
|
|
|
|
|
output = self.run_tests("-v", testname)
|
|
|
|
|
methods = self.parse_methods(output)
|
|
|
|
|
self.assertEqual(methods, all_methods)
|
|
|
|
|
|
|
|
|
|
# only run a subset
|
2020-06-30 21:46:06 +08:00
|
|
|
filename = os_helper.TESTFN
|
|
|
|
|
self.addCleanup(os_helper.unlink, filename)
|
2017-06-09 10:18:48 +02:00
|
|
|
|
|
|
|
|
subset = [
|
|
|
|
|
# only match the method name
|
|
|
|
|
'test_method1',
|
|
|
|
|
# match the full identifier
|
|
|
|
|
'%s.Tests.test_method3' % testname]
|
|
|
|
|
with open(filename, "w") as fp:
|
|
|
|
|
for name in subset:
|
|
|
|
|
print(name, file=fp)
|
|
|
|
|
|
|
|
|
|
output = self.run_tests("-v", "--matchfile", filename, testname)
|
|
|
|
|
methods = self.parse_methods(output)
|
|
|
|
|
subset = ['test_method1', 'test_method3']
|
|
|
|
|
self.assertEqual(methods, subset)
|
|
|
|
|
|
2017-06-26 18:33:19 +02:00
|
|
|
def test_env_changed(self):
|
|
|
|
|
code = textwrap.dedent("""
|
|
|
|
|
import unittest
|
|
|
|
|
|
|
|
|
|
class Tests(unittest.TestCase):
|
|
|
|
|
def test_env_changed(self):
|
|
|
|
|
open("env_changed", "w").close()
|
|
|
|
|
""")
|
|
|
|
|
testname = self.create_test(code=code)
|
|
|
|
|
|
|
|
|
|
# don't fail by default
|
|
|
|
|
output = self.run_tests(testname)
|
[3.11] gh-108822: Backport libregrtest changes from the main branch (#108820)
* Revert "[3.11] gh-101634: regrtest reports decoding error as failed test (#106169) (#106175)"
This reverts commit d5418e97fc524420011a370ba3c2c3cf6a89a74f.
* Revert "[3.11] bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (GH-30895) (GH-103342)"
This reverts commit ecb09a849689764193e0115d27e220f82b5f6d9f.
* Revert "gh-95027: Fix regrtest stdout encoding on Windows (GH-98492)"
This reverts commit b2aa28eec56d07b9c6777b02b7247cf21839de9f.
* Revert "[3.11] gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253) (GH-94408)"
This reverts commit 0122ab235b5acb52dd99fd05d8802a00f438b828.
* Revert "Run Tools/scripts/reindent.py (GH-94225)"
This reverts commit f0f3a424afb00a15ce8c0140dd218f5b33929be6.
* Revert "gh-94052: Don't re-run failed tests with --python option (GH-94054)"
This reverts commit 1347607db12012f6458ffcba48d8ad797083812e.
* Revert "[3.11] gh-84461: Fix Emscripten umask and permission issues (GH-94002) (GH-94006)"
This reverts commit 10731849184a3101ed18683b0128d689f1671c3f.
* gh-93353: regrtest checks for leaked temporary files (#93776)
When running tests with -jN, create a temporary directory per process
and mark a test as "environment changed" if a test leaks a temporary
file or directory.
(cherry picked from commit e566ce5496f1bad81c431aaee65e36d5e44771c5)
* gh-93353: Fix regrtest for -jN with N >= 2 (GH-93813)
(cherry picked from commit 36934a16e86f34d69ba2d41630fb5b4d06d59cff)
* gh-93353: regrtest supports checking tmp files with -j2 (#93909)
regrtest now also implements checking for leaked temporary files and
directories when using -jN for N >= 2. Use tempfile.mkdtemp() to
create the temporary directory. Skip this check on WASI.
(cherry picked from commit 4f85cec9e2077681b3dacc3108e646d509b720bf)
* gh-84461: Fix Emscripten umask and permission issues (GH-94002)
- Emscripten's default umask is too strict, see
https://github.com/emscripten-core/emscripten/issues/17269
- getuid/getgid and geteuid/getegid are stubs that always return 0
(root). Disable effective uid/gid syscalls and fix tests that use
chmod() current user.
- Cannot drop X bit from directory.
(cherry picked from commit 2702e408fd0e0dd7aec396b4cf8c7ce9caae81d8)
* gh-94052: Don't re-run failed tests with --python option (#94054)
(cherry picked from commit 0ff7b996f5d836e63cdaf652c7aa734285261096)
* Run Tools/scripts/reindent.py (#94225)
Reindent files which were not properly formatted (PEP 8: 4 spaces).
Remove also some trailing spaces.
(cherry picked from commit e87ada48a9e5d9d03f9759138869216df0d7383a)
* gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253)
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 199ba233248ab279f445e0809c2077976f0711bc)
* gh-96465: Clear fractions hash lru_cache under refleak testing (GH-96689)
Automerge-Triggered-By: GH:zware
(cherry picked from commit 9c8f3794337457b1d905a9fa0f38c2978fe32abd)
* gh-95027: Fix regrtest stdout encoding on Windows (#98492)
On Windows, when the Python test suite is run with the -jN option,
the ANSI code page is now used as the encoding for the stdout
temporary file, rather than using UTF-8 which can lead to decoding
errors.
(cherry picked from commit ec1f6f5f139868dc2c1116a7c7c878c38c668d53)
* gh-98903: Test suite fails with exit code 4 if no tests ran (#98904)
The Python test suite now fails wit exit code 4 if no tests ran. It
should help detecting typos in test names and test methods.
* Add "EXITCODE_" constants to Lib/test/libregrtest/main.py.
* Fix a typo: "NO TEST RUN" becomes "NO TESTS RAN"
(cherry picked from commit c76db37c0d23174cbffd6fa978d39693890ef020)
* gh-100086: Add build info to test.libregrtest (#100093)
The Python test runner (libregrtest) now logs Python build information like
"debug" vs "release" build, or LTO and PGO optimizations.
(cherry picked from commit 3c892022472eb975360fb3f0caa6f6fcc6fbf220)
* bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (#30895)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
(cherry picked from commit 995386071f96e4cfebfa027a71ca9134e4651d2a)
* gh-82054: allow test runner to split test_asyncio to execute in parallel by sharding. (#103927)
This runs test_asyncio sub-tests in parallel using sharding from Cinder. This suite is typically the longest-pole in runs because it is a test package with a lot of further sub-tests otherwise run serially. By breaking out the sub-tests as independent modules we can run a lot more in parallel.
After porting we can see the direct impact on a multicore system.
Without this change:
Running make test is 5 min 26 seconds
With this change:
Running make test takes 3 min 39 seconds
That'll vary based on system and parallelism. On a `-j 4` run similar to what CI and buildbot systems often do, it reduced the overall test suite completion latency by 10%.
The drawbacks are that this implementation is hacky and due to the sorting of the tests it obscures when the asyncio tests occur and involves changing CPython test infrastructure but, the wall time saved it is worth it, especially in low-core count CI runs as it pulls a long tail. The win for productivity and reserved CI resource usage is significant.
Future tests that deserve to be refactored into split up suites to benefit from are test_concurrent_futures and the way the _test_multiprocessing suite gets run for all start methods. As exposed by passing the -o flag to python -m test to get a list of the 10 longest running tests.
---------
Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google, LLC]
(cherry picked from commit 9e011e7c77dad7d0bbb944c44891531606caeb21)
* Display the sanitizer config in the regrtest header. (#105301)
Display the sanitizers present in libregrtest.
Having this in the CI output for tests with the relevant environment
variable displayed will help make it easier to do what we need to
create an equivalent local test run.
(cherry picked from commit 852348ab65783601e0844b6647ea033668b45c11)
* gh-101634: regrtest reports decoding error as failed test (#106169)
When running the Python test suite with -jN option, if a worker stdout
cannot be decoded from the locale encoding report a failed testn so the
exitcode is non-zero.
(cherry picked from commit 2ac3eec103cf450aaaebeb932e51155d2e7fb37b)
* gh-108223: test.pythoninfo and libregrtest log Py_NOGIL (#108238)
Enable with --disable-gil --without-pydebug:
$ make pythoninfo|grep NOGIL
sysconfig[Py_NOGIL]: 1
$ ./python -m test
...
== Python build: nogil debug
...
(cherry picked from commit 5afe0c17ca14df430736e549542a4b85e7e7c7ac)
* gh-90791: test.pythoninfo logs ASAN_OPTIONS env var (#108289)
* Cleanup libregrtest code logging ASAN_OPTIONS.
* Fix a typo on "ASAN_OPTIONS" vs "MSAN_OPTIONS".
(cherry picked from commit 3a1ac87f8f89d3206b46a0df4908afae629d669d)
* gh-108388: regrtest splits test_asyncio package (#108393)
Currently, test_asyncio package is only splitted into sub-tests when
using command "./python -m test". With this change, it's also
splitted when passing it on the command line:
"./python -m test test_asyncio".
Remove the concept of "STDTESTS". Python is now mature enough to not
have to bother with that anymore. Removing STDTESTS simplify the
code.
(cherry picked from commit 174e9da0836844a2138cc8915dd305cb2cd7a583)
* regrtest computes statistics (#108793)
test_netrc, test_pep646_syntax and test_xml_etree now return results
in the test_main() function.
Changes:
* Rewrite TestResult as a dataclass with a new State class.
* Add test.support.TestStats class and Regrtest.stats_dict attribute.
* libregrtest.runtest functions now modify a TestResult instance
in-place.
* libregrtest summary lists the number of run tests and skipped
tests, and denied resources.
* Add TestResult.has_meaningful_duration() method.
* Compute TestResult duration in the upper function.
* Use time.perf_counter() instead of time.monotonic().
* Regrtest: rename 'resource_denieds' attribute to 'resource_denied'.
* Rename CHILD_ERROR to MULTIPROCESSING_ERROR.
* Use match/case syntadx to have different code depending on the
test state.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit d4e534cbb35678c82b3a1276826af55d7bfc23b6)
* gh-108822: Add Changelog entry for regrtest statistics (#108821)
---------
Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Zachary Ware <zach@python.org>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Joshua Herman <zitterbewegung@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-09-03 19:21:53 +02:00
|
|
|
self.check_executed_tests(output, [testname],
|
|
|
|
|
env_changed=testname, stats=1)
|
2017-06-26 18:33:19 +02:00
|
|
|
|
|
|
|
|
# fail with --fail-env-changed
|
[3.11] gh-108822: Backport libregrtest changes from the main branch (#108820)
* Revert "[3.11] gh-101634: regrtest reports decoding error as failed test (#106169) (#106175)"
This reverts commit d5418e97fc524420011a370ba3c2c3cf6a89a74f.
* Revert "[3.11] bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (GH-30895) (GH-103342)"
This reverts commit ecb09a849689764193e0115d27e220f82b5f6d9f.
* Revert "gh-95027: Fix regrtest stdout encoding on Windows (GH-98492)"
This reverts commit b2aa28eec56d07b9c6777b02b7247cf21839de9f.
* Revert "[3.11] gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253) (GH-94408)"
This reverts commit 0122ab235b5acb52dd99fd05d8802a00f438b828.
* Revert "Run Tools/scripts/reindent.py (GH-94225)"
This reverts commit f0f3a424afb00a15ce8c0140dd218f5b33929be6.
* Revert "gh-94052: Don't re-run failed tests with --python option (GH-94054)"
This reverts commit 1347607db12012f6458ffcba48d8ad797083812e.
* Revert "[3.11] gh-84461: Fix Emscripten umask and permission issues (GH-94002) (GH-94006)"
This reverts commit 10731849184a3101ed18683b0128d689f1671c3f.
* gh-93353: regrtest checks for leaked temporary files (#93776)
When running tests with -jN, create a temporary directory per process
and mark a test as "environment changed" if a test leaks a temporary
file or directory.
(cherry picked from commit e566ce5496f1bad81c431aaee65e36d5e44771c5)
* gh-93353: Fix regrtest for -jN with N >= 2 (GH-93813)
(cherry picked from commit 36934a16e86f34d69ba2d41630fb5b4d06d59cff)
* gh-93353: regrtest supports checking tmp files with -j2 (#93909)
regrtest now also implements checking for leaked temporary files and
directories when using -jN for N >= 2. Use tempfile.mkdtemp() to
create the temporary directory. Skip this check on WASI.
(cherry picked from commit 4f85cec9e2077681b3dacc3108e646d509b720bf)
* gh-84461: Fix Emscripten umask and permission issues (GH-94002)
- Emscripten's default umask is too strict, see
https://github.com/emscripten-core/emscripten/issues/17269
- getuid/getgid and geteuid/getegid are stubs that always return 0
(root). Disable effective uid/gid syscalls and fix tests that use
chmod() current user.
- Cannot drop X bit from directory.
(cherry picked from commit 2702e408fd0e0dd7aec396b4cf8c7ce9caae81d8)
* gh-94052: Don't re-run failed tests with --python option (#94054)
(cherry picked from commit 0ff7b996f5d836e63cdaf652c7aa734285261096)
* Run Tools/scripts/reindent.py (#94225)
Reindent files which were not properly formatted (PEP 8: 4 spaces).
Remove also some trailing spaces.
(cherry picked from commit e87ada48a9e5d9d03f9759138869216df0d7383a)
* gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253)
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 199ba233248ab279f445e0809c2077976f0711bc)
* gh-96465: Clear fractions hash lru_cache under refleak testing (GH-96689)
Automerge-Triggered-By: GH:zware
(cherry picked from commit 9c8f3794337457b1d905a9fa0f38c2978fe32abd)
* gh-95027: Fix regrtest stdout encoding on Windows (#98492)
On Windows, when the Python test suite is run with the -jN option,
the ANSI code page is now used as the encoding for the stdout
temporary file, rather than using UTF-8 which can lead to decoding
errors.
(cherry picked from commit ec1f6f5f139868dc2c1116a7c7c878c38c668d53)
* gh-98903: Test suite fails with exit code 4 if no tests ran (#98904)
The Python test suite now fails wit exit code 4 if no tests ran. It
should help detecting typos in test names and test methods.
* Add "EXITCODE_" constants to Lib/test/libregrtest/main.py.
* Fix a typo: "NO TEST RUN" becomes "NO TESTS RAN"
(cherry picked from commit c76db37c0d23174cbffd6fa978d39693890ef020)
* gh-100086: Add build info to test.libregrtest (#100093)
The Python test runner (libregrtest) now logs Python build information like
"debug" vs "release" build, or LTO and PGO optimizations.
(cherry picked from commit 3c892022472eb975360fb3f0caa6f6fcc6fbf220)
* bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (#30895)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
(cherry picked from commit 995386071f96e4cfebfa027a71ca9134e4651d2a)
* gh-82054: allow test runner to split test_asyncio to execute in parallel by sharding. (#103927)
This runs test_asyncio sub-tests in parallel using sharding from Cinder. This suite is typically the longest-pole in runs because it is a test package with a lot of further sub-tests otherwise run serially. By breaking out the sub-tests as independent modules we can run a lot more in parallel.
After porting we can see the direct impact on a multicore system.
Without this change:
Running make test is 5 min 26 seconds
With this change:
Running make test takes 3 min 39 seconds
That'll vary based on system and parallelism. On a `-j 4` run similar to what CI and buildbot systems often do, it reduced the overall test suite completion latency by 10%.
The drawbacks are that this implementation is hacky and due to the sorting of the tests it obscures when the asyncio tests occur and involves changing CPython test infrastructure but, the wall time saved it is worth it, especially in low-core count CI runs as it pulls a long tail. The win for productivity and reserved CI resource usage is significant.
Future tests that deserve to be refactored into split up suites to benefit from are test_concurrent_futures and the way the _test_multiprocessing suite gets run for all start methods. As exposed by passing the -o flag to python -m test to get a list of the 10 longest running tests.
---------
Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google, LLC]
(cherry picked from commit 9e011e7c77dad7d0bbb944c44891531606caeb21)
* Display the sanitizer config in the regrtest header. (#105301)
Display the sanitizers present in libregrtest.
Having this in the CI output for tests with the relevant environment
variable displayed will help make it easier to do what we need to
create an equivalent local test run.
(cherry picked from commit 852348ab65783601e0844b6647ea033668b45c11)
* gh-101634: regrtest reports decoding error as failed test (#106169)
When running the Python test suite with -jN option, if a worker stdout
cannot be decoded from the locale encoding report a failed testn so the
exitcode is non-zero.
(cherry picked from commit 2ac3eec103cf450aaaebeb932e51155d2e7fb37b)
* gh-108223: test.pythoninfo and libregrtest log Py_NOGIL (#108238)
Enable with --disable-gil --without-pydebug:
$ make pythoninfo|grep NOGIL
sysconfig[Py_NOGIL]: 1
$ ./python -m test
...
== Python build: nogil debug
...
(cherry picked from commit 5afe0c17ca14df430736e549542a4b85e7e7c7ac)
* gh-90791: test.pythoninfo logs ASAN_OPTIONS env var (#108289)
* Cleanup libregrtest code logging ASAN_OPTIONS.
* Fix a typo on "ASAN_OPTIONS" vs "MSAN_OPTIONS".
(cherry picked from commit 3a1ac87f8f89d3206b46a0df4908afae629d669d)
* gh-108388: regrtest splits test_asyncio package (#108393)
Currently, test_asyncio package is only splitted into sub-tests when
using command "./python -m test". With this change, it's also
splitted when passing it on the command line:
"./python -m test test_asyncio".
Remove the concept of "STDTESTS". Python is now mature enough to not
have to bother with that anymore. Removing STDTESTS simplify the
code.
(cherry picked from commit 174e9da0836844a2138cc8915dd305cb2cd7a583)
* regrtest computes statistics (#108793)
test_netrc, test_pep646_syntax and test_xml_etree now return results
in the test_main() function.
Changes:
* Rewrite TestResult as a dataclass with a new State class.
* Add test.support.TestStats class and Regrtest.stats_dict attribute.
* libregrtest.runtest functions now modify a TestResult instance
in-place.
* libregrtest summary lists the number of run tests and skipped
tests, and denied resources.
* Add TestResult.has_meaningful_duration() method.
* Compute TestResult duration in the upper function.
* Use time.perf_counter() instead of time.monotonic().
* Regrtest: rename 'resource_denieds' attribute to 'resource_denied'.
* Rename CHILD_ERROR to MULTIPROCESSING_ERROR.
* Use match/case syntadx to have different code depending on the
test state.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit d4e534cbb35678c82b3a1276826af55d7bfc23b6)
* gh-108822: Add Changelog entry for regrtest statistics (#108821)
---------
Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Zachary Ware <zach@python.org>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Joshua Herman <zitterbewegung@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-09-03 19:21:53 +02:00
|
|
|
output = self.run_tests("--fail-env-changed", testname,
|
|
|
|
|
exitcode=EXITCODE_ENV_CHANGED)
|
2017-06-26 18:33:19 +02:00
|
|
|
self.check_executed_tests(output, [testname], env_changed=testname,
|
[3.11] gh-108822: Backport libregrtest changes from the main branch (#108820)
* Revert "[3.11] gh-101634: regrtest reports decoding error as failed test (#106169) (#106175)"
This reverts commit d5418e97fc524420011a370ba3c2c3cf6a89a74f.
* Revert "[3.11] bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (GH-30895) (GH-103342)"
This reverts commit ecb09a849689764193e0115d27e220f82b5f6d9f.
* Revert "gh-95027: Fix regrtest stdout encoding on Windows (GH-98492)"
This reverts commit b2aa28eec56d07b9c6777b02b7247cf21839de9f.
* Revert "[3.11] gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253) (GH-94408)"
This reverts commit 0122ab235b5acb52dd99fd05d8802a00f438b828.
* Revert "Run Tools/scripts/reindent.py (GH-94225)"
This reverts commit f0f3a424afb00a15ce8c0140dd218f5b33929be6.
* Revert "gh-94052: Don't re-run failed tests with --python option (GH-94054)"
This reverts commit 1347607db12012f6458ffcba48d8ad797083812e.
* Revert "[3.11] gh-84461: Fix Emscripten umask and permission issues (GH-94002) (GH-94006)"
This reverts commit 10731849184a3101ed18683b0128d689f1671c3f.
* gh-93353: regrtest checks for leaked temporary files (#93776)
When running tests with -jN, create a temporary directory per process
and mark a test as "environment changed" if a test leaks a temporary
file or directory.
(cherry picked from commit e566ce5496f1bad81c431aaee65e36d5e44771c5)
* gh-93353: Fix regrtest for -jN with N >= 2 (GH-93813)
(cherry picked from commit 36934a16e86f34d69ba2d41630fb5b4d06d59cff)
* gh-93353: regrtest supports checking tmp files with -j2 (#93909)
regrtest now also implements checking for leaked temporary files and
directories when using -jN for N >= 2. Use tempfile.mkdtemp() to
create the temporary directory. Skip this check on WASI.
(cherry picked from commit 4f85cec9e2077681b3dacc3108e646d509b720bf)
* gh-84461: Fix Emscripten umask and permission issues (GH-94002)
- Emscripten's default umask is too strict, see
https://github.com/emscripten-core/emscripten/issues/17269
- getuid/getgid and geteuid/getegid are stubs that always return 0
(root). Disable effective uid/gid syscalls and fix tests that use
chmod() current user.
- Cannot drop X bit from directory.
(cherry picked from commit 2702e408fd0e0dd7aec396b4cf8c7ce9caae81d8)
* gh-94052: Don't re-run failed tests with --python option (#94054)
(cherry picked from commit 0ff7b996f5d836e63cdaf652c7aa734285261096)
* Run Tools/scripts/reindent.py (#94225)
Reindent files which were not properly formatted (PEP 8: 4 spaces).
Remove also some trailing spaces.
(cherry picked from commit e87ada48a9e5d9d03f9759138869216df0d7383a)
* gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253)
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 199ba233248ab279f445e0809c2077976f0711bc)
* gh-96465: Clear fractions hash lru_cache under refleak testing (GH-96689)
Automerge-Triggered-By: GH:zware
(cherry picked from commit 9c8f3794337457b1d905a9fa0f38c2978fe32abd)
* gh-95027: Fix regrtest stdout encoding on Windows (#98492)
On Windows, when the Python test suite is run with the -jN option,
the ANSI code page is now used as the encoding for the stdout
temporary file, rather than using UTF-8 which can lead to decoding
errors.
(cherry picked from commit ec1f6f5f139868dc2c1116a7c7c878c38c668d53)
* gh-98903: Test suite fails with exit code 4 if no tests ran (#98904)
The Python test suite now fails wit exit code 4 if no tests ran. It
should help detecting typos in test names and test methods.
* Add "EXITCODE_" constants to Lib/test/libregrtest/main.py.
* Fix a typo: "NO TEST RUN" becomes "NO TESTS RAN"
(cherry picked from commit c76db37c0d23174cbffd6fa978d39693890ef020)
* gh-100086: Add build info to test.libregrtest (#100093)
The Python test runner (libregrtest) now logs Python build information like
"debug" vs "release" build, or LTO and PGO optimizations.
(cherry picked from commit 3c892022472eb975360fb3f0caa6f6fcc6fbf220)
* bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (#30895)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
(cherry picked from commit 995386071f96e4cfebfa027a71ca9134e4651d2a)
* gh-82054: allow test runner to split test_asyncio to execute in parallel by sharding. (#103927)
This runs test_asyncio sub-tests in parallel using sharding from Cinder. This suite is typically the longest-pole in runs because it is a test package with a lot of further sub-tests otherwise run serially. By breaking out the sub-tests as independent modules we can run a lot more in parallel.
After porting we can see the direct impact on a multicore system.
Without this change:
Running make test is 5 min 26 seconds
With this change:
Running make test takes 3 min 39 seconds
That'll vary based on system and parallelism. On a `-j 4` run similar to what CI and buildbot systems often do, it reduced the overall test suite completion latency by 10%.
The drawbacks are that this implementation is hacky and due to the sorting of the tests it obscures when the asyncio tests occur and involves changing CPython test infrastructure but, the wall time saved it is worth it, especially in low-core count CI runs as it pulls a long tail. The win for productivity and reserved CI resource usage is significant.
Future tests that deserve to be refactored into split up suites to benefit from are test_concurrent_futures and the way the _test_multiprocessing suite gets run for all start methods. As exposed by passing the -o flag to python -m test to get a list of the 10 longest running tests.
---------
Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google, LLC]
(cherry picked from commit 9e011e7c77dad7d0bbb944c44891531606caeb21)
* Display the sanitizer config in the regrtest header. (#105301)
Display the sanitizers present in libregrtest.
Having this in the CI output for tests with the relevant environment
variable displayed will help make it easier to do what we need to
create an equivalent local test run.
(cherry picked from commit 852348ab65783601e0844b6647ea033668b45c11)
* gh-101634: regrtest reports decoding error as failed test (#106169)
When running the Python test suite with -jN option, if a worker stdout
cannot be decoded from the locale encoding report a failed testn so the
exitcode is non-zero.
(cherry picked from commit 2ac3eec103cf450aaaebeb932e51155d2e7fb37b)
* gh-108223: test.pythoninfo and libregrtest log Py_NOGIL (#108238)
Enable with --disable-gil --without-pydebug:
$ make pythoninfo|grep NOGIL
sysconfig[Py_NOGIL]: 1
$ ./python -m test
...
== Python build: nogil debug
...
(cherry picked from commit 5afe0c17ca14df430736e549542a4b85e7e7c7ac)
* gh-90791: test.pythoninfo logs ASAN_OPTIONS env var (#108289)
* Cleanup libregrtest code logging ASAN_OPTIONS.
* Fix a typo on "ASAN_OPTIONS" vs "MSAN_OPTIONS".
(cherry picked from commit 3a1ac87f8f89d3206b46a0df4908afae629d669d)
* gh-108388: regrtest splits test_asyncio package (#108393)
Currently, test_asyncio package is only splitted into sub-tests when
using command "./python -m test". With this change, it's also
splitted when passing it on the command line:
"./python -m test test_asyncio".
Remove the concept of "STDTESTS". Python is now mature enough to not
have to bother with that anymore. Removing STDTESTS simplify the
code.
(cherry picked from commit 174e9da0836844a2138cc8915dd305cb2cd7a583)
* regrtest computes statistics (#108793)
test_netrc, test_pep646_syntax and test_xml_etree now return results
in the test_main() function.
Changes:
* Rewrite TestResult as a dataclass with a new State class.
* Add test.support.TestStats class and Regrtest.stats_dict attribute.
* libregrtest.runtest functions now modify a TestResult instance
in-place.
* libregrtest summary lists the number of run tests and skipped
tests, and denied resources.
* Add TestResult.has_meaningful_duration() method.
* Compute TestResult duration in the upper function.
* Use time.perf_counter() instead of time.monotonic().
* Regrtest: rename 'resource_denieds' attribute to 'resource_denied'.
* Rename CHILD_ERROR to MULTIPROCESSING_ERROR.
* Use match/case syntadx to have different code depending on the
test state.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit d4e534cbb35678c82b3a1276826af55d7bfc23b6)
* gh-108822: Add Changelog entry for regrtest statistics (#108821)
---------
Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Zachary Ware <zach@python.org>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Joshua Herman <zitterbewegung@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-09-03 19:21:53 +02:00
|
|
|
fail_env_changed=True, stats=1)
|
2017-06-26 18:33:19 +02:00
|
|
|
|
2018-06-08 09:53:51 +02:00
|
|
|
def test_rerun_fail(self):
|
2019-04-26 09:56:37 +02:00
|
|
|
# FAILURE then FAILURE
|
2018-06-08 09:53:51 +02:00
|
|
|
code = textwrap.dedent("""
|
|
|
|
|
import unittest
|
|
|
|
|
|
|
|
|
|
class Tests(unittest.TestCase):
|
2021-07-22 20:25:58 +02:00
|
|
|
def test_succeed(self):
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
def test_fail_always(self):
|
|
|
|
|
# test that always fails
|
2018-06-08 09:53:51 +02:00
|
|
|
self.fail("bug")
|
|
|
|
|
""")
|
|
|
|
|
testname = self.create_test(code=code)
|
|
|
|
|
|
[3.11] gh-108822: Backport libregrtest changes from the main branch (#108820)
* Revert "[3.11] gh-101634: regrtest reports decoding error as failed test (#106169) (#106175)"
This reverts commit d5418e97fc524420011a370ba3c2c3cf6a89a74f.
* Revert "[3.11] bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (GH-30895) (GH-103342)"
This reverts commit ecb09a849689764193e0115d27e220f82b5f6d9f.
* Revert "gh-95027: Fix regrtest stdout encoding on Windows (GH-98492)"
This reverts commit b2aa28eec56d07b9c6777b02b7247cf21839de9f.
* Revert "[3.11] gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253) (GH-94408)"
This reverts commit 0122ab235b5acb52dd99fd05d8802a00f438b828.
* Revert "Run Tools/scripts/reindent.py (GH-94225)"
This reverts commit f0f3a424afb00a15ce8c0140dd218f5b33929be6.
* Revert "gh-94052: Don't re-run failed tests with --python option (GH-94054)"
This reverts commit 1347607db12012f6458ffcba48d8ad797083812e.
* Revert "[3.11] gh-84461: Fix Emscripten umask and permission issues (GH-94002) (GH-94006)"
This reverts commit 10731849184a3101ed18683b0128d689f1671c3f.
* gh-93353: regrtest checks for leaked temporary files (#93776)
When running tests with -jN, create a temporary directory per process
and mark a test as "environment changed" if a test leaks a temporary
file or directory.
(cherry picked from commit e566ce5496f1bad81c431aaee65e36d5e44771c5)
* gh-93353: Fix regrtest for -jN with N >= 2 (GH-93813)
(cherry picked from commit 36934a16e86f34d69ba2d41630fb5b4d06d59cff)
* gh-93353: regrtest supports checking tmp files with -j2 (#93909)
regrtest now also implements checking for leaked temporary files and
directories when using -jN for N >= 2. Use tempfile.mkdtemp() to
create the temporary directory. Skip this check on WASI.
(cherry picked from commit 4f85cec9e2077681b3dacc3108e646d509b720bf)
* gh-84461: Fix Emscripten umask and permission issues (GH-94002)
- Emscripten's default umask is too strict, see
https://github.com/emscripten-core/emscripten/issues/17269
- getuid/getgid and geteuid/getegid are stubs that always return 0
(root). Disable effective uid/gid syscalls and fix tests that use
chmod() current user.
- Cannot drop X bit from directory.
(cherry picked from commit 2702e408fd0e0dd7aec396b4cf8c7ce9caae81d8)
* gh-94052: Don't re-run failed tests with --python option (#94054)
(cherry picked from commit 0ff7b996f5d836e63cdaf652c7aa734285261096)
* Run Tools/scripts/reindent.py (#94225)
Reindent files which were not properly formatted (PEP 8: 4 spaces).
Remove also some trailing spaces.
(cherry picked from commit e87ada48a9e5d9d03f9759138869216df0d7383a)
* gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253)
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 199ba233248ab279f445e0809c2077976f0711bc)
* gh-96465: Clear fractions hash lru_cache under refleak testing (GH-96689)
Automerge-Triggered-By: GH:zware
(cherry picked from commit 9c8f3794337457b1d905a9fa0f38c2978fe32abd)
* gh-95027: Fix regrtest stdout encoding on Windows (#98492)
On Windows, when the Python test suite is run with the -jN option,
the ANSI code page is now used as the encoding for the stdout
temporary file, rather than using UTF-8 which can lead to decoding
errors.
(cherry picked from commit ec1f6f5f139868dc2c1116a7c7c878c38c668d53)
* gh-98903: Test suite fails with exit code 4 if no tests ran (#98904)
The Python test suite now fails wit exit code 4 if no tests ran. It
should help detecting typos in test names and test methods.
* Add "EXITCODE_" constants to Lib/test/libregrtest/main.py.
* Fix a typo: "NO TEST RUN" becomes "NO TESTS RAN"
(cherry picked from commit c76db37c0d23174cbffd6fa978d39693890ef020)
* gh-100086: Add build info to test.libregrtest (#100093)
The Python test runner (libregrtest) now logs Python build information like
"debug" vs "release" build, or LTO and PGO optimizations.
(cherry picked from commit 3c892022472eb975360fb3f0caa6f6fcc6fbf220)
* bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (#30895)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
(cherry picked from commit 995386071f96e4cfebfa027a71ca9134e4651d2a)
* gh-82054: allow test runner to split test_asyncio to execute in parallel by sharding. (#103927)
This runs test_asyncio sub-tests in parallel using sharding from Cinder. This suite is typically the longest-pole in runs because it is a test package with a lot of further sub-tests otherwise run serially. By breaking out the sub-tests as independent modules we can run a lot more in parallel.
After porting we can see the direct impact on a multicore system.
Without this change:
Running make test is 5 min 26 seconds
With this change:
Running make test takes 3 min 39 seconds
That'll vary based on system and parallelism. On a `-j 4` run similar to what CI and buildbot systems often do, it reduced the overall test suite completion latency by 10%.
The drawbacks are that this implementation is hacky and due to the sorting of the tests it obscures when the asyncio tests occur and involves changing CPython test infrastructure but, the wall time saved it is worth it, especially in low-core count CI runs as it pulls a long tail. The win for productivity and reserved CI resource usage is significant.
Future tests that deserve to be refactored into split up suites to benefit from are test_concurrent_futures and the way the _test_multiprocessing suite gets run for all start methods. As exposed by passing the -o flag to python -m test to get a list of the 10 longest running tests.
---------
Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google, LLC]
(cherry picked from commit 9e011e7c77dad7d0bbb944c44891531606caeb21)
* Display the sanitizer config in the regrtest header. (#105301)
Display the sanitizers present in libregrtest.
Having this in the CI output for tests with the relevant environment
variable displayed will help make it easier to do what we need to
create an equivalent local test run.
(cherry picked from commit 852348ab65783601e0844b6647ea033668b45c11)
* gh-101634: regrtest reports decoding error as failed test (#106169)
When running the Python test suite with -jN option, if a worker stdout
cannot be decoded from the locale encoding report a failed testn so the
exitcode is non-zero.
(cherry picked from commit 2ac3eec103cf450aaaebeb932e51155d2e7fb37b)
* gh-108223: test.pythoninfo and libregrtest log Py_NOGIL (#108238)
Enable with --disable-gil --without-pydebug:
$ make pythoninfo|grep NOGIL
sysconfig[Py_NOGIL]: 1
$ ./python -m test
...
== Python build: nogil debug
...
(cherry picked from commit 5afe0c17ca14df430736e549542a4b85e7e7c7ac)
* gh-90791: test.pythoninfo logs ASAN_OPTIONS env var (#108289)
* Cleanup libregrtest code logging ASAN_OPTIONS.
* Fix a typo on "ASAN_OPTIONS" vs "MSAN_OPTIONS".
(cherry picked from commit 3a1ac87f8f89d3206b46a0df4908afae629d669d)
* gh-108388: regrtest splits test_asyncio package (#108393)
Currently, test_asyncio package is only splitted into sub-tests when
using command "./python -m test". With this change, it's also
splitted when passing it on the command line:
"./python -m test test_asyncio".
Remove the concept of "STDTESTS". Python is now mature enough to not
have to bother with that anymore. Removing STDTESTS simplify the
code.
(cherry picked from commit 174e9da0836844a2138cc8915dd305cb2cd7a583)
* regrtest computes statistics (#108793)
test_netrc, test_pep646_syntax and test_xml_etree now return results
in the test_main() function.
Changes:
* Rewrite TestResult as a dataclass with a new State class.
* Add test.support.TestStats class and Regrtest.stats_dict attribute.
* libregrtest.runtest functions now modify a TestResult instance
in-place.
* libregrtest summary lists the number of run tests and skipped
tests, and denied resources.
* Add TestResult.has_meaningful_duration() method.
* Compute TestResult duration in the upper function.
* Use time.perf_counter() instead of time.monotonic().
* Regrtest: rename 'resource_denieds' attribute to 'resource_denied'.
* Rename CHILD_ERROR to MULTIPROCESSING_ERROR.
* Use match/case syntadx to have different code depending on the
test state.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit d4e534cbb35678c82b3a1276826af55d7bfc23b6)
* gh-108822: Add Changelog entry for regrtest statistics (#108821)
---------
Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Zachary Ware <zach@python.org>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Joshua Herman <zitterbewegung@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-09-03 19:21:53 +02:00
|
|
|
output = self.run_tests("-w", testname, exitcode=EXITCODE_BAD_TEST)
|
2018-06-08 09:53:51 +02:00
|
|
|
self.check_executed_tests(output, [testname],
|
[3.11] gh-108822: Backport libregrtest changes from the main branch (#108820)
* Revert "[3.11] gh-101634: regrtest reports decoding error as failed test (#106169) (#106175)"
This reverts commit d5418e97fc524420011a370ba3c2c3cf6a89a74f.
* Revert "[3.11] bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (GH-30895) (GH-103342)"
This reverts commit ecb09a849689764193e0115d27e220f82b5f6d9f.
* Revert "gh-95027: Fix regrtest stdout encoding on Windows (GH-98492)"
This reverts commit b2aa28eec56d07b9c6777b02b7247cf21839de9f.
* Revert "[3.11] gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253) (GH-94408)"
This reverts commit 0122ab235b5acb52dd99fd05d8802a00f438b828.
* Revert "Run Tools/scripts/reindent.py (GH-94225)"
This reverts commit f0f3a424afb00a15ce8c0140dd218f5b33929be6.
* Revert "gh-94052: Don't re-run failed tests with --python option (GH-94054)"
This reverts commit 1347607db12012f6458ffcba48d8ad797083812e.
* Revert "[3.11] gh-84461: Fix Emscripten umask and permission issues (GH-94002) (GH-94006)"
This reverts commit 10731849184a3101ed18683b0128d689f1671c3f.
* gh-93353: regrtest checks for leaked temporary files (#93776)
When running tests with -jN, create a temporary directory per process
and mark a test as "environment changed" if a test leaks a temporary
file or directory.
(cherry picked from commit e566ce5496f1bad81c431aaee65e36d5e44771c5)
* gh-93353: Fix regrtest for -jN with N >= 2 (GH-93813)
(cherry picked from commit 36934a16e86f34d69ba2d41630fb5b4d06d59cff)
* gh-93353: regrtest supports checking tmp files with -j2 (#93909)
regrtest now also implements checking for leaked temporary files and
directories when using -jN for N >= 2. Use tempfile.mkdtemp() to
create the temporary directory. Skip this check on WASI.
(cherry picked from commit 4f85cec9e2077681b3dacc3108e646d509b720bf)
* gh-84461: Fix Emscripten umask and permission issues (GH-94002)
- Emscripten's default umask is too strict, see
https://github.com/emscripten-core/emscripten/issues/17269
- getuid/getgid and geteuid/getegid are stubs that always return 0
(root). Disable effective uid/gid syscalls and fix tests that use
chmod() current user.
- Cannot drop X bit from directory.
(cherry picked from commit 2702e408fd0e0dd7aec396b4cf8c7ce9caae81d8)
* gh-94052: Don't re-run failed tests with --python option (#94054)
(cherry picked from commit 0ff7b996f5d836e63cdaf652c7aa734285261096)
* Run Tools/scripts/reindent.py (#94225)
Reindent files which were not properly formatted (PEP 8: 4 spaces).
Remove also some trailing spaces.
(cherry picked from commit e87ada48a9e5d9d03f9759138869216df0d7383a)
* gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253)
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 199ba233248ab279f445e0809c2077976f0711bc)
* gh-96465: Clear fractions hash lru_cache under refleak testing (GH-96689)
Automerge-Triggered-By: GH:zware
(cherry picked from commit 9c8f3794337457b1d905a9fa0f38c2978fe32abd)
* gh-95027: Fix regrtest stdout encoding on Windows (#98492)
On Windows, when the Python test suite is run with the -jN option,
the ANSI code page is now used as the encoding for the stdout
temporary file, rather than using UTF-8 which can lead to decoding
errors.
(cherry picked from commit ec1f6f5f139868dc2c1116a7c7c878c38c668d53)
* gh-98903: Test suite fails with exit code 4 if no tests ran (#98904)
The Python test suite now fails wit exit code 4 if no tests ran. It
should help detecting typos in test names and test methods.
* Add "EXITCODE_" constants to Lib/test/libregrtest/main.py.
* Fix a typo: "NO TEST RUN" becomes "NO TESTS RAN"
(cherry picked from commit c76db37c0d23174cbffd6fa978d39693890ef020)
* gh-100086: Add build info to test.libregrtest (#100093)
The Python test runner (libregrtest) now logs Python build information like
"debug" vs "release" build, or LTO and PGO optimizations.
(cherry picked from commit 3c892022472eb975360fb3f0caa6f6fcc6fbf220)
* bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (#30895)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
(cherry picked from commit 995386071f96e4cfebfa027a71ca9134e4651d2a)
* gh-82054: allow test runner to split test_asyncio to execute in parallel by sharding. (#103927)
This runs test_asyncio sub-tests in parallel using sharding from Cinder. This suite is typically the longest-pole in runs because it is a test package with a lot of further sub-tests otherwise run serially. By breaking out the sub-tests as independent modules we can run a lot more in parallel.
After porting we can see the direct impact on a multicore system.
Without this change:
Running make test is 5 min 26 seconds
With this change:
Running make test takes 3 min 39 seconds
That'll vary based on system and parallelism. On a `-j 4` run similar to what CI and buildbot systems often do, it reduced the overall test suite completion latency by 10%.
The drawbacks are that this implementation is hacky and due to the sorting of the tests it obscures when the asyncio tests occur and involves changing CPython test infrastructure but, the wall time saved it is worth it, especially in low-core count CI runs as it pulls a long tail. The win for productivity and reserved CI resource usage is significant.
Future tests that deserve to be refactored into split up suites to benefit from are test_concurrent_futures and the way the _test_multiprocessing suite gets run for all start methods. As exposed by passing the -o flag to python -m test to get a list of the 10 longest running tests.
---------
Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google, LLC]
(cherry picked from commit 9e011e7c77dad7d0bbb944c44891531606caeb21)
* Display the sanitizer config in the regrtest header. (#105301)
Display the sanitizers present in libregrtest.
Having this in the CI output for tests with the relevant environment
variable displayed will help make it easier to do what we need to
create an equivalent local test run.
(cherry picked from commit 852348ab65783601e0844b6647ea033668b45c11)
* gh-101634: regrtest reports decoding error as failed test (#106169)
When running the Python test suite with -jN option, if a worker stdout
cannot be decoded from the locale encoding report a failed testn so the
exitcode is non-zero.
(cherry picked from commit 2ac3eec103cf450aaaebeb932e51155d2e7fb37b)
* gh-108223: test.pythoninfo and libregrtest log Py_NOGIL (#108238)
Enable with --disable-gil --without-pydebug:
$ make pythoninfo|grep NOGIL
sysconfig[Py_NOGIL]: 1
$ ./python -m test
...
== Python build: nogil debug
...
(cherry picked from commit 5afe0c17ca14df430736e549542a4b85e7e7c7ac)
* gh-90791: test.pythoninfo logs ASAN_OPTIONS env var (#108289)
* Cleanup libregrtest code logging ASAN_OPTIONS.
* Fix a typo on "ASAN_OPTIONS" vs "MSAN_OPTIONS".
(cherry picked from commit 3a1ac87f8f89d3206b46a0df4908afae629d669d)
* gh-108388: regrtest splits test_asyncio package (#108393)
Currently, test_asyncio package is only splitted into sub-tests when
using command "./python -m test". With this change, it's also
splitted when passing it on the command line:
"./python -m test test_asyncio".
Remove the concept of "STDTESTS". Python is now mature enough to not
have to bother with that anymore. Removing STDTESTS simplify the
code.
(cherry picked from commit 174e9da0836844a2138cc8915dd305cb2cd7a583)
* regrtest computes statistics (#108793)
test_netrc, test_pep646_syntax and test_xml_etree now return results
in the test_main() function.
Changes:
* Rewrite TestResult as a dataclass with a new State class.
* Add test.support.TestStats class and Regrtest.stats_dict attribute.
* libregrtest.runtest functions now modify a TestResult instance
in-place.
* libregrtest summary lists the number of run tests and skipped
tests, and denied resources.
* Add TestResult.has_meaningful_duration() method.
* Compute TestResult duration in the upper function.
* Use time.perf_counter() instead of time.monotonic().
* Regrtest: rename 'resource_denieds' attribute to 'resource_denied'.
* Rename CHILD_ERROR to MULTIPROCESSING_ERROR.
* Use match/case syntadx to have different code depending on the
test state.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit d4e534cbb35678c82b3a1276826af55d7bfc23b6)
* gh-108822: Add Changelog entry for regrtest statistics (#108821)
---------
Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Zachary Ware <zach@python.org>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Joshua Herman <zitterbewegung@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-09-03 19:21:53 +02:00
|
|
|
failed=testname,
|
|
|
|
|
rerun={testname: "test_fail_always"},
|
|
|
|
|
stats=TestStats(1, 1))
|
2018-12-14 13:06:50 +01:00
|
|
|
|
2019-04-26 09:56:37 +02:00
|
|
|
def test_rerun_success(self):
|
|
|
|
|
# FAILURE then SUCCESS
|
|
|
|
|
code = textwrap.dedent("""
|
|
|
|
|
import builtins
|
|
|
|
|
import unittest
|
|
|
|
|
|
|
|
|
|
class Tests(unittest.TestCase):
|
2021-07-22 20:25:58 +02:00
|
|
|
def test_succeed(self):
|
|
|
|
|
return
|
2019-04-26 09:56:37 +02:00
|
|
|
|
|
|
|
|
def test_fail_once(self):
|
|
|
|
|
if not hasattr(builtins, '_test_failed'):
|
|
|
|
|
builtins._test_failed = True
|
|
|
|
|
self.fail("bug")
|
|
|
|
|
""")
|
|
|
|
|
testname = self.create_test(code=code)
|
|
|
|
|
|
|
|
|
|
output = self.run_tests("-w", testname, exitcode=0)
|
|
|
|
|
self.check_executed_tests(output, [testname],
|
[3.11] gh-108822: Backport libregrtest changes from the main branch (#108820)
* Revert "[3.11] gh-101634: regrtest reports decoding error as failed test (#106169) (#106175)"
This reverts commit d5418e97fc524420011a370ba3c2c3cf6a89a74f.
* Revert "[3.11] bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (GH-30895) (GH-103342)"
This reverts commit ecb09a849689764193e0115d27e220f82b5f6d9f.
* Revert "gh-95027: Fix regrtest stdout encoding on Windows (GH-98492)"
This reverts commit b2aa28eec56d07b9c6777b02b7247cf21839de9f.
* Revert "[3.11] gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253) (GH-94408)"
This reverts commit 0122ab235b5acb52dd99fd05d8802a00f438b828.
* Revert "Run Tools/scripts/reindent.py (GH-94225)"
This reverts commit f0f3a424afb00a15ce8c0140dd218f5b33929be6.
* Revert "gh-94052: Don't re-run failed tests with --python option (GH-94054)"
This reverts commit 1347607db12012f6458ffcba48d8ad797083812e.
* Revert "[3.11] gh-84461: Fix Emscripten umask and permission issues (GH-94002) (GH-94006)"
This reverts commit 10731849184a3101ed18683b0128d689f1671c3f.
* gh-93353: regrtest checks for leaked temporary files (#93776)
When running tests with -jN, create a temporary directory per process
and mark a test as "environment changed" if a test leaks a temporary
file or directory.
(cherry picked from commit e566ce5496f1bad81c431aaee65e36d5e44771c5)
* gh-93353: Fix regrtest for -jN with N >= 2 (GH-93813)
(cherry picked from commit 36934a16e86f34d69ba2d41630fb5b4d06d59cff)
* gh-93353: regrtest supports checking tmp files with -j2 (#93909)
regrtest now also implements checking for leaked temporary files and
directories when using -jN for N >= 2. Use tempfile.mkdtemp() to
create the temporary directory. Skip this check on WASI.
(cherry picked from commit 4f85cec9e2077681b3dacc3108e646d509b720bf)
* gh-84461: Fix Emscripten umask and permission issues (GH-94002)
- Emscripten's default umask is too strict, see
https://github.com/emscripten-core/emscripten/issues/17269
- getuid/getgid and geteuid/getegid are stubs that always return 0
(root). Disable effective uid/gid syscalls and fix tests that use
chmod() current user.
- Cannot drop X bit from directory.
(cherry picked from commit 2702e408fd0e0dd7aec396b4cf8c7ce9caae81d8)
* gh-94052: Don't re-run failed tests with --python option (#94054)
(cherry picked from commit 0ff7b996f5d836e63cdaf652c7aa734285261096)
* Run Tools/scripts/reindent.py (#94225)
Reindent files which were not properly formatted (PEP 8: 4 spaces).
Remove also some trailing spaces.
(cherry picked from commit e87ada48a9e5d9d03f9759138869216df0d7383a)
* gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253)
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 199ba233248ab279f445e0809c2077976f0711bc)
* gh-96465: Clear fractions hash lru_cache under refleak testing (GH-96689)
Automerge-Triggered-By: GH:zware
(cherry picked from commit 9c8f3794337457b1d905a9fa0f38c2978fe32abd)
* gh-95027: Fix regrtest stdout encoding on Windows (#98492)
On Windows, when the Python test suite is run with the -jN option,
the ANSI code page is now used as the encoding for the stdout
temporary file, rather than using UTF-8 which can lead to decoding
errors.
(cherry picked from commit ec1f6f5f139868dc2c1116a7c7c878c38c668d53)
* gh-98903: Test suite fails with exit code 4 if no tests ran (#98904)
The Python test suite now fails wit exit code 4 if no tests ran. It
should help detecting typos in test names and test methods.
* Add "EXITCODE_" constants to Lib/test/libregrtest/main.py.
* Fix a typo: "NO TEST RUN" becomes "NO TESTS RAN"
(cherry picked from commit c76db37c0d23174cbffd6fa978d39693890ef020)
* gh-100086: Add build info to test.libregrtest (#100093)
The Python test runner (libregrtest) now logs Python build information like
"debug" vs "release" build, or LTO and PGO optimizations.
(cherry picked from commit 3c892022472eb975360fb3f0caa6f6fcc6fbf220)
* bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (#30895)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
(cherry picked from commit 995386071f96e4cfebfa027a71ca9134e4651d2a)
* gh-82054: allow test runner to split test_asyncio to execute in parallel by sharding. (#103927)
This runs test_asyncio sub-tests in parallel using sharding from Cinder. This suite is typically the longest-pole in runs because it is a test package with a lot of further sub-tests otherwise run serially. By breaking out the sub-tests as independent modules we can run a lot more in parallel.
After porting we can see the direct impact on a multicore system.
Without this change:
Running make test is 5 min 26 seconds
With this change:
Running make test takes 3 min 39 seconds
That'll vary based on system and parallelism. On a `-j 4` run similar to what CI and buildbot systems often do, it reduced the overall test suite completion latency by 10%.
The drawbacks are that this implementation is hacky and due to the sorting of the tests it obscures when the asyncio tests occur and involves changing CPython test infrastructure but, the wall time saved it is worth it, especially in low-core count CI runs as it pulls a long tail. The win for productivity and reserved CI resource usage is significant.
Future tests that deserve to be refactored into split up suites to benefit from are test_concurrent_futures and the way the _test_multiprocessing suite gets run for all start methods. As exposed by passing the -o flag to python -m test to get a list of the 10 longest running tests.
---------
Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google, LLC]
(cherry picked from commit 9e011e7c77dad7d0bbb944c44891531606caeb21)
* Display the sanitizer config in the regrtest header. (#105301)
Display the sanitizers present in libregrtest.
Having this in the CI output for tests with the relevant environment
variable displayed will help make it easier to do what we need to
create an equivalent local test run.
(cherry picked from commit 852348ab65783601e0844b6647ea033668b45c11)
* gh-101634: regrtest reports decoding error as failed test (#106169)
When running the Python test suite with -jN option, if a worker stdout
cannot be decoded from the locale encoding report a failed testn so the
exitcode is non-zero.
(cherry picked from commit 2ac3eec103cf450aaaebeb932e51155d2e7fb37b)
* gh-108223: test.pythoninfo and libregrtest log Py_NOGIL (#108238)
Enable with --disable-gil --without-pydebug:
$ make pythoninfo|grep NOGIL
sysconfig[Py_NOGIL]: 1
$ ./python -m test
...
== Python build: nogil debug
...
(cherry picked from commit 5afe0c17ca14df430736e549542a4b85e7e7c7ac)
* gh-90791: test.pythoninfo logs ASAN_OPTIONS env var (#108289)
* Cleanup libregrtest code logging ASAN_OPTIONS.
* Fix a typo on "ASAN_OPTIONS" vs "MSAN_OPTIONS".
(cherry picked from commit 3a1ac87f8f89d3206b46a0df4908afae629d669d)
* gh-108388: regrtest splits test_asyncio package (#108393)
Currently, test_asyncio package is only splitted into sub-tests when
using command "./python -m test". With this change, it's also
splitted when passing it on the command line:
"./python -m test test_asyncio".
Remove the concept of "STDTESTS". Python is now mature enough to not
have to bother with that anymore. Removing STDTESTS simplify the
code.
(cherry picked from commit 174e9da0836844a2138cc8915dd305cb2cd7a583)
* regrtest computes statistics (#108793)
test_netrc, test_pep646_syntax and test_xml_etree now return results
in the test_main() function.
Changes:
* Rewrite TestResult as a dataclass with a new State class.
* Add test.support.TestStats class and Regrtest.stats_dict attribute.
* libregrtest.runtest functions now modify a TestResult instance
in-place.
* libregrtest summary lists the number of run tests and skipped
tests, and denied resources.
* Add TestResult.has_meaningful_duration() method.
* Compute TestResult duration in the upper function.
* Use time.perf_counter() instead of time.monotonic().
* Regrtest: rename 'resource_denieds' attribute to 'resource_denied'.
* Rename CHILD_ERROR to MULTIPROCESSING_ERROR.
* Use match/case syntadx to have different code depending on the
test state.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit d4e534cbb35678c82b3a1276826af55d7bfc23b6)
* gh-108822: Add Changelog entry for regrtest statistics (#108821)
---------
Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Zachary Ware <zach@python.org>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Joshua Herman <zitterbewegung@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-09-03 19:21:53 +02:00
|
|
|
rerun={testname: "test_fail_once"},
|
|
|
|
|
stats=1)
|
2019-04-26 09:56:37 +02:00
|
|
|
|
2023-04-07 19:35:16 +02:00
|
|
|
def test_rerun_setup_class_hook_failure(self):
|
|
|
|
|
# FAILURE then FAILURE
|
|
|
|
|
code = textwrap.dedent("""
|
|
|
|
|
import unittest
|
|
|
|
|
|
|
|
|
|
class ExampleTests(unittest.TestCase):
|
|
|
|
|
@classmethod
|
|
|
|
|
def setUpClass(self):
|
|
|
|
|
raise RuntimeError('Fail')
|
|
|
|
|
|
|
|
|
|
def test_success(self):
|
|
|
|
|
return
|
|
|
|
|
""")
|
|
|
|
|
testname = self.create_test(code=code)
|
|
|
|
|
|
|
|
|
|
output = self.run_tests("-w", testname, exitcode=EXITCODE_BAD_TEST)
|
|
|
|
|
self.check_executed_tests(output, testname,
|
|
|
|
|
failed=[testname],
|
[3.11] gh-108822: Backport libregrtest changes from the main branch (#108820)
* Revert "[3.11] gh-101634: regrtest reports decoding error as failed test (#106169) (#106175)"
This reverts commit d5418e97fc524420011a370ba3c2c3cf6a89a74f.
* Revert "[3.11] bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (GH-30895) (GH-103342)"
This reverts commit ecb09a849689764193e0115d27e220f82b5f6d9f.
* Revert "gh-95027: Fix regrtest stdout encoding on Windows (GH-98492)"
This reverts commit b2aa28eec56d07b9c6777b02b7247cf21839de9f.
* Revert "[3.11] gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253) (GH-94408)"
This reverts commit 0122ab235b5acb52dd99fd05d8802a00f438b828.
* Revert "Run Tools/scripts/reindent.py (GH-94225)"
This reverts commit f0f3a424afb00a15ce8c0140dd218f5b33929be6.
* Revert "gh-94052: Don't re-run failed tests with --python option (GH-94054)"
This reverts commit 1347607db12012f6458ffcba48d8ad797083812e.
* Revert "[3.11] gh-84461: Fix Emscripten umask and permission issues (GH-94002) (GH-94006)"
This reverts commit 10731849184a3101ed18683b0128d689f1671c3f.
* gh-93353: regrtest checks for leaked temporary files (#93776)
When running tests with -jN, create a temporary directory per process
and mark a test as "environment changed" if a test leaks a temporary
file or directory.
(cherry picked from commit e566ce5496f1bad81c431aaee65e36d5e44771c5)
* gh-93353: Fix regrtest for -jN with N >= 2 (GH-93813)
(cherry picked from commit 36934a16e86f34d69ba2d41630fb5b4d06d59cff)
* gh-93353: regrtest supports checking tmp files with -j2 (#93909)
regrtest now also implements checking for leaked temporary files and
directories when using -jN for N >= 2. Use tempfile.mkdtemp() to
create the temporary directory. Skip this check on WASI.
(cherry picked from commit 4f85cec9e2077681b3dacc3108e646d509b720bf)
* gh-84461: Fix Emscripten umask and permission issues (GH-94002)
- Emscripten's default umask is too strict, see
https://github.com/emscripten-core/emscripten/issues/17269
- getuid/getgid and geteuid/getegid are stubs that always return 0
(root). Disable effective uid/gid syscalls and fix tests that use
chmod() current user.
- Cannot drop X bit from directory.
(cherry picked from commit 2702e408fd0e0dd7aec396b4cf8c7ce9caae81d8)
* gh-94052: Don't re-run failed tests with --python option (#94054)
(cherry picked from commit 0ff7b996f5d836e63cdaf652c7aa734285261096)
* Run Tools/scripts/reindent.py (#94225)
Reindent files which were not properly formatted (PEP 8: 4 spaces).
Remove also some trailing spaces.
(cherry picked from commit e87ada48a9e5d9d03f9759138869216df0d7383a)
* gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253)
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 199ba233248ab279f445e0809c2077976f0711bc)
* gh-96465: Clear fractions hash lru_cache under refleak testing (GH-96689)
Automerge-Triggered-By: GH:zware
(cherry picked from commit 9c8f3794337457b1d905a9fa0f38c2978fe32abd)
* gh-95027: Fix regrtest stdout encoding on Windows (#98492)
On Windows, when the Python test suite is run with the -jN option,
the ANSI code page is now used as the encoding for the stdout
temporary file, rather than using UTF-8 which can lead to decoding
errors.
(cherry picked from commit ec1f6f5f139868dc2c1116a7c7c878c38c668d53)
* gh-98903: Test suite fails with exit code 4 if no tests ran (#98904)
The Python test suite now fails wit exit code 4 if no tests ran. It
should help detecting typos in test names and test methods.
* Add "EXITCODE_" constants to Lib/test/libregrtest/main.py.
* Fix a typo: "NO TEST RUN" becomes "NO TESTS RAN"
(cherry picked from commit c76db37c0d23174cbffd6fa978d39693890ef020)
* gh-100086: Add build info to test.libregrtest (#100093)
The Python test runner (libregrtest) now logs Python build information like
"debug" vs "release" build, or LTO and PGO optimizations.
(cherry picked from commit 3c892022472eb975360fb3f0caa6f6fcc6fbf220)
* bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (#30895)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
(cherry picked from commit 995386071f96e4cfebfa027a71ca9134e4651d2a)
* gh-82054: allow test runner to split test_asyncio to execute in parallel by sharding. (#103927)
This runs test_asyncio sub-tests in parallel using sharding from Cinder. This suite is typically the longest-pole in runs because it is a test package with a lot of further sub-tests otherwise run serially. By breaking out the sub-tests as independent modules we can run a lot more in parallel.
After porting we can see the direct impact on a multicore system.
Without this change:
Running make test is 5 min 26 seconds
With this change:
Running make test takes 3 min 39 seconds
That'll vary based on system and parallelism. On a `-j 4` run similar to what CI and buildbot systems often do, it reduced the overall test suite completion latency by 10%.
The drawbacks are that this implementation is hacky and due to the sorting of the tests it obscures when the asyncio tests occur and involves changing CPython test infrastructure but, the wall time saved it is worth it, especially in low-core count CI runs as it pulls a long tail. The win for productivity and reserved CI resource usage is significant.
Future tests that deserve to be refactored into split up suites to benefit from are test_concurrent_futures and the way the _test_multiprocessing suite gets run for all start methods. As exposed by passing the -o flag to python -m test to get a list of the 10 longest running tests.
---------
Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google, LLC]
(cherry picked from commit 9e011e7c77dad7d0bbb944c44891531606caeb21)
* Display the sanitizer config in the regrtest header. (#105301)
Display the sanitizers present in libregrtest.
Having this in the CI output for tests with the relevant environment
variable displayed will help make it easier to do what we need to
create an equivalent local test run.
(cherry picked from commit 852348ab65783601e0844b6647ea033668b45c11)
* gh-101634: regrtest reports decoding error as failed test (#106169)
When running the Python test suite with -jN option, if a worker stdout
cannot be decoded from the locale encoding report a failed testn so the
exitcode is non-zero.
(cherry picked from commit 2ac3eec103cf450aaaebeb932e51155d2e7fb37b)
* gh-108223: test.pythoninfo and libregrtest log Py_NOGIL (#108238)
Enable with --disable-gil --without-pydebug:
$ make pythoninfo|grep NOGIL
sysconfig[Py_NOGIL]: 1
$ ./python -m test
...
== Python build: nogil debug
...
(cherry picked from commit 5afe0c17ca14df430736e549542a4b85e7e7c7ac)
* gh-90791: test.pythoninfo logs ASAN_OPTIONS env var (#108289)
* Cleanup libregrtest code logging ASAN_OPTIONS.
* Fix a typo on "ASAN_OPTIONS" vs "MSAN_OPTIONS".
(cherry picked from commit 3a1ac87f8f89d3206b46a0df4908afae629d669d)
* gh-108388: regrtest splits test_asyncio package (#108393)
Currently, test_asyncio package is only splitted into sub-tests when
using command "./python -m test". With this change, it's also
splitted when passing it on the command line:
"./python -m test test_asyncio".
Remove the concept of "STDTESTS". Python is now mature enough to not
have to bother with that anymore. Removing STDTESTS simplify the
code.
(cherry picked from commit 174e9da0836844a2138cc8915dd305cb2cd7a583)
* regrtest computes statistics (#108793)
test_netrc, test_pep646_syntax and test_xml_etree now return results
in the test_main() function.
Changes:
* Rewrite TestResult as a dataclass with a new State class.
* Add test.support.TestStats class and Regrtest.stats_dict attribute.
* libregrtest.runtest functions now modify a TestResult instance
in-place.
* libregrtest summary lists the number of run tests and skipped
tests, and denied resources.
* Add TestResult.has_meaningful_duration() method.
* Compute TestResult duration in the upper function.
* Use time.perf_counter() instead of time.monotonic().
* Regrtest: rename 'resource_denieds' attribute to 'resource_denied'.
* Rename CHILD_ERROR to MULTIPROCESSING_ERROR.
* Use match/case syntadx to have different code depending on the
test state.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit d4e534cbb35678c82b3a1276826af55d7bfc23b6)
* gh-108822: Add Changelog entry for regrtest statistics (#108821)
---------
Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Zachary Ware <zach@python.org>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Joshua Herman <zitterbewegung@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-09-03 19:21:53 +02:00
|
|
|
rerun={testname: "ExampleTests"},
|
|
|
|
|
stats=0)
|
2023-04-07 19:35:16 +02:00
|
|
|
|
|
|
|
|
def test_rerun_teardown_class_hook_failure(self):
|
|
|
|
|
# FAILURE then FAILURE
|
|
|
|
|
code = textwrap.dedent("""
|
|
|
|
|
import unittest
|
|
|
|
|
|
|
|
|
|
class ExampleTests(unittest.TestCase):
|
|
|
|
|
@classmethod
|
|
|
|
|
def tearDownClass(self):
|
|
|
|
|
raise RuntimeError('Fail')
|
|
|
|
|
|
|
|
|
|
def test_success(self):
|
|
|
|
|
return
|
|
|
|
|
""")
|
|
|
|
|
testname = self.create_test(code=code)
|
|
|
|
|
|
|
|
|
|
output = self.run_tests("-w", testname, exitcode=EXITCODE_BAD_TEST)
|
|
|
|
|
self.check_executed_tests(output, testname,
|
|
|
|
|
failed=[testname],
|
[3.11] gh-108822: Backport libregrtest changes from the main branch (#108820)
* Revert "[3.11] gh-101634: regrtest reports decoding error as failed test (#106169) (#106175)"
This reverts commit d5418e97fc524420011a370ba3c2c3cf6a89a74f.
* Revert "[3.11] bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (GH-30895) (GH-103342)"
This reverts commit ecb09a849689764193e0115d27e220f82b5f6d9f.
* Revert "gh-95027: Fix regrtest stdout encoding on Windows (GH-98492)"
This reverts commit b2aa28eec56d07b9c6777b02b7247cf21839de9f.
* Revert "[3.11] gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253) (GH-94408)"
This reverts commit 0122ab235b5acb52dd99fd05d8802a00f438b828.
* Revert "Run Tools/scripts/reindent.py (GH-94225)"
This reverts commit f0f3a424afb00a15ce8c0140dd218f5b33929be6.
* Revert "gh-94052: Don't re-run failed tests with --python option (GH-94054)"
This reverts commit 1347607db12012f6458ffcba48d8ad797083812e.
* Revert "[3.11] gh-84461: Fix Emscripten umask and permission issues (GH-94002) (GH-94006)"
This reverts commit 10731849184a3101ed18683b0128d689f1671c3f.
* gh-93353: regrtest checks for leaked temporary files (#93776)
When running tests with -jN, create a temporary directory per process
and mark a test as "environment changed" if a test leaks a temporary
file or directory.
(cherry picked from commit e566ce5496f1bad81c431aaee65e36d5e44771c5)
* gh-93353: Fix regrtest for -jN with N >= 2 (GH-93813)
(cherry picked from commit 36934a16e86f34d69ba2d41630fb5b4d06d59cff)
* gh-93353: regrtest supports checking tmp files with -j2 (#93909)
regrtest now also implements checking for leaked temporary files and
directories when using -jN for N >= 2. Use tempfile.mkdtemp() to
create the temporary directory. Skip this check on WASI.
(cherry picked from commit 4f85cec9e2077681b3dacc3108e646d509b720bf)
* gh-84461: Fix Emscripten umask and permission issues (GH-94002)
- Emscripten's default umask is too strict, see
https://github.com/emscripten-core/emscripten/issues/17269
- getuid/getgid and geteuid/getegid are stubs that always return 0
(root). Disable effective uid/gid syscalls and fix tests that use
chmod() current user.
- Cannot drop X bit from directory.
(cherry picked from commit 2702e408fd0e0dd7aec396b4cf8c7ce9caae81d8)
* gh-94052: Don't re-run failed tests with --python option (#94054)
(cherry picked from commit 0ff7b996f5d836e63cdaf652c7aa734285261096)
* Run Tools/scripts/reindent.py (#94225)
Reindent files which were not properly formatted (PEP 8: 4 spaces).
Remove also some trailing spaces.
(cherry picked from commit e87ada48a9e5d9d03f9759138869216df0d7383a)
* gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253)
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 199ba233248ab279f445e0809c2077976f0711bc)
* gh-96465: Clear fractions hash lru_cache under refleak testing (GH-96689)
Automerge-Triggered-By: GH:zware
(cherry picked from commit 9c8f3794337457b1d905a9fa0f38c2978fe32abd)
* gh-95027: Fix regrtest stdout encoding on Windows (#98492)
On Windows, when the Python test suite is run with the -jN option,
the ANSI code page is now used as the encoding for the stdout
temporary file, rather than using UTF-8 which can lead to decoding
errors.
(cherry picked from commit ec1f6f5f139868dc2c1116a7c7c878c38c668d53)
* gh-98903: Test suite fails with exit code 4 if no tests ran (#98904)
The Python test suite now fails wit exit code 4 if no tests ran. It
should help detecting typos in test names and test methods.
* Add "EXITCODE_" constants to Lib/test/libregrtest/main.py.
* Fix a typo: "NO TEST RUN" becomes "NO TESTS RAN"
(cherry picked from commit c76db37c0d23174cbffd6fa978d39693890ef020)
* gh-100086: Add build info to test.libregrtest (#100093)
The Python test runner (libregrtest) now logs Python build information like
"debug" vs "release" build, or LTO and PGO optimizations.
(cherry picked from commit 3c892022472eb975360fb3f0caa6f6fcc6fbf220)
* bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (#30895)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
(cherry picked from commit 995386071f96e4cfebfa027a71ca9134e4651d2a)
* gh-82054: allow test runner to split test_asyncio to execute in parallel by sharding. (#103927)
This runs test_asyncio sub-tests in parallel using sharding from Cinder. This suite is typically the longest-pole in runs because it is a test package with a lot of further sub-tests otherwise run serially. By breaking out the sub-tests as independent modules we can run a lot more in parallel.
After porting we can see the direct impact on a multicore system.
Without this change:
Running make test is 5 min 26 seconds
With this change:
Running make test takes 3 min 39 seconds
That'll vary based on system and parallelism. On a `-j 4` run similar to what CI and buildbot systems often do, it reduced the overall test suite completion latency by 10%.
The drawbacks are that this implementation is hacky and due to the sorting of the tests it obscures when the asyncio tests occur and involves changing CPython test infrastructure but, the wall time saved it is worth it, especially in low-core count CI runs as it pulls a long tail. The win for productivity and reserved CI resource usage is significant.
Future tests that deserve to be refactored into split up suites to benefit from are test_concurrent_futures and the way the _test_multiprocessing suite gets run for all start methods. As exposed by passing the -o flag to python -m test to get a list of the 10 longest running tests.
---------
Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google, LLC]
(cherry picked from commit 9e011e7c77dad7d0bbb944c44891531606caeb21)
* Display the sanitizer config in the regrtest header. (#105301)
Display the sanitizers present in libregrtest.
Having this in the CI output for tests with the relevant environment
variable displayed will help make it easier to do what we need to
create an equivalent local test run.
(cherry picked from commit 852348ab65783601e0844b6647ea033668b45c11)
* gh-101634: regrtest reports decoding error as failed test (#106169)
When running the Python test suite with -jN option, if a worker stdout
cannot be decoded from the locale encoding report a failed testn so the
exitcode is non-zero.
(cherry picked from commit 2ac3eec103cf450aaaebeb932e51155d2e7fb37b)
* gh-108223: test.pythoninfo and libregrtest log Py_NOGIL (#108238)
Enable with --disable-gil --without-pydebug:
$ make pythoninfo|grep NOGIL
sysconfig[Py_NOGIL]: 1
$ ./python -m test
...
== Python build: nogil debug
...
(cherry picked from commit 5afe0c17ca14df430736e549542a4b85e7e7c7ac)
* gh-90791: test.pythoninfo logs ASAN_OPTIONS env var (#108289)
* Cleanup libregrtest code logging ASAN_OPTIONS.
* Fix a typo on "ASAN_OPTIONS" vs "MSAN_OPTIONS".
(cherry picked from commit 3a1ac87f8f89d3206b46a0df4908afae629d669d)
* gh-108388: regrtest splits test_asyncio package (#108393)
Currently, test_asyncio package is only splitted into sub-tests when
using command "./python -m test". With this change, it's also
splitted when passing it on the command line:
"./python -m test test_asyncio".
Remove the concept of "STDTESTS". Python is now mature enough to not
have to bother with that anymore. Removing STDTESTS simplify the
code.
(cherry picked from commit 174e9da0836844a2138cc8915dd305cb2cd7a583)
* regrtest computes statistics (#108793)
test_netrc, test_pep646_syntax and test_xml_etree now return results
in the test_main() function.
Changes:
* Rewrite TestResult as a dataclass with a new State class.
* Add test.support.TestStats class and Regrtest.stats_dict attribute.
* libregrtest.runtest functions now modify a TestResult instance
in-place.
* libregrtest summary lists the number of run tests and skipped
tests, and denied resources.
* Add TestResult.has_meaningful_duration() method.
* Compute TestResult duration in the upper function.
* Use time.perf_counter() instead of time.monotonic().
* Regrtest: rename 'resource_denieds' attribute to 'resource_denied'.
* Rename CHILD_ERROR to MULTIPROCESSING_ERROR.
* Use match/case syntadx to have different code depending on the
test state.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit d4e534cbb35678c82b3a1276826af55d7bfc23b6)
* gh-108822: Add Changelog entry for regrtest statistics (#108821)
---------
Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Zachary Ware <zach@python.org>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Joshua Herman <zitterbewegung@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-09-03 19:21:53 +02:00
|
|
|
rerun={testname: "ExampleTests"},
|
|
|
|
|
stats=1)
|
2023-04-07 19:35:16 +02:00
|
|
|
|
|
|
|
|
def test_rerun_setup_module_hook_failure(self):
|
|
|
|
|
# FAILURE then FAILURE
|
|
|
|
|
code = textwrap.dedent("""
|
|
|
|
|
import unittest
|
|
|
|
|
|
|
|
|
|
def setUpModule():
|
|
|
|
|
raise RuntimeError('Fail')
|
|
|
|
|
|
|
|
|
|
class ExampleTests(unittest.TestCase):
|
|
|
|
|
def test_success(self):
|
|
|
|
|
return
|
|
|
|
|
""")
|
|
|
|
|
testname = self.create_test(code=code)
|
|
|
|
|
|
|
|
|
|
output = self.run_tests("-w", testname, exitcode=EXITCODE_BAD_TEST)
|
|
|
|
|
self.check_executed_tests(output, testname,
|
|
|
|
|
failed=[testname],
|
[3.11] gh-108822: Backport libregrtest changes from the main branch (#108820)
* Revert "[3.11] gh-101634: regrtest reports decoding error as failed test (#106169) (#106175)"
This reverts commit d5418e97fc524420011a370ba3c2c3cf6a89a74f.
* Revert "[3.11] bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (GH-30895) (GH-103342)"
This reverts commit ecb09a849689764193e0115d27e220f82b5f6d9f.
* Revert "gh-95027: Fix regrtest stdout encoding on Windows (GH-98492)"
This reverts commit b2aa28eec56d07b9c6777b02b7247cf21839de9f.
* Revert "[3.11] gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253) (GH-94408)"
This reverts commit 0122ab235b5acb52dd99fd05d8802a00f438b828.
* Revert "Run Tools/scripts/reindent.py (GH-94225)"
This reverts commit f0f3a424afb00a15ce8c0140dd218f5b33929be6.
* Revert "gh-94052: Don't re-run failed tests with --python option (GH-94054)"
This reverts commit 1347607db12012f6458ffcba48d8ad797083812e.
* Revert "[3.11] gh-84461: Fix Emscripten umask and permission issues (GH-94002) (GH-94006)"
This reverts commit 10731849184a3101ed18683b0128d689f1671c3f.
* gh-93353: regrtest checks for leaked temporary files (#93776)
When running tests with -jN, create a temporary directory per process
and mark a test as "environment changed" if a test leaks a temporary
file or directory.
(cherry picked from commit e566ce5496f1bad81c431aaee65e36d5e44771c5)
* gh-93353: Fix regrtest for -jN with N >= 2 (GH-93813)
(cherry picked from commit 36934a16e86f34d69ba2d41630fb5b4d06d59cff)
* gh-93353: regrtest supports checking tmp files with -j2 (#93909)
regrtest now also implements checking for leaked temporary files and
directories when using -jN for N >= 2. Use tempfile.mkdtemp() to
create the temporary directory. Skip this check on WASI.
(cherry picked from commit 4f85cec9e2077681b3dacc3108e646d509b720bf)
* gh-84461: Fix Emscripten umask and permission issues (GH-94002)
- Emscripten's default umask is too strict, see
https://github.com/emscripten-core/emscripten/issues/17269
- getuid/getgid and geteuid/getegid are stubs that always return 0
(root). Disable effective uid/gid syscalls and fix tests that use
chmod() current user.
- Cannot drop X bit from directory.
(cherry picked from commit 2702e408fd0e0dd7aec396b4cf8c7ce9caae81d8)
* gh-94052: Don't re-run failed tests with --python option (#94054)
(cherry picked from commit 0ff7b996f5d836e63cdaf652c7aa734285261096)
* Run Tools/scripts/reindent.py (#94225)
Reindent files which were not properly formatted (PEP 8: 4 spaces).
Remove also some trailing spaces.
(cherry picked from commit e87ada48a9e5d9d03f9759138869216df0d7383a)
* gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253)
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 199ba233248ab279f445e0809c2077976f0711bc)
* gh-96465: Clear fractions hash lru_cache under refleak testing (GH-96689)
Automerge-Triggered-By: GH:zware
(cherry picked from commit 9c8f3794337457b1d905a9fa0f38c2978fe32abd)
* gh-95027: Fix regrtest stdout encoding on Windows (#98492)
On Windows, when the Python test suite is run with the -jN option,
the ANSI code page is now used as the encoding for the stdout
temporary file, rather than using UTF-8 which can lead to decoding
errors.
(cherry picked from commit ec1f6f5f139868dc2c1116a7c7c878c38c668d53)
* gh-98903: Test suite fails with exit code 4 if no tests ran (#98904)
The Python test suite now fails wit exit code 4 if no tests ran. It
should help detecting typos in test names and test methods.
* Add "EXITCODE_" constants to Lib/test/libregrtest/main.py.
* Fix a typo: "NO TEST RUN" becomes "NO TESTS RAN"
(cherry picked from commit c76db37c0d23174cbffd6fa978d39693890ef020)
* gh-100086: Add build info to test.libregrtest (#100093)
The Python test runner (libregrtest) now logs Python build information like
"debug" vs "release" build, or LTO and PGO optimizations.
(cherry picked from commit 3c892022472eb975360fb3f0caa6f6fcc6fbf220)
* bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (#30895)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
(cherry picked from commit 995386071f96e4cfebfa027a71ca9134e4651d2a)
* gh-82054: allow test runner to split test_asyncio to execute in parallel by sharding. (#103927)
This runs test_asyncio sub-tests in parallel using sharding from Cinder. This suite is typically the longest-pole in runs because it is a test package with a lot of further sub-tests otherwise run serially. By breaking out the sub-tests as independent modules we can run a lot more in parallel.
After porting we can see the direct impact on a multicore system.
Without this change:
Running make test is 5 min 26 seconds
With this change:
Running make test takes 3 min 39 seconds
That'll vary based on system and parallelism. On a `-j 4` run similar to what CI and buildbot systems often do, it reduced the overall test suite completion latency by 10%.
The drawbacks are that this implementation is hacky and due to the sorting of the tests it obscures when the asyncio tests occur and involves changing CPython test infrastructure but, the wall time saved it is worth it, especially in low-core count CI runs as it pulls a long tail. The win for productivity and reserved CI resource usage is significant.
Future tests that deserve to be refactored into split up suites to benefit from are test_concurrent_futures and the way the _test_multiprocessing suite gets run for all start methods. As exposed by passing the -o flag to python -m test to get a list of the 10 longest running tests.
---------
Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google, LLC]
(cherry picked from commit 9e011e7c77dad7d0bbb944c44891531606caeb21)
* Display the sanitizer config in the regrtest header. (#105301)
Display the sanitizers present in libregrtest.
Having this in the CI output for tests with the relevant environment
variable displayed will help make it easier to do what we need to
create an equivalent local test run.
(cherry picked from commit 852348ab65783601e0844b6647ea033668b45c11)
* gh-101634: regrtest reports decoding error as failed test (#106169)
When running the Python test suite with -jN option, if a worker stdout
cannot be decoded from the locale encoding report a failed testn so the
exitcode is non-zero.
(cherry picked from commit 2ac3eec103cf450aaaebeb932e51155d2e7fb37b)
* gh-108223: test.pythoninfo and libregrtest log Py_NOGIL (#108238)
Enable with --disable-gil --without-pydebug:
$ make pythoninfo|grep NOGIL
sysconfig[Py_NOGIL]: 1
$ ./python -m test
...
== Python build: nogil debug
...
(cherry picked from commit 5afe0c17ca14df430736e549542a4b85e7e7c7ac)
* gh-90791: test.pythoninfo logs ASAN_OPTIONS env var (#108289)
* Cleanup libregrtest code logging ASAN_OPTIONS.
* Fix a typo on "ASAN_OPTIONS" vs "MSAN_OPTIONS".
(cherry picked from commit 3a1ac87f8f89d3206b46a0df4908afae629d669d)
* gh-108388: regrtest splits test_asyncio package (#108393)
Currently, test_asyncio package is only splitted into sub-tests when
using command "./python -m test". With this change, it's also
splitted when passing it on the command line:
"./python -m test test_asyncio".
Remove the concept of "STDTESTS". Python is now mature enough to not
have to bother with that anymore. Removing STDTESTS simplify the
code.
(cherry picked from commit 174e9da0836844a2138cc8915dd305cb2cd7a583)
* regrtest computes statistics (#108793)
test_netrc, test_pep646_syntax and test_xml_etree now return results
in the test_main() function.
Changes:
* Rewrite TestResult as a dataclass with a new State class.
* Add test.support.TestStats class and Regrtest.stats_dict attribute.
* libregrtest.runtest functions now modify a TestResult instance
in-place.
* libregrtest summary lists the number of run tests and skipped
tests, and denied resources.
* Add TestResult.has_meaningful_duration() method.
* Compute TestResult duration in the upper function.
* Use time.perf_counter() instead of time.monotonic().
* Regrtest: rename 'resource_denieds' attribute to 'resource_denied'.
* Rename CHILD_ERROR to MULTIPROCESSING_ERROR.
* Use match/case syntadx to have different code depending on the
test state.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit d4e534cbb35678c82b3a1276826af55d7bfc23b6)
* gh-108822: Add Changelog entry for regrtest statistics (#108821)
---------
Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Zachary Ware <zach@python.org>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Joshua Herman <zitterbewegung@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-09-03 19:21:53 +02:00
|
|
|
rerun={testname: testname},
|
|
|
|
|
stats=0)
|
2023-04-07 19:35:16 +02:00
|
|
|
|
|
|
|
|
def test_rerun_teardown_module_hook_failure(self):
|
|
|
|
|
# FAILURE then FAILURE
|
|
|
|
|
code = textwrap.dedent("""
|
|
|
|
|
import unittest
|
|
|
|
|
|
|
|
|
|
def tearDownModule():
|
|
|
|
|
raise RuntimeError('Fail')
|
|
|
|
|
|
|
|
|
|
class ExampleTests(unittest.TestCase):
|
|
|
|
|
def test_success(self):
|
|
|
|
|
return
|
|
|
|
|
""")
|
|
|
|
|
testname = self.create_test(code=code)
|
|
|
|
|
|
|
|
|
|
output = self.run_tests("-w", testname, exitcode=EXITCODE_BAD_TEST)
|
|
|
|
|
self.check_executed_tests(output, testname,
|
|
|
|
|
failed=[testname],
|
[3.11] gh-108822: Backport libregrtest changes from the main branch (#108820)
* Revert "[3.11] gh-101634: regrtest reports decoding error as failed test (#106169) (#106175)"
This reverts commit d5418e97fc524420011a370ba3c2c3cf6a89a74f.
* Revert "[3.11] bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (GH-30895) (GH-103342)"
This reverts commit ecb09a849689764193e0115d27e220f82b5f6d9f.
* Revert "gh-95027: Fix regrtest stdout encoding on Windows (GH-98492)"
This reverts commit b2aa28eec56d07b9c6777b02b7247cf21839de9f.
* Revert "[3.11] gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253) (GH-94408)"
This reverts commit 0122ab235b5acb52dd99fd05d8802a00f438b828.
* Revert "Run Tools/scripts/reindent.py (GH-94225)"
This reverts commit f0f3a424afb00a15ce8c0140dd218f5b33929be6.
* Revert "gh-94052: Don't re-run failed tests with --python option (GH-94054)"
This reverts commit 1347607db12012f6458ffcba48d8ad797083812e.
* Revert "[3.11] gh-84461: Fix Emscripten umask and permission issues (GH-94002) (GH-94006)"
This reverts commit 10731849184a3101ed18683b0128d689f1671c3f.
* gh-93353: regrtest checks for leaked temporary files (#93776)
When running tests with -jN, create a temporary directory per process
and mark a test as "environment changed" if a test leaks a temporary
file or directory.
(cherry picked from commit e566ce5496f1bad81c431aaee65e36d5e44771c5)
* gh-93353: Fix regrtest for -jN with N >= 2 (GH-93813)
(cherry picked from commit 36934a16e86f34d69ba2d41630fb5b4d06d59cff)
* gh-93353: regrtest supports checking tmp files with -j2 (#93909)
regrtest now also implements checking for leaked temporary files and
directories when using -jN for N >= 2. Use tempfile.mkdtemp() to
create the temporary directory. Skip this check on WASI.
(cherry picked from commit 4f85cec9e2077681b3dacc3108e646d509b720bf)
* gh-84461: Fix Emscripten umask and permission issues (GH-94002)
- Emscripten's default umask is too strict, see
https://github.com/emscripten-core/emscripten/issues/17269
- getuid/getgid and geteuid/getegid are stubs that always return 0
(root). Disable effective uid/gid syscalls and fix tests that use
chmod() current user.
- Cannot drop X bit from directory.
(cherry picked from commit 2702e408fd0e0dd7aec396b4cf8c7ce9caae81d8)
* gh-94052: Don't re-run failed tests with --python option (#94054)
(cherry picked from commit 0ff7b996f5d836e63cdaf652c7aa734285261096)
* Run Tools/scripts/reindent.py (#94225)
Reindent files which were not properly formatted (PEP 8: 4 spaces).
Remove also some trailing spaces.
(cherry picked from commit e87ada48a9e5d9d03f9759138869216df0d7383a)
* gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253)
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 199ba233248ab279f445e0809c2077976f0711bc)
* gh-96465: Clear fractions hash lru_cache under refleak testing (GH-96689)
Automerge-Triggered-By: GH:zware
(cherry picked from commit 9c8f3794337457b1d905a9fa0f38c2978fe32abd)
* gh-95027: Fix regrtest stdout encoding on Windows (#98492)
On Windows, when the Python test suite is run with the -jN option,
the ANSI code page is now used as the encoding for the stdout
temporary file, rather than using UTF-8 which can lead to decoding
errors.
(cherry picked from commit ec1f6f5f139868dc2c1116a7c7c878c38c668d53)
* gh-98903: Test suite fails with exit code 4 if no tests ran (#98904)
The Python test suite now fails wit exit code 4 if no tests ran. It
should help detecting typos in test names and test methods.
* Add "EXITCODE_" constants to Lib/test/libregrtest/main.py.
* Fix a typo: "NO TEST RUN" becomes "NO TESTS RAN"
(cherry picked from commit c76db37c0d23174cbffd6fa978d39693890ef020)
* gh-100086: Add build info to test.libregrtest (#100093)
The Python test runner (libregrtest) now logs Python build information like
"debug" vs "release" build, or LTO and PGO optimizations.
(cherry picked from commit 3c892022472eb975360fb3f0caa6f6fcc6fbf220)
* bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (#30895)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
(cherry picked from commit 995386071f96e4cfebfa027a71ca9134e4651d2a)
* gh-82054: allow test runner to split test_asyncio to execute in parallel by sharding. (#103927)
This runs test_asyncio sub-tests in parallel using sharding from Cinder. This suite is typically the longest-pole in runs because it is a test package with a lot of further sub-tests otherwise run serially. By breaking out the sub-tests as independent modules we can run a lot more in parallel.
After porting we can see the direct impact on a multicore system.
Without this change:
Running make test is 5 min 26 seconds
With this change:
Running make test takes 3 min 39 seconds
That'll vary based on system and parallelism. On a `-j 4` run similar to what CI and buildbot systems often do, it reduced the overall test suite completion latency by 10%.
The drawbacks are that this implementation is hacky and due to the sorting of the tests it obscures when the asyncio tests occur and involves changing CPython test infrastructure but, the wall time saved it is worth it, especially in low-core count CI runs as it pulls a long tail. The win for productivity and reserved CI resource usage is significant.
Future tests that deserve to be refactored into split up suites to benefit from are test_concurrent_futures and the way the _test_multiprocessing suite gets run for all start methods. As exposed by passing the -o flag to python -m test to get a list of the 10 longest running tests.
---------
Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google, LLC]
(cherry picked from commit 9e011e7c77dad7d0bbb944c44891531606caeb21)
* Display the sanitizer config in the regrtest header. (#105301)
Display the sanitizers present in libregrtest.
Having this in the CI output for tests with the relevant environment
variable displayed will help make it easier to do what we need to
create an equivalent local test run.
(cherry picked from commit 852348ab65783601e0844b6647ea033668b45c11)
* gh-101634: regrtest reports decoding error as failed test (#106169)
When running the Python test suite with -jN option, if a worker stdout
cannot be decoded from the locale encoding report a failed testn so the
exitcode is non-zero.
(cherry picked from commit 2ac3eec103cf450aaaebeb932e51155d2e7fb37b)
* gh-108223: test.pythoninfo and libregrtest log Py_NOGIL (#108238)
Enable with --disable-gil --without-pydebug:
$ make pythoninfo|grep NOGIL
sysconfig[Py_NOGIL]: 1
$ ./python -m test
...
== Python build: nogil debug
...
(cherry picked from commit 5afe0c17ca14df430736e549542a4b85e7e7c7ac)
* gh-90791: test.pythoninfo logs ASAN_OPTIONS env var (#108289)
* Cleanup libregrtest code logging ASAN_OPTIONS.
* Fix a typo on "ASAN_OPTIONS" vs "MSAN_OPTIONS".
(cherry picked from commit 3a1ac87f8f89d3206b46a0df4908afae629d669d)
* gh-108388: regrtest splits test_asyncio package (#108393)
Currently, test_asyncio package is only splitted into sub-tests when
using command "./python -m test". With this change, it's also
splitted when passing it on the command line:
"./python -m test test_asyncio".
Remove the concept of "STDTESTS". Python is now mature enough to not
have to bother with that anymore. Removing STDTESTS simplify the
code.
(cherry picked from commit 174e9da0836844a2138cc8915dd305cb2cd7a583)
* regrtest computes statistics (#108793)
test_netrc, test_pep646_syntax and test_xml_etree now return results
in the test_main() function.
Changes:
* Rewrite TestResult as a dataclass with a new State class.
* Add test.support.TestStats class and Regrtest.stats_dict attribute.
* libregrtest.runtest functions now modify a TestResult instance
in-place.
* libregrtest summary lists the number of run tests and skipped
tests, and denied resources.
* Add TestResult.has_meaningful_duration() method.
* Compute TestResult duration in the upper function.
* Use time.perf_counter() instead of time.monotonic().
* Regrtest: rename 'resource_denieds' attribute to 'resource_denied'.
* Rename CHILD_ERROR to MULTIPROCESSING_ERROR.
* Use match/case syntadx to have different code depending on the
test state.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit d4e534cbb35678c82b3a1276826af55d7bfc23b6)
* gh-108822: Add Changelog entry for regrtest statistics (#108821)
---------
Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Zachary Ware <zach@python.org>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Joshua Herman <zitterbewegung@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-09-03 19:21:53 +02:00
|
|
|
rerun={testname: testname},
|
|
|
|
|
stats=1)
|
2023-04-07 19:35:16 +02:00
|
|
|
|
|
|
|
|
def test_rerun_setup_hook_failure(self):
|
|
|
|
|
# FAILURE then FAILURE
|
|
|
|
|
code = textwrap.dedent("""
|
|
|
|
|
import unittest
|
|
|
|
|
|
|
|
|
|
class ExampleTests(unittest.TestCase):
|
|
|
|
|
def setUp(self):
|
|
|
|
|
raise RuntimeError('Fail')
|
|
|
|
|
|
|
|
|
|
def test_success(self):
|
|
|
|
|
return
|
|
|
|
|
""")
|
|
|
|
|
testname = self.create_test(code=code)
|
|
|
|
|
|
|
|
|
|
output = self.run_tests("-w", testname, exitcode=EXITCODE_BAD_TEST)
|
|
|
|
|
self.check_executed_tests(output, testname,
|
|
|
|
|
failed=[testname],
|
[3.11] gh-108822: Backport libregrtest changes from the main branch (#108820)
* Revert "[3.11] gh-101634: regrtest reports decoding error as failed test (#106169) (#106175)"
This reverts commit d5418e97fc524420011a370ba3c2c3cf6a89a74f.
* Revert "[3.11] bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (GH-30895) (GH-103342)"
This reverts commit ecb09a849689764193e0115d27e220f82b5f6d9f.
* Revert "gh-95027: Fix regrtest stdout encoding on Windows (GH-98492)"
This reverts commit b2aa28eec56d07b9c6777b02b7247cf21839de9f.
* Revert "[3.11] gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253) (GH-94408)"
This reverts commit 0122ab235b5acb52dd99fd05d8802a00f438b828.
* Revert "Run Tools/scripts/reindent.py (GH-94225)"
This reverts commit f0f3a424afb00a15ce8c0140dd218f5b33929be6.
* Revert "gh-94052: Don't re-run failed tests with --python option (GH-94054)"
This reverts commit 1347607db12012f6458ffcba48d8ad797083812e.
* Revert "[3.11] gh-84461: Fix Emscripten umask and permission issues (GH-94002) (GH-94006)"
This reverts commit 10731849184a3101ed18683b0128d689f1671c3f.
* gh-93353: regrtest checks for leaked temporary files (#93776)
When running tests with -jN, create a temporary directory per process
and mark a test as "environment changed" if a test leaks a temporary
file or directory.
(cherry picked from commit e566ce5496f1bad81c431aaee65e36d5e44771c5)
* gh-93353: Fix regrtest for -jN with N >= 2 (GH-93813)
(cherry picked from commit 36934a16e86f34d69ba2d41630fb5b4d06d59cff)
* gh-93353: regrtest supports checking tmp files with -j2 (#93909)
regrtest now also implements checking for leaked temporary files and
directories when using -jN for N >= 2. Use tempfile.mkdtemp() to
create the temporary directory. Skip this check on WASI.
(cherry picked from commit 4f85cec9e2077681b3dacc3108e646d509b720bf)
* gh-84461: Fix Emscripten umask and permission issues (GH-94002)
- Emscripten's default umask is too strict, see
https://github.com/emscripten-core/emscripten/issues/17269
- getuid/getgid and geteuid/getegid are stubs that always return 0
(root). Disable effective uid/gid syscalls and fix tests that use
chmod() current user.
- Cannot drop X bit from directory.
(cherry picked from commit 2702e408fd0e0dd7aec396b4cf8c7ce9caae81d8)
* gh-94052: Don't re-run failed tests with --python option (#94054)
(cherry picked from commit 0ff7b996f5d836e63cdaf652c7aa734285261096)
* Run Tools/scripts/reindent.py (#94225)
Reindent files which were not properly formatted (PEP 8: 4 spaces).
Remove also some trailing spaces.
(cherry picked from commit e87ada48a9e5d9d03f9759138869216df0d7383a)
* gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253)
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 199ba233248ab279f445e0809c2077976f0711bc)
* gh-96465: Clear fractions hash lru_cache under refleak testing (GH-96689)
Automerge-Triggered-By: GH:zware
(cherry picked from commit 9c8f3794337457b1d905a9fa0f38c2978fe32abd)
* gh-95027: Fix regrtest stdout encoding on Windows (#98492)
On Windows, when the Python test suite is run with the -jN option,
the ANSI code page is now used as the encoding for the stdout
temporary file, rather than using UTF-8 which can lead to decoding
errors.
(cherry picked from commit ec1f6f5f139868dc2c1116a7c7c878c38c668d53)
* gh-98903: Test suite fails with exit code 4 if no tests ran (#98904)
The Python test suite now fails wit exit code 4 if no tests ran. It
should help detecting typos in test names and test methods.
* Add "EXITCODE_" constants to Lib/test/libregrtest/main.py.
* Fix a typo: "NO TEST RUN" becomes "NO TESTS RAN"
(cherry picked from commit c76db37c0d23174cbffd6fa978d39693890ef020)
* gh-100086: Add build info to test.libregrtest (#100093)
The Python test runner (libregrtest) now logs Python build information like
"debug" vs "release" build, or LTO and PGO optimizations.
(cherry picked from commit 3c892022472eb975360fb3f0caa6f6fcc6fbf220)
* bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (#30895)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
(cherry picked from commit 995386071f96e4cfebfa027a71ca9134e4651d2a)
* gh-82054: allow test runner to split test_asyncio to execute in parallel by sharding. (#103927)
This runs test_asyncio sub-tests in parallel using sharding from Cinder. This suite is typically the longest-pole in runs because it is a test package with a lot of further sub-tests otherwise run serially. By breaking out the sub-tests as independent modules we can run a lot more in parallel.
After porting we can see the direct impact on a multicore system.
Without this change:
Running make test is 5 min 26 seconds
With this change:
Running make test takes 3 min 39 seconds
That'll vary based on system and parallelism. On a `-j 4` run similar to what CI and buildbot systems often do, it reduced the overall test suite completion latency by 10%.
The drawbacks are that this implementation is hacky and due to the sorting of the tests it obscures when the asyncio tests occur and involves changing CPython test infrastructure but, the wall time saved it is worth it, especially in low-core count CI runs as it pulls a long tail. The win for productivity and reserved CI resource usage is significant.
Future tests that deserve to be refactored into split up suites to benefit from are test_concurrent_futures and the way the _test_multiprocessing suite gets run for all start methods. As exposed by passing the -o flag to python -m test to get a list of the 10 longest running tests.
---------
Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google, LLC]
(cherry picked from commit 9e011e7c77dad7d0bbb944c44891531606caeb21)
* Display the sanitizer config in the regrtest header. (#105301)
Display the sanitizers present in libregrtest.
Having this in the CI output for tests with the relevant environment
variable displayed will help make it easier to do what we need to
create an equivalent local test run.
(cherry picked from commit 852348ab65783601e0844b6647ea033668b45c11)
* gh-101634: regrtest reports decoding error as failed test (#106169)
When running the Python test suite with -jN option, if a worker stdout
cannot be decoded from the locale encoding report a failed testn so the
exitcode is non-zero.
(cherry picked from commit 2ac3eec103cf450aaaebeb932e51155d2e7fb37b)
* gh-108223: test.pythoninfo and libregrtest log Py_NOGIL (#108238)
Enable with --disable-gil --without-pydebug:
$ make pythoninfo|grep NOGIL
sysconfig[Py_NOGIL]: 1
$ ./python -m test
...
== Python build: nogil debug
...
(cherry picked from commit 5afe0c17ca14df430736e549542a4b85e7e7c7ac)
* gh-90791: test.pythoninfo logs ASAN_OPTIONS env var (#108289)
* Cleanup libregrtest code logging ASAN_OPTIONS.
* Fix a typo on "ASAN_OPTIONS" vs "MSAN_OPTIONS".
(cherry picked from commit 3a1ac87f8f89d3206b46a0df4908afae629d669d)
* gh-108388: regrtest splits test_asyncio package (#108393)
Currently, test_asyncio package is only splitted into sub-tests when
using command "./python -m test". With this change, it's also
splitted when passing it on the command line:
"./python -m test test_asyncio".
Remove the concept of "STDTESTS". Python is now mature enough to not
have to bother with that anymore. Removing STDTESTS simplify the
code.
(cherry picked from commit 174e9da0836844a2138cc8915dd305cb2cd7a583)
* regrtest computes statistics (#108793)
test_netrc, test_pep646_syntax and test_xml_etree now return results
in the test_main() function.
Changes:
* Rewrite TestResult as a dataclass with a new State class.
* Add test.support.TestStats class and Regrtest.stats_dict attribute.
* libregrtest.runtest functions now modify a TestResult instance
in-place.
* libregrtest summary lists the number of run tests and skipped
tests, and denied resources.
* Add TestResult.has_meaningful_duration() method.
* Compute TestResult duration in the upper function.
* Use time.perf_counter() instead of time.monotonic().
* Regrtest: rename 'resource_denieds' attribute to 'resource_denied'.
* Rename CHILD_ERROR to MULTIPROCESSING_ERROR.
* Use match/case syntadx to have different code depending on the
test state.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit d4e534cbb35678c82b3a1276826af55d7bfc23b6)
* gh-108822: Add Changelog entry for regrtest statistics (#108821)
---------
Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Zachary Ware <zach@python.org>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Joshua Herman <zitterbewegung@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-09-03 19:21:53 +02:00
|
|
|
rerun={testname: "test_success"},
|
|
|
|
|
stats=1)
|
2023-04-07 19:35:16 +02:00
|
|
|
|
|
|
|
|
def test_rerun_teardown_hook_failure(self):
|
|
|
|
|
# FAILURE then FAILURE
|
|
|
|
|
code = textwrap.dedent("""
|
|
|
|
|
import unittest
|
|
|
|
|
|
|
|
|
|
class ExampleTests(unittest.TestCase):
|
|
|
|
|
def tearDown(self):
|
|
|
|
|
raise RuntimeError('Fail')
|
|
|
|
|
|
|
|
|
|
def test_success(self):
|
|
|
|
|
return
|
|
|
|
|
""")
|
|
|
|
|
testname = self.create_test(code=code)
|
|
|
|
|
|
|
|
|
|
output = self.run_tests("-w", testname, exitcode=EXITCODE_BAD_TEST)
|
|
|
|
|
self.check_executed_tests(output, testname,
|
|
|
|
|
failed=[testname],
|
[3.11] gh-108822: Backport libregrtest changes from the main branch (#108820)
* Revert "[3.11] gh-101634: regrtest reports decoding error as failed test (#106169) (#106175)"
This reverts commit d5418e97fc524420011a370ba3c2c3cf6a89a74f.
* Revert "[3.11] bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (GH-30895) (GH-103342)"
This reverts commit ecb09a849689764193e0115d27e220f82b5f6d9f.
* Revert "gh-95027: Fix regrtest stdout encoding on Windows (GH-98492)"
This reverts commit b2aa28eec56d07b9c6777b02b7247cf21839de9f.
* Revert "[3.11] gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253) (GH-94408)"
This reverts commit 0122ab235b5acb52dd99fd05d8802a00f438b828.
* Revert "Run Tools/scripts/reindent.py (GH-94225)"
This reverts commit f0f3a424afb00a15ce8c0140dd218f5b33929be6.
* Revert "gh-94052: Don't re-run failed tests with --python option (GH-94054)"
This reverts commit 1347607db12012f6458ffcba48d8ad797083812e.
* Revert "[3.11] gh-84461: Fix Emscripten umask and permission issues (GH-94002) (GH-94006)"
This reverts commit 10731849184a3101ed18683b0128d689f1671c3f.
* gh-93353: regrtest checks for leaked temporary files (#93776)
When running tests with -jN, create a temporary directory per process
and mark a test as "environment changed" if a test leaks a temporary
file or directory.
(cherry picked from commit e566ce5496f1bad81c431aaee65e36d5e44771c5)
* gh-93353: Fix regrtest for -jN with N >= 2 (GH-93813)
(cherry picked from commit 36934a16e86f34d69ba2d41630fb5b4d06d59cff)
* gh-93353: regrtest supports checking tmp files with -j2 (#93909)
regrtest now also implements checking for leaked temporary files and
directories when using -jN for N >= 2. Use tempfile.mkdtemp() to
create the temporary directory. Skip this check on WASI.
(cherry picked from commit 4f85cec9e2077681b3dacc3108e646d509b720bf)
* gh-84461: Fix Emscripten umask and permission issues (GH-94002)
- Emscripten's default umask is too strict, see
https://github.com/emscripten-core/emscripten/issues/17269
- getuid/getgid and geteuid/getegid are stubs that always return 0
(root). Disable effective uid/gid syscalls and fix tests that use
chmod() current user.
- Cannot drop X bit from directory.
(cherry picked from commit 2702e408fd0e0dd7aec396b4cf8c7ce9caae81d8)
* gh-94052: Don't re-run failed tests with --python option (#94054)
(cherry picked from commit 0ff7b996f5d836e63cdaf652c7aa734285261096)
* Run Tools/scripts/reindent.py (#94225)
Reindent files which were not properly formatted (PEP 8: 4 spaces).
Remove also some trailing spaces.
(cherry picked from commit e87ada48a9e5d9d03f9759138869216df0d7383a)
* gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253)
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 199ba233248ab279f445e0809c2077976f0711bc)
* gh-96465: Clear fractions hash lru_cache under refleak testing (GH-96689)
Automerge-Triggered-By: GH:zware
(cherry picked from commit 9c8f3794337457b1d905a9fa0f38c2978fe32abd)
* gh-95027: Fix regrtest stdout encoding on Windows (#98492)
On Windows, when the Python test suite is run with the -jN option,
the ANSI code page is now used as the encoding for the stdout
temporary file, rather than using UTF-8 which can lead to decoding
errors.
(cherry picked from commit ec1f6f5f139868dc2c1116a7c7c878c38c668d53)
* gh-98903: Test suite fails with exit code 4 if no tests ran (#98904)
The Python test suite now fails wit exit code 4 if no tests ran. It
should help detecting typos in test names and test methods.
* Add "EXITCODE_" constants to Lib/test/libregrtest/main.py.
* Fix a typo: "NO TEST RUN" becomes "NO TESTS RAN"
(cherry picked from commit c76db37c0d23174cbffd6fa978d39693890ef020)
* gh-100086: Add build info to test.libregrtest (#100093)
The Python test runner (libregrtest) now logs Python build information like
"debug" vs "release" build, or LTO and PGO optimizations.
(cherry picked from commit 3c892022472eb975360fb3f0caa6f6fcc6fbf220)
* bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (#30895)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
(cherry picked from commit 995386071f96e4cfebfa027a71ca9134e4651d2a)
* gh-82054: allow test runner to split test_asyncio to execute in parallel by sharding. (#103927)
This runs test_asyncio sub-tests in parallel using sharding from Cinder. This suite is typically the longest-pole in runs because it is a test package with a lot of further sub-tests otherwise run serially. By breaking out the sub-tests as independent modules we can run a lot more in parallel.
After porting we can see the direct impact on a multicore system.
Without this change:
Running make test is 5 min 26 seconds
With this change:
Running make test takes 3 min 39 seconds
That'll vary based on system and parallelism. On a `-j 4` run similar to what CI and buildbot systems often do, it reduced the overall test suite completion latency by 10%.
The drawbacks are that this implementation is hacky and due to the sorting of the tests it obscures when the asyncio tests occur and involves changing CPython test infrastructure but, the wall time saved it is worth it, especially in low-core count CI runs as it pulls a long tail. The win for productivity and reserved CI resource usage is significant.
Future tests that deserve to be refactored into split up suites to benefit from are test_concurrent_futures and the way the _test_multiprocessing suite gets run for all start methods. As exposed by passing the -o flag to python -m test to get a list of the 10 longest running tests.
---------
Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google, LLC]
(cherry picked from commit 9e011e7c77dad7d0bbb944c44891531606caeb21)
* Display the sanitizer config in the regrtest header. (#105301)
Display the sanitizers present in libregrtest.
Having this in the CI output for tests with the relevant environment
variable displayed will help make it easier to do what we need to
create an equivalent local test run.
(cherry picked from commit 852348ab65783601e0844b6647ea033668b45c11)
* gh-101634: regrtest reports decoding error as failed test (#106169)
When running the Python test suite with -jN option, if a worker stdout
cannot be decoded from the locale encoding report a failed testn so the
exitcode is non-zero.
(cherry picked from commit 2ac3eec103cf450aaaebeb932e51155d2e7fb37b)
* gh-108223: test.pythoninfo and libregrtest log Py_NOGIL (#108238)
Enable with --disable-gil --without-pydebug:
$ make pythoninfo|grep NOGIL
sysconfig[Py_NOGIL]: 1
$ ./python -m test
...
== Python build: nogil debug
...
(cherry picked from commit 5afe0c17ca14df430736e549542a4b85e7e7c7ac)
* gh-90791: test.pythoninfo logs ASAN_OPTIONS env var (#108289)
* Cleanup libregrtest code logging ASAN_OPTIONS.
* Fix a typo on "ASAN_OPTIONS" vs "MSAN_OPTIONS".
(cherry picked from commit 3a1ac87f8f89d3206b46a0df4908afae629d669d)
* gh-108388: regrtest splits test_asyncio package (#108393)
Currently, test_asyncio package is only splitted into sub-tests when
using command "./python -m test". With this change, it's also
splitted when passing it on the command line:
"./python -m test test_asyncio".
Remove the concept of "STDTESTS". Python is now mature enough to not
have to bother with that anymore. Removing STDTESTS simplify the
code.
(cherry picked from commit 174e9da0836844a2138cc8915dd305cb2cd7a583)
* regrtest computes statistics (#108793)
test_netrc, test_pep646_syntax and test_xml_etree now return results
in the test_main() function.
Changes:
* Rewrite TestResult as a dataclass with a new State class.
* Add test.support.TestStats class and Regrtest.stats_dict attribute.
* libregrtest.runtest functions now modify a TestResult instance
in-place.
* libregrtest summary lists the number of run tests and skipped
tests, and denied resources.
* Add TestResult.has_meaningful_duration() method.
* Compute TestResult duration in the upper function.
* Use time.perf_counter() instead of time.monotonic().
* Regrtest: rename 'resource_denieds' attribute to 'resource_denied'.
* Rename CHILD_ERROR to MULTIPROCESSING_ERROR.
* Use match/case syntadx to have different code depending on the
test state.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit d4e534cbb35678c82b3a1276826af55d7bfc23b6)
* gh-108822: Add Changelog entry for regrtest statistics (#108821)
---------
Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Zachary Ware <zach@python.org>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Joshua Herman <zitterbewegung@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-09-03 19:21:53 +02:00
|
|
|
rerun={testname: "test_success"},
|
|
|
|
|
stats=1)
|
2023-04-07 19:35:16 +02:00
|
|
|
|
|
|
|
|
def test_rerun_async_setup_hook_failure(self):
|
|
|
|
|
# FAILURE then FAILURE
|
|
|
|
|
code = textwrap.dedent("""
|
|
|
|
|
import unittest
|
|
|
|
|
|
|
|
|
|
class ExampleTests(unittest.IsolatedAsyncioTestCase):
|
|
|
|
|
async def asyncSetUp(self):
|
|
|
|
|
raise RuntimeError('Fail')
|
|
|
|
|
|
|
|
|
|
async def test_success(self):
|
|
|
|
|
return
|
|
|
|
|
""")
|
|
|
|
|
testname = self.create_test(code=code)
|
|
|
|
|
|
|
|
|
|
output = self.run_tests("-w", testname, exitcode=EXITCODE_BAD_TEST)
|
|
|
|
|
self.check_executed_tests(output, testname,
|
|
|
|
|
failed=[testname],
|
[3.11] gh-108822: Backport libregrtest changes from the main branch (#108820)
* Revert "[3.11] gh-101634: regrtest reports decoding error as failed test (#106169) (#106175)"
This reverts commit d5418e97fc524420011a370ba3c2c3cf6a89a74f.
* Revert "[3.11] bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (GH-30895) (GH-103342)"
This reverts commit ecb09a849689764193e0115d27e220f82b5f6d9f.
* Revert "gh-95027: Fix regrtest stdout encoding on Windows (GH-98492)"
This reverts commit b2aa28eec56d07b9c6777b02b7247cf21839de9f.
* Revert "[3.11] gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253) (GH-94408)"
This reverts commit 0122ab235b5acb52dd99fd05d8802a00f438b828.
* Revert "Run Tools/scripts/reindent.py (GH-94225)"
This reverts commit f0f3a424afb00a15ce8c0140dd218f5b33929be6.
* Revert "gh-94052: Don't re-run failed tests with --python option (GH-94054)"
This reverts commit 1347607db12012f6458ffcba48d8ad797083812e.
* Revert "[3.11] gh-84461: Fix Emscripten umask and permission issues (GH-94002) (GH-94006)"
This reverts commit 10731849184a3101ed18683b0128d689f1671c3f.
* gh-93353: regrtest checks for leaked temporary files (#93776)
When running tests with -jN, create a temporary directory per process
and mark a test as "environment changed" if a test leaks a temporary
file or directory.
(cherry picked from commit e566ce5496f1bad81c431aaee65e36d5e44771c5)
* gh-93353: Fix regrtest for -jN with N >= 2 (GH-93813)
(cherry picked from commit 36934a16e86f34d69ba2d41630fb5b4d06d59cff)
* gh-93353: regrtest supports checking tmp files with -j2 (#93909)
regrtest now also implements checking for leaked temporary files and
directories when using -jN for N >= 2. Use tempfile.mkdtemp() to
create the temporary directory. Skip this check on WASI.
(cherry picked from commit 4f85cec9e2077681b3dacc3108e646d509b720bf)
* gh-84461: Fix Emscripten umask and permission issues (GH-94002)
- Emscripten's default umask is too strict, see
https://github.com/emscripten-core/emscripten/issues/17269
- getuid/getgid and geteuid/getegid are stubs that always return 0
(root). Disable effective uid/gid syscalls and fix tests that use
chmod() current user.
- Cannot drop X bit from directory.
(cherry picked from commit 2702e408fd0e0dd7aec396b4cf8c7ce9caae81d8)
* gh-94052: Don't re-run failed tests with --python option (#94054)
(cherry picked from commit 0ff7b996f5d836e63cdaf652c7aa734285261096)
* Run Tools/scripts/reindent.py (#94225)
Reindent files which were not properly formatted (PEP 8: 4 spaces).
Remove also some trailing spaces.
(cherry picked from commit e87ada48a9e5d9d03f9759138869216df0d7383a)
* gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253)
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 199ba233248ab279f445e0809c2077976f0711bc)
* gh-96465: Clear fractions hash lru_cache under refleak testing (GH-96689)
Automerge-Triggered-By: GH:zware
(cherry picked from commit 9c8f3794337457b1d905a9fa0f38c2978fe32abd)
* gh-95027: Fix regrtest stdout encoding on Windows (#98492)
On Windows, when the Python test suite is run with the -jN option,
the ANSI code page is now used as the encoding for the stdout
temporary file, rather than using UTF-8 which can lead to decoding
errors.
(cherry picked from commit ec1f6f5f139868dc2c1116a7c7c878c38c668d53)
* gh-98903: Test suite fails with exit code 4 if no tests ran (#98904)
The Python test suite now fails wit exit code 4 if no tests ran. It
should help detecting typos in test names and test methods.
* Add "EXITCODE_" constants to Lib/test/libregrtest/main.py.
* Fix a typo: "NO TEST RUN" becomes "NO TESTS RAN"
(cherry picked from commit c76db37c0d23174cbffd6fa978d39693890ef020)
* gh-100086: Add build info to test.libregrtest (#100093)
The Python test runner (libregrtest) now logs Python build information like
"debug" vs "release" build, or LTO and PGO optimizations.
(cherry picked from commit 3c892022472eb975360fb3f0caa6f6fcc6fbf220)
* bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (#30895)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
(cherry picked from commit 995386071f96e4cfebfa027a71ca9134e4651d2a)
* gh-82054: allow test runner to split test_asyncio to execute in parallel by sharding. (#103927)
This runs test_asyncio sub-tests in parallel using sharding from Cinder. This suite is typically the longest-pole in runs because it is a test package with a lot of further sub-tests otherwise run serially. By breaking out the sub-tests as independent modules we can run a lot more in parallel.
After porting we can see the direct impact on a multicore system.
Without this change:
Running make test is 5 min 26 seconds
With this change:
Running make test takes 3 min 39 seconds
That'll vary based on system and parallelism. On a `-j 4` run similar to what CI and buildbot systems often do, it reduced the overall test suite completion latency by 10%.
The drawbacks are that this implementation is hacky and due to the sorting of the tests it obscures when the asyncio tests occur and involves changing CPython test infrastructure but, the wall time saved it is worth it, especially in low-core count CI runs as it pulls a long tail. The win for productivity and reserved CI resource usage is significant.
Future tests that deserve to be refactored into split up suites to benefit from are test_concurrent_futures and the way the _test_multiprocessing suite gets run for all start methods. As exposed by passing the -o flag to python -m test to get a list of the 10 longest running tests.
---------
Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google, LLC]
(cherry picked from commit 9e011e7c77dad7d0bbb944c44891531606caeb21)
* Display the sanitizer config in the regrtest header. (#105301)
Display the sanitizers present in libregrtest.
Having this in the CI output for tests with the relevant environment
variable displayed will help make it easier to do what we need to
create an equivalent local test run.
(cherry picked from commit 852348ab65783601e0844b6647ea033668b45c11)
* gh-101634: regrtest reports decoding error as failed test (#106169)
When running the Python test suite with -jN option, if a worker stdout
cannot be decoded from the locale encoding report a failed testn so the
exitcode is non-zero.
(cherry picked from commit 2ac3eec103cf450aaaebeb932e51155d2e7fb37b)
* gh-108223: test.pythoninfo and libregrtest log Py_NOGIL (#108238)
Enable with --disable-gil --without-pydebug:
$ make pythoninfo|grep NOGIL
sysconfig[Py_NOGIL]: 1
$ ./python -m test
...
== Python build: nogil debug
...
(cherry picked from commit 5afe0c17ca14df430736e549542a4b85e7e7c7ac)
* gh-90791: test.pythoninfo logs ASAN_OPTIONS env var (#108289)
* Cleanup libregrtest code logging ASAN_OPTIONS.
* Fix a typo on "ASAN_OPTIONS" vs "MSAN_OPTIONS".
(cherry picked from commit 3a1ac87f8f89d3206b46a0df4908afae629d669d)
* gh-108388: regrtest splits test_asyncio package (#108393)
Currently, test_asyncio package is only splitted into sub-tests when
using command "./python -m test". With this change, it's also
splitted when passing it on the command line:
"./python -m test test_asyncio".
Remove the concept of "STDTESTS". Python is now mature enough to not
have to bother with that anymore. Removing STDTESTS simplify the
code.
(cherry picked from commit 174e9da0836844a2138cc8915dd305cb2cd7a583)
* regrtest computes statistics (#108793)
test_netrc, test_pep646_syntax and test_xml_etree now return results
in the test_main() function.
Changes:
* Rewrite TestResult as a dataclass with a new State class.
* Add test.support.TestStats class and Regrtest.stats_dict attribute.
* libregrtest.runtest functions now modify a TestResult instance
in-place.
* libregrtest summary lists the number of run tests and skipped
tests, and denied resources.
* Add TestResult.has_meaningful_duration() method.
* Compute TestResult duration in the upper function.
* Use time.perf_counter() instead of time.monotonic().
* Regrtest: rename 'resource_denieds' attribute to 'resource_denied'.
* Rename CHILD_ERROR to MULTIPROCESSING_ERROR.
* Use match/case syntadx to have different code depending on the
test state.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit d4e534cbb35678c82b3a1276826af55d7bfc23b6)
* gh-108822: Add Changelog entry for regrtest statistics (#108821)
---------
Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Zachary Ware <zach@python.org>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Joshua Herman <zitterbewegung@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-09-03 19:21:53 +02:00
|
|
|
rerun={testname: "test_success"},
|
|
|
|
|
stats=1)
|
2023-04-07 19:35:16 +02:00
|
|
|
|
|
|
|
|
def test_rerun_async_teardown_hook_failure(self):
|
|
|
|
|
# FAILURE then FAILURE
|
|
|
|
|
code = textwrap.dedent("""
|
|
|
|
|
import unittest
|
|
|
|
|
|
|
|
|
|
class ExampleTests(unittest.IsolatedAsyncioTestCase):
|
|
|
|
|
async def asyncTearDown(self):
|
|
|
|
|
raise RuntimeError('Fail')
|
|
|
|
|
|
|
|
|
|
async def test_success(self):
|
|
|
|
|
return
|
|
|
|
|
""")
|
|
|
|
|
testname = self.create_test(code=code)
|
|
|
|
|
|
|
|
|
|
output = self.run_tests("-w", testname, exitcode=EXITCODE_BAD_TEST)
|
|
|
|
|
self.check_executed_tests(output, testname,
|
|
|
|
|
failed=[testname],
|
[3.11] gh-108822: Backport libregrtest changes from the main branch (#108820)
* Revert "[3.11] gh-101634: regrtest reports decoding error as failed test (#106169) (#106175)"
This reverts commit d5418e97fc524420011a370ba3c2c3cf6a89a74f.
* Revert "[3.11] bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (GH-30895) (GH-103342)"
This reverts commit ecb09a849689764193e0115d27e220f82b5f6d9f.
* Revert "gh-95027: Fix regrtest stdout encoding on Windows (GH-98492)"
This reverts commit b2aa28eec56d07b9c6777b02b7247cf21839de9f.
* Revert "[3.11] gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253) (GH-94408)"
This reverts commit 0122ab235b5acb52dd99fd05d8802a00f438b828.
* Revert "Run Tools/scripts/reindent.py (GH-94225)"
This reverts commit f0f3a424afb00a15ce8c0140dd218f5b33929be6.
* Revert "gh-94052: Don't re-run failed tests with --python option (GH-94054)"
This reverts commit 1347607db12012f6458ffcba48d8ad797083812e.
* Revert "[3.11] gh-84461: Fix Emscripten umask and permission issues (GH-94002) (GH-94006)"
This reverts commit 10731849184a3101ed18683b0128d689f1671c3f.
* gh-93353: regrtest checks for leaked temporary files (#93776)
When running tests with -jN, create a temporary directory per process
and mark a test as "environment changed" if a test leaks a temporary
file or directory.
(cherry picked from commit e566ce5496f1bad81c431aaee65e36d5e44771c5)
* gh-93353: Fix regrtest for -jN with N >= 2 (GH-93813)
(cherry picked from commit 36934a16e86f34d69ba2d41630fb5b4d06d59cff)
* gh-93353: regrtest supports checking tmp files with -j2 (#93909)
regrtest now also implements checking for leaked temporary files and
directories when using -jN for N >= 2. Use tempfile.mkdtemp() to
create the temporary directory. Skip this check on WASI.
(cherry picked from commit 4f85cec9e2077681b3dacc3108e646d509b720bf)
* gh-84461: Fix Emscripten umask and permission issues (GH-94002)
- Emscripten's default umask is too strict, see
https://github.com/emscripten-core/emscripten/issues/17269
- getuid/getgid and geteuid/getegid are stubs that always return 0
(root). Disable effective uid/gid syscalls and fix tests that use
chmod() current user.
- Cannot drop X bit from directory.
(cherry picked from commit 2702e408fd0e0dd7aec396b4cf8c7ce9caae81d8)
* gh-94052: Don't re-run failed tests with --python option (#94054)
(cherry picked from commit 0ff7b996f5d836e63cdaf652c7aa734285261096)
* Run Tools/scripts/reindent.py (#94225)
Reindent files which were not properly formatted (PEP 8: 4 spaces).
Remove also some trailing spaces.
(cherry picked from commit e87ada48a9e5d9d03f9759138869216df0d7383a)
* gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253)
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 199ba233248ab279f445e0809c2077976f0711bc)
* gh-96465: Clear fractions hash lru_cache under refleak testing (GH-96689)
Automerge-Triggered-By: GH:zware
(cherry picked from commit 9c8f3794337457b1d905a9fa0f38c2978fe32abd)
* gh-95027: Fix regrtest stdout encoding on Windows (#98492)
On Windows, when the Python test suite is run with the -jN option,
the ANSI code page is now used as the encoding for the stdout
temporary file, rather than using UTF-8 which can lead to decoding
errors.
(cherry picked from commit ec1f6f5f139868dc2c1116a7c7c878c38c668d53)
* gh-98903: Test suite fails with exit code 4 if no tests ran (#98904)
The Python test suite now fails wit exit code 4 if no tests ran. It
should help detecting typos in test names and test methods.
* Add "EXITCODE_" constants to Lib/test/libregrtest/main.py.
* Fix a typo: "NO TEST RUN" becomes "NO TESTS RAN"
(cherry picked from commit c76db37c0d23174cbffd6fa978d39693890ef020)
* gh-100086: Add build info to test.libregrtest (#100093)
The Python test runner (libregrtest) now logs Python build information like
"debug" vs "release" build, or LTO and PGO optimizations.
(cherry picked from commit 3c892022472eb975360fb3f0caa6f6fcc6fbf220)
* bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (#30895)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
(cherry picked from commit 995386071f96e4cfebfa027a71ca9134e4651d2a)
* gh-82054: allow test runner to split test_asyncio to execute in parallel by sharding. (#103927)
This runs test_asyncio sub-tests in parallel using sharding from Cinder. This suite is typically the longest-pole in runs because it is a test package with a lot of further sub-tests otherwise run serially. By breaking out the sub-tests as independent modules we can run a lot more in parallel.
After porting we can see the direct impact on a multicore system.
Without this change:
Running make test is 5 min 26 seconds
With this change:
Running make test takes 3 min 39 seconds
That'll vary based on system and parallelism. On a `-j 4` run similar to what CI and buildbot systems often do, it reduced the overall test suite completion latency by 10%.
The drawbacks are that this implementation is hacky and due to the sorting of the tests it obscures when the asyncio tests occur and involves changing CPython test infrastructure but, the wall time saved it is worth it, especially in low-core count CI runs as it pulls a long tail. The win for productivity and reserved CI resource usage is significant.
Future tests that deserve to be refactored into split up suites to benefit from are test_concurrent_futures and the way the _test_multiprocessing suite gets run for all start methods. As exposed by passing the -o flag to python -m test to get a list of the 10 longest running tests.
---------
Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google, LLC]
(cherry picked from commit 9e011e7c77dad7d0bbb944c44891531606caeb21)
* Display the sanitizer config in the regrtest header. (#105301)
Display the sanitizers present in libregrtest.
Having this in the CI output for tests with the relevant environment
variable displayed will help make it easier to do what we need to
create an equivalent local test run.
(cherry picked from commit 852348ab65783601e0844b6647ea033668b45c11)
* gh-101634: regrtest reports decoding error as failed test (#106169)
When running the Python test suite with -jN option, if a worker stdout
cannot be decoded from the locale encoding report a failed testn so the
exitcode is non-zero.
(cherry picked from commit 2ac3eec103cf450aaaebeb932e51155d2e7fb37b)
* gh-108223: test.pythoninfo and libregrtest log Py_NOGIL (#108238)
Enable with --disable-gil --without-pydebug:
$ make pythoninfo|grep NOGIL
sysconfig[Py_NOGIL]: 1
$ ./python -m test
...
== Python build: nogil debug
...
(cherry picked from commit 5afe0c17ca14df430736e549542a4b85e7e7c7ac)
* gh-90791: test.pythoninfo logs ASAN_OPTIONS env var (#108289)
* Cleanup libregrtest code logging ASAN_OPTIONS.
* Fix a typo on "ASAN_OPTIONS" vs "MSAN_OPTIONS".
(cherry picked from commit 3a1ac87f8f89d3206b46a0df4908afae629d669d)
* gh-108388: regrtest splits test_asyncio package (#108393)
Currently, test_asyncio package is only splitted into sub-tests when
using command "./python -m test". With this change, it's also
splitted when passing it on the command line:
"./python -m test test_asyncio".
Remove the concept of "STDTESTS". Python is now mature enough to not
have to bother with that anymore. Removing STDTESTS simplify the
code.
(cherry picked from commit 174e9da0836844a2138cc8915dd305cb2cd7a583)
* regrtest computes statistics (#108793)
test_netrc, test_pep646_syntax and test_xml_etree now return results
in the test_main() function.
Changes:
* Rewrite TestResult as a dataclass with a new State class.
* Add test.support.TestStats class and Regrtest.stats_dict attribute.
* libregrtest.runtest functions now modify a TestResult instance
in-place.
* libregrtest summary lists the number of run tests and skipped
tests, and denied resources.
* Add TestResult.has_meaningful_duration() method.
* Compute TestResult duration in the upper function.
* Use time.perf_counter() instead of time.monotonic().
* Regrtest: rename 'resource_denieds' attribute to 'resource_denied'.
* Rename CHILD_ERROR to MULTIPROCESSING_ERROR.
* Use match/case syntadx to have different code depending on the
test state.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit d4e534cbb35678c82b3a1276826af55d7bfc23b6)
* gh-108822: Add Changelog entry for regrtest statistics (#108821)
---------
Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Zachary Ware <zach@python.org>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Joshua Herman <zitterbewegung@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-09-03 19:21:53 +02:00
|
|
|
rerun={testname: "test_success"},
|
|
|
|
|
stats=1)
|
2023-04-07 19:35:16 +02:00
|
|
|
|
2018-11-29 17:17:44 +00:00
|
|
|
def test_no_tests_ran(self):
|
|
|
|
|
code = textwrap.dedent("""
|
|
|
|
|
import unittest
|
|
|
|
|
|
|
|
|
|
class Tests(unittest.TestCase):
|
|
|
|
|
def test_bug(self):
|
|
|
|
|
pass
|
|
|
|
|
""")
|
|
|
|
|
testname = self.create_test(code=code)
|
|
|
|
|
|
[3.11] gh-108822: Backport libregrtest changes from the main branch (#108820)
* Revert "[3.11] gh-101634: regrtest reports decoding error as failed test (#106169) (#106175)"
This reverts commit d5418e97fc524420011a370ba3c2c3cf6a89a74f.
* Revert "[3.11] bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (GH-30895) (GH-103342)"
This reverts commit ecb09a849689764193e0115d27e220f82b5f6d9f.
* Revert "gh-95027: Fix regrtest stdout encoding on Windows (GH-98492)"
This reverts commit b2aa28eec56d07b9c6777b02b7247cf21839de9f.
* Revert "[3.11] gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253) (GH-94408)"
This reverts commit 0122ab235b5acb52dd99fd05d8802a00f438b828.
* Revert "Run Tools/scripts/reindent.py (GH-94225)"
This reverts commit f0f3a424afb00a15ce8c0140dd218f5b33929be6.
* Revert "gh-94052: Don't re-run failed tests with --python option (GH-94054)"
This reverts commit 1347607db12012f6458ffcba48d8ad797083812e.
* Revert "[3.11] gh-84461: Fix Emscripten umask and permission issues (GH-94002) (GH-94006)"
This reverts commit 10731849184a3101ed18683b0128d689f1671c3f.
* gh-93353: regrtest checks for leaked temporary files (#93776)
When running tests with -jN, create a temporary directory per process
and mark a test as "environment changed" if a test leaks a temporary
file or directory.
(cherry picked from commit e566ce5496f1bad81c431aaee65e36d5e44771c5)
* gh-93353: Fix regrtest for -jN with N >= 2 (GH-93813)
(cherry picked from commit 36934a16e86f34d69ba2d41630fb5b4d06d59cff)
* gh-93353: regrtest supports checking tmp files with -j2 (#93909)
regrtest now also implements checking for leaked temporary files and
directories when using -jN for N >= 2. Use tempfile.mkdtemp() to
create the temporary directory. Skip this check on WASI.
(cherry picked from commit 4f85cec9e2077681b3dacc3108e646d509b720bf)
* gh-84461: Fix Emscripten umask and permission issues (GH-94002)
- Emscripten's default umask is too strict, see
https://github.com/emscripten-core/emscripten/issues/17269
- getuid/getgid and geteuid/getegid are stubs that always return 0
(root). Disable effective uid/gid syscalls and fix tests that use
chmod() current user.
- Cannot drop X bit from directory.
(cherry picked from commit 2702e408fd0e0dd7aec396b4cf8c7ce9caae81d8)
* gh-94052: Don't re-run failed tests with --python option (#94054)
(cherry picked from commit 0ff7b996f5d836e63cdaf652c7aa734285261096)
* Run Tools/scripts/reindent.py (#94225)
Reindent files which were not properly formatted (PEP 8: 4 spaces).
Remove also some trailing spaces.
(cherry picked from commit e87ada48a9e5d9d03f9759138869216df0d7383a)
* gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253)
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 199ba233248ab279f445e0809c2077976f0711bc)
* gh-96465: Clear fractions hash lru_cache under refleak testing (GH-96689)
Automerge-Triggered-By: GH:zware
(cherry picked from commit 9c8f3794337457b1d905a9fa0f38c2978fe32abd)
* gh-95027: Fix regrtest stdout encoding on Windows (#98492)
On Windows, when the Python test suite is run with the -jN option,
the ANSI code page is now used as the encoding for the stdout
temporary file, rather than using UTF-8 which can lead to decoding
errors.
(cherry picked from commit ec1f6f5f139868dc2c1116a7c7c878c38c668d53)
* gh-98903: Test suite fails with exit code 4 if no tests ran (#98904)
The Python test suite now fails wit exit code 4 if no tests ran. It
should help detecting typos in test names and test methods.
* Add "EXITCODE_" constants to Lib/test/libregrtest/main.py.
* Fix a typo: "NO TEST RUN" becomes "NO TESTS RAN"
(cherry picked from commit c76db37c0d23174cbffd6fa978d39693890ef020)
* gh-100086: Add build info to test.libregrtest (#100093)
The Python test runner (libregrtest) now logs Python build information like
"debug" vs "release" build, or LTO and PGO optimizations.
(cherry picked from commit 3c892022472eb975360fb3f0caa6f6fcc6fbf220)
* bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (#30895)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
(cherry picked from commit 995386071f96e4cfebfa027a71ca9134e4651d2a)
* gh-82054: allow test runner to split test_asyncio to execute in parallel by sharding. (#103927)
This runs test_asyncio sub-tests in parallel using sharding from Cinder. This suite is typically the longest-pole in runs because it is a test package with a lot of further sub-tests otherwise run serially. By breaking out the sub-tests as independent modules we can run a lot more in parallel.
After porting we can see the direct impact on a multicore system.
Without this change:
Running make test is 5 min 26 seconds
With this change:
Running make test takes 3 min 39 seconds
That'll vary based on system and parallelism. On a `-j 4` run similar to what CI and buildbot systems often do, it reduced the overall test suite completion latency by 10%.
The drawbacks are that this implementation is hacky and due to the sorting of the tests it obscures when the asyncio tests occur and involves changing CPython test infrastructure but, the wall time saved it is worth it, especially in low-core count CI runs as it pulls a long tail. The win for productivity and reserved CI resource usage is significant.
Future tests that deserve to be refactored into split up suites to benefit from are test_concurrent_futures and the way the _test_multiprocessing suite gets run for all start methods. As exposed by passing the -o flag to python -m test to get a list of the 10 longest running tests.
---------
Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google, LLC]
(cherry picked from commit 9e011e7c77dad7d0bbb944c44891531606caeb21)
* Display the sanitizer config in the regrtest header. (#105301)
Display the sanitizers present in libregrtest.
Having this in the CI output for tests with the relevant environment
variable displayed will help make it easier to do what we need to
create an equivalent local test run.
(cherry picked from commit 852348ab65783601e0844b6647ea033668b45c11)
* gh-101634: regrtest reports decoding error as failed test (#106169)
When running the Python test suite with -jN option, if a worker stdout
cannot be decoded from the locale encoding report a failed testn so the
exitcode is non-zero.
(cherry picked from commit 2ac3eec103cf450aaaebeb932e51155d2e7fb37b)
* gh-108223: test.pythoninfo and libregrtest log Py_NOGIL (#108238)
Enable with --disable-gil --without-pydebug:
$ make pythoninfo|grep NOGIL
sysconfig[Py_NOGIL]: 1
$ ./python -m test
...
== Python build: nogil debug
...
(cherry picked from commit 5afe0c17ca14df430736e549542a4b85e7e7c7ac)
* gh-90791: test.pythoninfo logs ASAN_OPTIONS env var (#108289)
* Cleanup libregrtest code logging ASAN_OPTIONS.
* Fix a typo on "ASAN_OPTIONS" vs "MSAN_OPTIONS".
(cherry picked from commit 3a1ac87f8f89d3206b46a0df4908afae629d669d)
* gh-108388: regrtest splits test_asyncio package (#108393)
Currently, test_asyncio package is only splitted into sub-tests when
using command "./python -m test". With this change, it's also
splitted when passing it on the command line:
"./python -m test test_asyncio".
Remove the concept of "STDTESTS". Python is now mature enough to not
have to bother with that anymore. Removing STDTESTS simplify the
code.
(cherry picked from commit 174e9da0836844a2138cc8915dd305cb2cd7a583)
* regrtest computes statistics (#108793)
test_netrc, test_pep646_syntax and test_xml_etree now return results
in the test_main() function.
Changes:
* Rewrite TestResult as a dataclass with a new State class.
* Add test.support.TestStats class and Regrtest.stats_dict attribute.
* libregrtest.runtest functions now modify a TestResult instance
in-place.
* libregrtest summary lists the number of run tests and skipped
tests, and denied resources.
* Add TestResult.has_meaningful_duration() method.
* Compute TestResult duration in the upper function.
* Use time.perf_counter() instead of time.monotonic().
* Regrtest: rename 'resource_denieds' attribute to 'resource_denied'.
* Rename CHILD_ERROR to MULTIPROCESSING_ERROR.
* Use match/case syntadx to have different code depending on the
test state.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit d4e534cbb35678c82b3a1276826af55d7bfc23b6)
* gh-108822: Add Changelog entry for regrtest statistics (#108821)
---------
Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Zachary Ware <zach@python.org>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Joshua Herman <zitterbewegung@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-09-03 19:21:53 +02:00
|
|
|
output = self.run_tests(testname, "-m", "nosuchtest",
|
|
|
|
|
exitcode=EXITCODE_NO_TESTS_RAN)
|
|
|
|
|
self.check_executed_tests(output, [testname],
|
|
|
|
|
run_no_tests=testname,
|
|
|
|
|
stats=0)
|
2018-11-29 17:17:44 +00:00
|
|
|
|
2018-12-14 13:06:50 +01:00
|
|
|
def test_no_tests_ran_skip(self):
|
|
|
|
|
code = textwrap.dedent("""
|
|
|
|
|
import unittest
|
|
|
|
|
|
|
|
|
|
class Tests(unittest.TestCase):
|
|
|
|
|
def test_skipped(self):
|
|
|
|
|
self.skipTest("because")
|
|
|
|
|
""")
|
|
|
|
|
testname = self.create_test(code=code)
|
|
|
|
|
|
[3.11] gh-108822: Backport libregrtest changes from the main branch (#108820)
* Revert "[3.11] gh-101634: regrtest reports decoding error as failed test (#106169) (#106175)"
This reverts commit d5418e97fc524420011a370ba3c2c3cf6a89a74f.
* Revert "[3.11] bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (GH-30895) (GH-103342)"
This reverts commit ecb09a849689764193e0115d27e220f82b5f6d9f.
* Revert "gh-95027: Fix regrtest stdout encoding on Windows (GH-98492)"
This reverts commit b2aa28eec56d07b9c6777b02b7247cf21839de9f.
* Revert "[3.11] gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253) (GH-94408)"
This reverts commit 0122ab235b5acb52dd99fd05d8802a00f438b828.
* Revert "Run Tools/scripts/reindent.py (GH-94225)"
This reverts commit f0f3a424afb00a15ce8c0140dd218f5b33929be6.
* Revert "gh-94052: Don't re-run failed tests with --python option (GH-94054)"
This reverts commit 1347607db12012f6458ffcba48d8ad797083812e.
* Revert "[3.11] gh-84461: Fix Emscripten umask and permission issues (GH-94002) (GH-94006)"
This reverts commit 10731849184a3101ed18683b0128d689f1671c3f.
* gh-93353: regrtest checks for leaked temporary files (#93776)
When running tests with -jN, create a temporary directory per process
and mark a test as "environment changed" if a test leaks a temporary
file or directory.
(cherry picked from commit e566ce5496f1bad81c431aaee65e36d5e44771c5)
* gh-93353: Fix regrtest for -jN with N >= 2 (GH-93813)
(cherry picked from commit 36934a16e86f34d69ba2d41630fb5b4d06d59cff)
* gh-93353: regrtest supports checking tmp files with -j2 (#93909)
regrtest now also implements checking for leaked temporary files and
directories when using -jN for N >= 2. Use tempfile.mkdtemp() to
create the temporary directory. Skip this check on WASI.
(cherry picked from commit 4f85cec9e2077681b3dacc3108e646d509b720bf)
* gh-84461: Fix Emscripten umask and permission issues (GH-94002)
- Emscripten's default umask is too strict, see
https://github.com/emscripten-core/emscripten/issues/17269
- getuid/getgid and geteuid/getegid are stubs that always return 0
(root). Disable effective uid/gid syscalls and fix tests that use
chmod() current user.
- Cannot drop X bit from directory.
(cherry picked from commit 2702e408fd0e0dd7aec396b4cf8c7ce9caae81d8)
* gh-94052: Don't re-run failed tests with --python option (#94054)
(cherry picked from commit 0ff7b996f5d836e63cdaf652c7aa734285261096)
* Run Tools/scripts/reindent.py (#94225)
Reindent files which were not properly formatted (PEP 8: 4 spaces).
Remove also some trailing spaces.
(cherry picked from commit e87ada48a9e5d9d03f9759138869216df0d7383a)
* gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253)
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 199ba233248ab279f445e0809c2077976f0711bc)
* gh-96465: Clear fractions hash lru_cache under refleak testing (GH-96689)
Automerge-Triggered-By: GH:zware
(cherry picked from commit 9c8f3794337457b1d905a9fa0f38c2978fe32abd)
* gh-95027: Fix regrtest stdout encoding on Windows (#98492)
On Windows, when the Python test suite is run with the -jN option,
the ANSI code page is now used as the encoding for the stdout
temporary file, rather than using UTF-8 which can lead to decoding
errors.
(cherry picked from commit ec1f6f5f139868dc2c1116a7c7c878c38c668d53)
* gh-98903: Test suite fails with exit code 4 if no tests ran (#98904)
The Python test suite now fails wit exit code 4 if no tests ran. It
should help detecting typos in test names and test methods.
* Add "EXITCODE_" constants to Lib/test/libregrtest/main.py.
* Fix a typo: "NO TEST RUN" becomes "NO TESTS RAN"
(cherry picked from commit c76db37c0d23174cbffd6fa978d39693890ef020)
* gh-100086: Add build info to test.libregrtest (#100093)
The Python test runner (libregrtest) now logs Python build information like
"debug" vs "release" build, or LTO and PGO optimizations.
(cherry picked from commit 3c892022472eb975360fb3f0caa6f6fcc6fbf220)
* bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (#30895)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
(cherry picked from commit 995386071f96e4cfebfa027a71ca9134e4651d2a)
* gh-82054: allow test runner to split test_asyncio to execute in parallel by sharding. (#103927)
This runs test_asyncio sub-tests in parallel using sharding from Cinder. This suite is typically the longest-pole in runs because it is a test package with a lot of further sub-tests otherwise run serially. By breaking out the sub-tests as independent modules we can run a lot more in parallel.
After porting we can see the direct impact on a multicore system.
Without this change:
Running make test is 5 min 26 seconds
With this change:
Running make test takes 3 min 39 seconds
That'll vary based on system and parallelism. On a `-j 4` run similar to what CI and buildbot systems often do, it reduced the overall test suite completion latency by 10%.
The drawbacks are that this implementation is hacky and due to the sorting of the tests it obscures when the asyncio tests occur and involves changing CPython test infrastructure but, the wall time saved it is worth it, especially in low-core count CI runs as it pulls a long tail. The win for productivity and reserved CI resource usage is significant.
Future tests that deserve to be refactored into split up suites to benefit from are test_concurrent_futures and the way the _test_multiprocessing suite gets run for all start methods. As exposed by passing the -o flag to python -m test to get a list of the 10 longest running tests.
---------
Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google, LLC]
(cherry picked from commit 9e011e7c77dad7d0bbb944c44891531606caeb21)
* Display the sanitizer config in the regrtest header. (#105301)
Display the sanitizers present in libregrtest.
Having this in the CI output for tests with the relevant environment
variable displayed will help make it easier to do what we need to
create an equivalent local test run.
(cherry picked from commit 852348ab65783601e0844b6647ea033668b45c11)
* gh-101634: regrtest reports decoding error as failed test (#106169)
When running the Python test suite with -jN option, if a worker stdout
cannot be decoded from the locale encoding report a failed testn so the
exitcode is non-zero.
(cherry picked from commit 2ac3eec103cf450aaaebeb932e51155d2e7fb37b)
* gh-108223: test.pythoninfo and libregrtest log Py_NOGIL (#108238)
Enable with --disable-gil --without-pydebug:
$ make pythoninfo|grep NOGIL
sysconfig[Py_NOGIL]: 1
$ ./python -m test
...
== Python build: nogil debug
...
(cherry picked from commit 5afe0c17ca14df430736e549542a4b85e7e7c7ac)
* gh-90791: test.pythoninfo logs ASAN_OPTIONS env var (#108289)
* Cleanup libregrtest code logging ASAN_OPTIONS.
* Fix a typo on "ASAN_OPTIONS" vs "MSAN_OPTIONS".
(cherry picked from commit 3a1ac87f8f89d3206b46a0df4908afae629d669d)
* gh-108388: regrtest splits test_asyncio package (#108393)
Currently, test_asyncio package is only splitted into sub-tests when
using command "./python -m test". With this change, it's also
splitted when passing it on the command line:
"./python -m test test_asyncio".
Remove the concept of "STDTESTS". Python is now mature enough to not
have to bother with that anymore. Removing STDTESTS simplify the
code.
(cherry picked from commit 174e9da0836844a2138cc8915dd305cb2cd7a583)
* regrtest computes statistics (#108793)
test_netrc, test_pep646_syntax and test_xml_etree now return results
in the test_main() function.
Changes:
* Rewrite TestResult as a dataclass with a new State class.
* Add test.support.TestStats class and Regrtest.stats_dict attribute.
* libregrtest.runtest functions now modify a TestResult instance
in-place.
* libregrtest summary lists the number of run tests and skipped
tests, and denied resources.
* Add TestResult.has_meaningful_duration() method.
* Compute TestResult duration in the upper function.
* Use time.perf_counter() instead of time.monotonic().
* Regrtest: rename 'resource_denieds' attribute to 'resource_denied'.
* Rename CHILD_ERROR to MULTIPROCESSING_ERROR.
* Use match/case syntadx to have different code depending on the
test state.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit d4e534cbb35678c82b3a1276826af55d7bfc23b6)
* gh-108822: Add Changelog entry for regrtest statistics (#108821)
---------
Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Zachary Ware <zach@python.org>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Joshua Herman <zitterbewegung@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-09-03 19:21:53 +02:00
|
|
|
output = self.run_tests(testname)
|
|
|
|
|
self.check_executed_tests(output, [testname],
|
|
|
|
|
stats=TestStats(1, skipped=1))
|
2018-12-14 13:06:50 +01:00
|
|
|
|
2018-11-29 17:17:44 +00:00
|
|
|
def test_no_tests_ran_multiple_tests_nonexistent(self):
|
|
|
|
|
code = textwrap.dedent("""
|
|
|
|
|
import unittest
|
|
|
|
|
|
|
|
|
|
class Tests(unittest.TestCase):
|
|
|
|
|
def test_bug(self):
|
|
|
|
|
pass
|
|
|
|
|
""")
|
|
|
|
|
testname = self.create_test(code=code)
|
|
|
|
|
testname2 = self.create_test(code=code)
|
|
|
|
|
|
[3.11] gh-108822: Backport libregrtest changes from the main branch (#108820)
* Revert "[3.11] gh-101634: regrtest reports decoding error as failed test (#106169) (#106175)"
This reverts commit d5418e97fc524420011a370ba3c2c3cf6a89a74f.
* Revert "[3.11] bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (GH-30895) (GH-103342)"
This reverts commit ecb09a849689764193e0115d27e220f82b5f6d9f.
* Revert "gh-95027: Fix regrtest stdout encoding on Windows (GH-98492)"
This reverts commit b2aa28eec56d07b9c6777b02b7247cf21839de9f.
* Revert "[3.11] gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253) (GH-94408)"
This reverts commit 0122ab235b5acb52dd99fd05d8802a00f438b828.
* Revert "Run Tools/scripts/reindent.py (GH-94225)"
This reverts commit f0f3a424afb00a15ce8c0140dd218f5b33929be6.
* Revert "gh-94052: Don't re-run failed tests with --python option (GH-94054)"
This reverts commit 1347607db12012f6458ffcba48d8ad797083812e.
* Revert "[3.11] gh-84461: Fix Emscripten umask and permission issues (GH-94002) (GH-94006)"
This reverts commit 10731849184a3101ed18683b0128d689f1671c3f.
* gh-93353: regrtest checks for leaked temporary files (#93776)
When running tests with -jN, create a temporary directory per process
and mark a test as "environment changed" if a test leaks a temporary
file or directory.
(cherry picked from commit e566ce5496f1bad81c431aaee65e36d5e44771c5)
* gh-93353: Fix regrtest for -jN with N >= 2 (GH-93813)
(cherry picked from commit 36934a16e86f34d69ba2d41630fb5b4d06d59cff)
* gh-93353: regrtest supports checking tmp files with -j2 (#93909)
regrtest now also implements checking for leaked temporary files and
directories when using -jN for N >= 2. Use tempfile.mkdtemp() to
create the temporary directory. Skip this check on WASI.
(cherry picked from commit 4f85cec9e2077681b3dacc3108e646d509b720bf)
* gh-84461: Fix Emscripten umask and permission issues (GH-94002)
- Emscripten's default umask is too strict, see
https://github.com/emscripten-core/emscripten/issues/17269
- getuid/getgid and geteuid/getegid are stubs that always return 0
(root). Disable effective uid/gid syscalls and fix tests that use
chmod() current user.
- Cannot drop X bit from directory.
(cherry picked from commit 2702e408fd0e0dd7aec396b4cf8c7ce9caae81d8)
* gh-94052: Don't re-run failed tests with --python option (#94054)
(cherry picked from commit 0ff7b996f5d836e63cdaf652c7aa734285261096)
* Run Tools/scripts/reindent.py (#94225)
Reindent files which were not properly formatted (PEP 8: 4 spaces).
Remove also some trailing spaces.
(cherry picked from commit e87ada48a9e5d9d03f9759138869216df0d7383a)
* gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253)
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 199ba233248ab279f445e0809c2077976f0711bc)
* gh-96465: Clear fractions hash lru_cache under refleak testing (GH-96689)
Automerge-Triggered-By: GH:zware
(cherry picked from commit 9c8f3794337457b1d905a9fa0f38c2978fe32abd)
* gh-95027: Fix regrtest stdout encoding on Windows (#98492)
On Windows, when the Python test suite is run with the -jN option,
the ANSI code page is now used as the encoding for the stdout
temporary file, rather than using UTF-8 which can lead to decoding
errors.
(cherry picked from commit ec1f6f5f139868dc2c1116a7c7c878c38c668d53)
* gh-98903: Test suite fails with exit code 4 if no tests ran (#98904)
The Python test suite now fails wit exit code 4 if no tests ran. It
should help detecting typos in test names and test methods.
* Add "EXITCODE_" constants to Lib/test/libregrtest/main.py.
* Fix a typo: "NO TEST RUN" becomes "NO TESTS RAN"
(cherry picked from commit c76db37c0d23174cbffd6fa978d39693890ef020)
* gh-100086: Add build info to test.libregrtest (#100093)
The Python test runner (libregrtest) now logs Python build information like
"debug" vs "release" build, or LTO and PGO optimizations.
(cherry picked from commit 3c892022472eb975360fb3f0caa6f6fcc6fbf220)
* bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (#30895)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
(cherry picked from commit 995386071f96e4cfebfa027a71ca9134e4651d2a)
* gh-82054: allow test runner to split test_asyncio to execute in parallel by sharding. (#103927)
This runs test_asyncio sub-tests in parallel using sharding from Cinder. This suite is typically the longest-pole in runs because it is a test package with a lot of further sub-tests otherwise run serially. By breaking out the sub-tests as independent modules we can run a lot more in parallel.
After porting we can see the direct impact on a multicore system.
Without this change:
Running make test is 5 min 26 seconds
With this change:
Running make test takes 3 min 39 seconds
That'll vary based on system and parallelism. On a `-j 4` run similar to what CI and buildbot systems often do, it reduced the overall test suite completion latency by 10%.
The drawbacks are that this implementation is hacky and due to the sorting of the tests it obscures when the asyncio tests occur and involves changing CPython test infrastructure but, the wall time saved it is worth it, especially in low-core count CI runs as it pulls a long tail. The win for productivity and reserved CI resource usage is significant.
Future tests that deserve to be refactored into split up suites to benefit from are test_concurrent_futures and the way the _test_multiprocessing suite gets run for all start methods. As exposed by passing the -o flag to python -m test to get a list of the 10 longest running tests.
---------
Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google, LLC]
(cherry picked from commit 9e011e7c77dad7d0bbb944c44891531606caeb21)
* Display the sanitizer config in the regrtest header. (#105301)
Display the sanitizers present in libregrtest.
Having this in the CI output for tests with the relevant environment
variable displayed will help make it easier to do what we need to
create an equivalent local test run.
(cherry picked from commit 852348ab65783601e0844b6647ea033668b45c11)
* gh-101634: regrtest reports decoding error as failed test (#106169)
When running the Python test suite with -jN option, if a worker stdout
cannot be decoded from the locale encoding report a failed testn so the
exitcode is non-zero.
(cherry picked from commit 2ac3eec103cf450aaaebeb932e51155d2e7fb37b)
* gh-108223: test.pythoninfo and libregrtest log Py_NOGIL (#108238)
Enable with --disable-gil --without-pydebug:
$ make pythoninfo|grep NOGIL
sysconfig[Py_NOGIL]: 1
$ ./python -m test
...
== Python build: nogil debug
...
(cherry picked from commit 5afe0c17ca14df430736e549542a4b85e7e7c7ac)
* gh-90791: test.pythoninfo logs ASAN_OPTIONS env var (#108289)
* Cleanup libregrtest code logging ASAN_OPTIONS.
* Fix a typo on "ASAN_OPTIONS" vs "MSAN_OPTIONS".
(cherry picked from commit 3a1ac87f8f89d3206b46a0df4908afae629d669d)
* gh-108388: regrtest splits test_asyncio package (#108393)
Currently, test_asyncio package is only splitted into sub-tests when
using command "./python -m test". With this change, it's also
splitted when passing it on the command line:
"./python -m test test_asyncio".
Remove the concept of "STDTESTS". Python is now mature enough to not
have to bother with that anymore. Removing STDTESTS simplify the
code.
(cherry picked from commit 174e9da0836844a2138cc8915dd305cb2cd7a583)
* regrtest computes statistics (#108793)
test_netrc, test_pep646_syntax and test_xml_etree now return results
in the test_main() function.
Changes:
* Rewrite TestResult as a dataclass with a new State class.
* Add test.support.TestStats class and Regrtest.stats_dict attribute.
* libregrtest.runtest functions now modify a TestResult instance
in-place.
* libregrtest summary lists the number of run tests and skipped
tests, and denied resources.
* Add TestResult.has_meaningful_duration() method.
* Compute TestResult duration in the upper function.
* Use time.perf_counter() instead of time.monotonic().
* Regrtest: rename 'resource_denieds' attribute to 'resource_denied'.
* Rename CHILD_ERROR to MULTIPROCESSING_ERROR.
* Use match/case syntadx to have different code depending on the
test state.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit d4e534cbb35678c82b3a1276826af55d7bfc23b6)
* gh-108822: Add Changelog entry for regrtest statistics (#108821)
---------
Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Zachary Ware <zach@python.org>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Joshua Herman <zitterbewegung@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-09-03 19:21:53 +02:00
|
|
|
output = self.run_tests(testname, testname2, "-m", "nosuchtest",
|
|
|
|
|
exitcode=EXITCODE_NO_TESTS_RAN)
|
2018-11-29 17:17:44 +00:00
|
|
|
self.check_executed_tests(output, [testname, testname2],
|
[3.11] gh-108822: Backport libregrtest changes from the main branch (#108820)
* Revert "[3.11] gh-101634: regrtest reports decoding error as failed test (#106169) (#106175)"
This reverts commit d5418e97fc524420011a370ba3c2c3cf6a89a74f.
* Revert "[3.11] bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (GH-30895) (GH-103342)"
This reverts commit ecb09a849689764193e0115d27e220f82b5f6d9f.
* Revert "gh-95027: Fix regrtest stdout encoding on Windows (GH-98492)"
This reverts commit b2aa28eec56d07b9c6777b02b7247cf21839de9f.
* Revert "[3.11] gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253) (GH-94408)"
This reverts commit 0122ab235b5acb52dd99fd05d8802a00f438b828.
* Revert "Run Tools/scripts/reindent.py (GH-94225)"
This reverts commit f0f3a424afb00a15ce8c0140dd218f5b33929be6.
* Revert "gh-94052: Don't re-run failed tests with --python option (GH-94054)"
This reverts commit 1347607db12012f6458ffcba48d8ad797083812e.
* Revert "[3.11] gh-84461: Fix Emscripten umask and permission issues (GH-94002) (GH-94006)"
This reverts commit 10731849184a3101ed18683b0128d689f1671c3f.
* gh-93353: regrtest checks for leaked temporary files (#93776)
When running tests with -jN, create a temporary directory per process
and mark a test as "environment changed" if a test leaks a temporary
file or directory.
(cherry picked from commit e566ce5496f1bad81c431aaee65e36d5e44771c5)
* gh-93353: Fix regrtest for -jN with N >= 2 (GH-93813)
(cherry picked from commit 36934a16e86f34d69ba2d41630fb5b4d06d59cff)
* gh-93353: regrtest supports checking tmp files with -j2 (#93909)
regrtest now also implements checking for leaked temporary files and
directories when using -jN for N >= 2. Use tempfile.mkdtemp() to
create the temporary directory. Skip this check on WASI.
(cherry picked from commit 4f85cec9e2077681b3dacc3108e646d509b720bf)
* gh-84461: Fix Emscripten umask and permission issues (GH-94002)
- Emscripten's default umask is too strict, see
https://github.com/emscripten-core/emscripten/issues/17269
- getuid/getgid and geteuid/getegid are stubs that always return 0
(root). Disable effective uid/gid syscalls and fix tests that use
chmod() current user.
- Cannot drop X bit from directory.
(cherry picked from commit 2702e408fd0e0dd7aec396b4cf8c7ce9caae81d8)
* gh-94052: Don't re-run failed tests with --python option (#94054)
(cherry picked from commit 0ff7b996f5d836e63cdaf652c7aa734285261096)
* Run Tools/scripts/reindent.py (#94225)
Reindent files which were not properly formatted (PEP 8: 4 spaces).
Remove also some trailing spaces.
(cherry picked from commit e87ada48a9e5d9d03f9759138869216df0d7383a)
* gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253)
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 199ba233248ab279f445e0809c2077976f0711bc)
* gh-96465: Clear fractions hash lru_cache under refleak testing (GH-96689)
Automerge-Triggered-By: GH:zware
(cherry picked from commit 9c8f3794337457b1d905a9fa0f38c2978fe32abd)
* gh-95027: Fix regrtest stdout encoding on Windows (#98492)
On Windows, when the Python test suite is run with the -jN option,
the ANSI code page is now used as the encoding for the stdout
temporary file, rather than using UTF-8 which can lead to decoding
errors.
(cherry picked from commit ec1f6f5f139868dc2c1116a7c7c878c38c668d53)
* gh-98903: Test suite fails with exit code 4 if no tests ran (#98904)
The Python test suite now fails wit exit code 4 if no tests ran. It
should help detecting typos in test names and test methods.
* Add "EXITCODE_" constants to Lib/test/libregrtest/main.py.
* Fix a typo: "NO TEST RUN" becomes "NO TESTS RAN"
(cherry picked from commit c76db37c0d23174cbffd6fa978d39693890ef020)
* gh-100086: Add build info to test.libregrtest (#100093)
The Python test runner (libregrtest) now logs Python build information like
"debug" vs "release" build, or LTO and PGO optimizations.
(cherry picked from commit 3c892022472eb975360fb3f0caa6f6fcc6fbf220)
* bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (#30895)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
(cherry picked from commit 995386071f96e4cfebfa027a71ca9134e4651d2a)
* gh-82054: allow test runner to split test_asyncio to execute in parallel by sharding. (#103927)
This runs test_asyncio sub-tests in parallel using sharding from Cinder. This suite is typically the longest-pole in runs because it is a test package with a lot of further sub-tests otherwise run serially. By breaking out the sub-tests as independent modules we can run a lot more in parallel.
After porting we can see the direct impact on a multicore system.
Without this change:
Running make test is 5 min 26 seconds
With this change:
Running make test takes 3 min 39 seconds
That'll vary based on system and parallelism. On a `-j 4` run similar to what CI and buildbot systems often do, it reduced the overall test suite completion latency by 10%.
The drawbacks are that this implementation is hacky and due to the sorting of the tests it obscures when the asyncio tests occur and involves changing CPython test infrastructure but, the wall time saved it is worth it, especially in low-core count CI runs as it pulls a long tail. The win for productivity and reserved CI resource usage is significant.
Future tests that deserve to be refactored into split up suites to benefit from are test_concurrent_futures and the way the _test_multiprocessing suite gets run for all start methods. As exposed by passing the -o flag to python -m test to get a list of the 10 longest running tests.
---------
Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google, LLC]
(cherry picked from commit 9e011e7c77dad7d0bbb944c44891531606caeb21)
* Display the sanitizer config in the regrtest header. (#105301)
Display the sanitizers present in libregrtest.
Having this in the CI output for tests with the relevant environment
variable displayed will help make it easier to do what we need to
create an equivalent local test run.
(cherry picked from commit 852348ab65783601e0844b6647ea033668b45c11)
* gh-101634: regrtest reports decoding error as failed test (#106169)
When running the Python test suite with -jN option, if a worker stdout
cannot be decoded from the locale encoding report a failed testn so the
exitcode is non-zero.
(cherry picked from commit 2ac3eec103cf450aaaebeb932e51155d2e7fb37b)
* gh-108223: test.pythoninfo and libregrtest log Py_NOGIL (#108238)
Enable with --disable-gil --without-pydebug:
$ make pythoninfo|grep NOGIL
sysconfig[Py_NOGIL]: 1
$ ./python -m test
...
== Python build: nogil debug
...
(cherry picked from commit 5afe0c17ca14df430736e549542a4b85e7e7c7ac)
* gh-90791: test.pythoninfo logs ASAN_OPTIONS env var (#108289)
* Cleanup libregrtest code logging ASAN_OPTIONS.
* Fix a typo on "ASAN_OPTIONS" vs "MSAN_OPTIONS".
(cherry picked from commit 3a1ac87f8f89d3206b46a0df4908afae629d669d)
* gh-108388: regrtest splits test_asyncio package (#108393)
Currently, test_asyncio package is only splitted into sub-tests when
using command "./python -m test". With this change, it's also
splitted when passing it on the command line:
"./python -m test test_asyncio".
Remove the concept of "STDTESTS". Python is now mature enough to not
have to bother with that anymore. Removing STDTESTS simplify the
code.
(cherry picked from commit 174e9da0836844a2138cc8915dd305cb2cd7a583)
* regrtest computes statistics (#108793)
test_netrc, test_pep646_syntax and test_xml_etree now return results
in the test_main() function.
Changes:
* Rewrite TestResult as a dataclass with a new State class.
* Add test.support.TestStats class and Regrtest.stats_dict attribute.
* libregrtest.runtest functions now modify a TestResult instance
in-place.
* libregrtest summary lists the number of run tests and skipped
tests, and denied resources.
* Add TestResult.has_meaningful_duration() method.
* Compute TestResult duration in the upper function.
* Use time.perf_counter() instead of time.monotonic().
* Regrtest: rename 'resource_denieds' attribute to 'resource_denied'.
* Rename CHILD_ERROR to MULTIPROCESSING_ERROR.
* Use match/case syntadx to have different code depending on the
test state.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit d4e534cbb35678c82b3a1276826af55d7bfc23b6)
* gh-108822: Add Changelog entry for regrtest statistics (#108821)
---------
Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Zachary Ware <zach@python.org>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Joshua Herman <zitterbewegung@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-09-03 19:21:53 +02:00
|
|
|
run_no_tests=[testname, testname2],
|
|
|
|
|
stats=0)
|
2018-11-29 17:17:44 +00:00
|
|
|
|
|
|
|
|
def test_no_test_ran_some_test_exist_some_not(self):
|
|
|
|
|
code = textwrap.dedent("""
|
|
|
|
|
import unittest
|
|
|
|
|
|
|
|
|
|
class Tests(unittest.TestCase):
|
|
|
|
|
def test_bug(self):
|
|
|
|
|
pass
|
|
|
|
|
""")
|
|
|
|
|
testname = self.create_test(code=code)
|
|
|
|
|
other_code = textwrap.dedent("""
|
|
|
|
|
import unittest
|
|
|
|
|
|
|
|
|
|
class Tests(unittest.TestCase):
|
|
|
|
|
def test_other_bug(self):
|
|
|
|
|
pass
|
|
|
|
|
""")
|
|
|
|
|
testname2 = self.create_test(code=other_code)
|
|
|
|
|
|
|
|
|
|
output = self.run_tests(testname, testname2, "-m", "nosuchtest",
|
|
|
|
|
"-m", "test_other_bug", exitcode=0)
|
|
|
|
|
self.check_executed_tests(output, [testname, testname2],
|
[3.11] gh-108822: Backport libregrtest changes from the main branch (#108820)
* Revert "[3.11] gh-101634: regrtest reports decoding error as failed test (#106169) (#106175)"
This reverts commit d5418e97fc524420011a370ba3c2c3cf6a89a74f.
* Revert "[3.11] bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (GH-30895) (GH-103342)"
This reverts commit ecb09a849689764193e0115d27e220f82b5f6d9f.
* Revert "gh-95027: Fix regrtest stdout encoding on Windows (GH-98492)"
This reverts commit b2aa28eec56d07b9c6777b02b7247cf21839de9f.
* Revert "[3.11] gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253) (GH-94408)"
This reverts commit 0122ab235b5acb52dd99fd05d8802a00f438b828.
* Revert "Run Tools/scripts/reindent.py (GH-94225)"
This reverts commit f0f3a424afb00a15ce8c0140dd218f5b33929be6.
* Revert "gh-94052: Don't re-run failed tests with --python option (GH-94054)"
This reverts commit 1347607db12012f6458ffcba48d8ad797083812e.
* Revert "[3.11] gh-84461: Fix Emscripten umask and permission issues (GH-94002) (GH-94006)"
This reverts commit 10731849184a3101ed18683b0128d689f1671c3f.
* gh-93353: regrtest checks for leaked temporary files (#93776)
When running tests with -jN, create a temporary directory per process
and mark a test as "environment changed" if a test leaks a temporary
file or directory.
(cherry picked from commit e566ce5496f1bad81c431aaee65e36d5e44771c5)
* gh-93353: Fix regrtest for -jN with N >= 2 (GH-93813)
(cherry picked from commit 36934a16e86f34d69ba2d41630fb5b4d06d59cff)
* gh-93353: regrtest supports checking tmp files with -j2 (#93909)
regrtest now also implements checking for leaked temporary files and
directories when using -jN for N >= 2. Use tempfile.mkdtemp() to
create the temporary directory. Skip this check on WASI.
(cherry picked from commit 4f85cec9e2077681b3dacc3108e646d509b720bf)
* gh-84461: Fix Emscripten umask and permission issues (GH-94002)
- Emscripten's default umask is too strict, see
https://github.com/emscripten-core/emscripten/issues/17269
- getuid/getgid and geteuid/getegid are stubs that always return 0
(root). Disable effective uid/gid syscalls and fix tests that use
chmod() current user.
- Cannot drop X bit from directory.
(cherry picked from commit 2702e408fd0e0dd7aec396b4cf8c7ce9caae81d8)
* gh-94052: Don't re-run failed tests with --python option (#94054)
(cherry picked from commit 0ff7b996f5d836e63cdaf652c7aa734285261096)
* Run Tools/scripts/reindent.py (#94225)
Reindent files which were not properly formatted (PEP 8: 4 spaces).
Remove also some trailing spaces.
(cherry picked from commit e87ada48a9e5d9d03f9759138869216df0d7383a)
* gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253)
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 199ba233248ab279f445e0809c2077976f0711bc)
* gh-96465: Clear fractions hash lru_cache under refleak testing (GH-96689)
Automerge-Triggered-By: GH:zware
(cherry picked from commit 9c8f3794337457b1d905a9fa0f38c2978fe32abd)
* gh-95027: Fix regrtest stdout encoding on Windows (#98492)
On Windows, when the Python test suite is run with the -jN option,
the ANSI code page is now used as the encoding for the stdout
temporary file, rather than using UTF-8 which can lead to decoding
errors.
(cherry picked from commit ec1f6f5f139868dc2c1116a7c7c878c38c668d53)
* gh-98903: Test suite fails with exit code 4 if no tests ran (#98904)
The Python test suite now fails wit exit code 4 if no tests ran. It
should help detecting typos in test names and test methods.
* Add "EXITCODE_" constants to Lib/test/libregrtest/main.py.
* Fix a typo: "NO TEST RUN" becomes "NO TESTS RAN"
(cherry picked from commit c76db37c0d23174cbffd6fa978d39693890ef020)
* gh-100086: Add build info to test.libregrtest (#100093)
The Python test runner (libregrtest) now logs Python build information like
"debug" vs "release" build, or LTO and PGO optimizations.
(cherry picked from commit 3c892022472eb975360fb3f0caa6f6fcc6fbf220)
* bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (#30895)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
(cherry picked from commit 995386071f96e4cfebfa027a71ca9134e4651d2a)
* gh-82054: allow test runner to split test_asyncio to execute in parallel by sharding. (#103927)
This runs test_asyncio sub-tests in parallel using sharding from Cinder. This suite is typically the longest-pole in runs because it is a test package with a lot of further sub-tests otherwise run serially. By breaking out the sub-tests as independent modules we can run a lot more in parallel.
After porting we can see the direct impact on a multicore system.
Without this change:
Running make test is 5 min 26 seconds
With this change:
Running make test takes 3 min 39 seconds
That'll vary based on system and parallelism. On a `-j 4` run similar to what CI and buildbot systems often do, it reduced the overall test suite completion latency by 10%.
The drawbacks are that this implementation is hacky and due to the sorting of the tests it obscures when the asyncio tests occur and involves changing CPython test infrastructure but, the wall time saved it is worth it, especially in low-core count CI runs as it pulls a long tail. The win for productivity and reserved CI resource usage is significant.
Future tests that deserve to be refactored into split up suites to benefit from are test_concurrent_futures and the way the _test_multiprocessing suite gets run for all start methods. As exposed by passing the -o flag to python -m test to get a list of the 10 longest running tests.
---------
Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google, LLC]
(cherry picked from commit 9e011e7c77dad7d0bbb944c44891531606caeb21)
* Display the sanitizer config in the regrtest header. (#105301)
Display the sanitizers present in libregrtest.
Having this in the CI output for tests with the relevant environment
variable displayed will help make it easier to do what we need to
create an equivalent local test run.
(cherry picked from commit 852348ab65783601e0844b6647ea033668b45c11)
* gh-101634: regrtest reports decoding error as failed test (#106169)
When running the Python test suite with -jN option, if a worker stdout
cannot be decoded from the locale encoding report a failed testn so the
exitcode is non-zero.
(cherry picked from commit 2ac3eec103cf450aaaebeb932e51155d2e7fb37b)
* gh-108223: test.pythoninfo and libregrtest log Py_NOGIL (#108238)
Enable with --disable-gil --without-pydebug:
$ make pythoninfo|grep NOGIL
sysconfig[Py_NOGIL]: 1
$ ./python -m test
...
== Python build: nogil debug
...
(cherry picked from commit 5afe0c17ca14df430736e549542a4b85e7e7c7ac)
* gh-90791: test.pythoninfo logs ASAN_OPTIONS env var (#108289)
* Cleanup libregrtest code logging ASAN_OPTIONS.
* Fix a typo on "ASAN_OPTIONS" vs "MSAN_OPTIONS".
(cherry picked from commit 3a1ac87f8f89d3206b46a0df4908afae629d669d)
* gh-108388: regrtest splits test_asyncio package (#108393)
Currently, test_asyncio package is only splitted into sub-tests when
using command "./python -m test". With this change, it's also
splitted when passing it on the command line:
"./python -m test test_asyncio".
Remove the concept of "STDTESTS". Python is now mature enough to not
have to bother with that anymore. Removing STDTESTS simplify the
code.
(cherry picked from commit 174e9da0836844a2138cc8915dd305cb2cd7a583)
* regrtest computes statistics (#108793)
test_netrc, test_pep646_syntax and test_xml_etree now return results
in the test_main() function.
Changes:
* Rewrite TestResult as a dataclass with a new State class.
* Add test.support.TestStats class and Regrtest.stats_dict attribute.
* libregrtest.runtest functions now modify a TestResult instance
in-place.
* libregrtest summary lists the number of run tests and skipped
tests, and denied resources.
* Add TestResult.has_meaningful_duration() method.
* Compute TestResult duration in the upper function.
* Use time.perf_counter() instead of time.monotonic().
* Regrtest: rename 'resource_denieds' attribute to 'resource_denied'.
* Rename CHILD_ERROR to MULTIPROCESSING_ERROR.
* Use match/case syntadx to have different code depending on the
test state.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit d4e534cbb35678c82b3a1276826af55d7bfc23b6)
* gh-108822: Add Changelog entry for regrtest statistics (#108821)
---------
Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Zachary Ware <zach@python.org>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Joshua Herman <zitterbewegung@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-09-03 19:21:53 +02:00
|
|
|
run_no_tests=[testname],
|
|
|
|
|
stats=1)
|
2018-06-08 09:53:51 +02:00
|
|
|
|
2019-04-26 09:28:53 +02:00
|
|
|
@support.cpython_only
|
2021-11-12 16:19:09 +01:00
|
|
|
def test_uncollectable(self):
|
2019-04-26 09:28:53 +02:00
|
|
|
code = textwrap.dedent(r"""
|
|
|
|
|
import _testcapi
|
|
|
|
|
import gc
|
|
|
|
|
import unittest
|
|
|
|
|
|
|
|
|
|
@_testcapi.with_tp_del
|
|
|
|
|
class Garbage:
|
|
|
|
|
def __tp_del__(self):
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
class Tests(unittest.TestCase):
|
|
|
|
|
def test_garbage(self):
|
|
|
|
|
# create an uncollectable object
|
|
|
|
|
obj = Garbage()
|
|
|
|
|
obj.ref_cycle = obj
|
|
|
|
|
obj = None
|
|
|
|
|
""")
|
|
|
|
|
testname = self.create_test(code=code)
|
|
|
|
|
|
[3.11] gh-108822: Backport libregrtest changes from the main branch (#108820)
* Revert "[3.11] gh-101634: regrtest reports decoding error as failed test (#106169) (#106175)"
This reverts commit d5418e97fc524420011a370ba3c2c3cf6a89a74f.
* Revert "[3.11] bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (GH-30895) (GH-103342)"
This reverts commit ecb09a849689764193e0115d27e220f82b5f6d9f.
* Revert "gh-95027: Fix regrtest stdout encoding on Windows (GH-98492)"
This reverts commit b2aa28eec56d07b9c6777b02b7247cf21839de9f.
* Revert "[3.11] gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253) (GH-94408)"
This reverts commit 0122ab235b5acb52dd99fd05d8802a00f438b828.
* Revert "Run Tools/scripts/reindent.py (GH-94225)"
This reverts commit f0f3a424afb00a15ce8c0140dd218f5b33929be6.
* Revert "gh-94052: Don't re-run failed tests with --python option (GH-94054)"
This reverts commit 1347607db12012f6458ffcba48d8ad797083812e.
* Revert "[3.11] gh-84461: Fix Emscripten umask and permission issues (GH-94002) (GH-94006)"
This reverts commit 10731849184a3101ed18683b0128d689f1671c3f.
* gh-93353: regrtest checks for leaked temporary files (#93776)
When running tests with -jN, create a temporary directory per process
and mark a test as "environment changed" if a test leaks a temporary
file or directory.
(cherry picked from commit e566ce5496f1bad81c431aaee65e36d5e44771c5)
* gh-93353: Fix regrtest for -jN with N >= 2 (GH-93813)
(cherry picked from commit 36934a16e86f34d69ba2d41630fb5b4d06d59cff)
* gh-93353: regrtest supports checking tmp files with -j2 (#93909)
regrtest now also implements checking for leaked temporary files and
directories when using -jN for N >= 2. Use tempfile.mkdtemp() to
create the temporary directory. Skip this check on WASI.
(cherry picked from commit 4f85cec9e2077681b3dacc3108e646d509b720bf)
* gh-84461: Fix Emscripten umask and permission issues (GH-94002)
- Emscripten's default umask is too strict, see
https://github.com/emscripten-core/emscripten/issues/17269
- getuid/getgid and geteuid/getegid are stubs that always return 0
(root). Disable effective uid/gid syscalls and fix tests that use
chmod() current user.
- Cannot drop X bit from directory.
(cherry picked from commit 2702e408fd0e0dd7aec396b4cf8c7ce9caae81d8)
* gh-94052: Don't re-run failed tests with --python option (#94054)
(cherry picked from commit 0ff7b996f5d836e63cdaf652c7aa734285261096)
* Run Tools/scripts/reindent.py (#94225)
Reindent files which were not properly formatted (PEP 8: 4 spaces).
Remove also some trailing spaces.
(cherry picked from commit e87ada48a9e5d9d03f9759138869216df0d7383a)
* gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253)
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 199ba233248ab279f445e0809c2077976f0711bc)
* gh-96465: Clear fractions hash lru_cache under refleak testing (GH-96689)
Automerge-Triggered-By: GH:zware
(cherry picked from commit 9c8f3794337457b1d905a9fa0f38c2978fe32abd)
* gh-95027: Fix regrtest stdout encoding on Windows (#98492)
On Windows, when the Python test suite is run with the -jN option,
the ANSI code page is now used as the encoding for the stdout
temporary file, rather than using UTF-8 which can lead to decoding
errors.
(cherry picked from commit ec1f6f5f139868dc2c1116a7c7c878c38c668d53)
* gh-98903: Test suite fails with exit code 4 if no tests ran (#98904)
The Python test suite now fails wit exit code 4 if no tests ran. It
should help detecting typos in test names and test methods.
* Add "EXITCODE_" constants to Lib/test/libregrtest/main.py.
* Fix a typo: "NO TEST RUN" becomes "NO TESTS RAN"
(cherry picked from commit c76db37c0d23174cbffd6fa978d39693890ef020)
* gh-100086: Add build info to test.libregrtest (#100093)
The Python test runner (libregrtest) now logs Python build information like
"debug" vs "release" build, or LTO and PGO optimizations.
(cherry picked from commit 3c892022472eb975360fb3f0caa6f6fcc6fbf220)
* bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (#30895)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
(cherry picked from commit 995386071f96e4cfebfa027a71ca9134e4651d2a)
* gh-82054: allow test runner to split test_asyncio to execute in parallel by sharding. (#103927)
This runs test_asyncio sub-tests in parallel using sharding from Cinder. This suite is typically the longest-pole in runs because it is a test package with a lot of further sub-tests otherwise run serially. By breaking out the sub-tests as independent modules we can run a lot more in parallel.
After porting we can see the direct impact on a multicore system.
Without this change:
Running make test is 5 min 26 seconds
With this change:
Running make test takes 3 min 39 seconds
That'll vary based on system and parallelism. On a `-j 4` run similar to what CI and buildbot systems often do, it reduced the overall test suite completion latency by 10%.
The drawbacks are that this implementation is hacky and due to the sorting of the tests it obscures when the asyncio tests occur and involves changing CPython test infrastructure but, the wall time saved it is worth it, especially in low-core count CI runs as it pulls a long tail. The win for productivity and reserved CI resource usage is significant.
Future tests that deserve to be refactored into split up suites to benefit from are test_concurrent_futures and the way the _test_multiprocessing suite gets run for all start methods. As exposed by passing the -o flag to python -m test to get a list of the 10 longest running tests.
---------
Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google, LLC]
(cherry picked from commit 9e011e7c77dad7d0bbb944c44891531606caeb21)
* Display the sanitizer config in the regrtest header. (#105301)
Display the sanitizers present in libregrtest.
Having this in the CI output for tests with the relevant environment
variable displayed will help make it easier to do what we need to
create an equivalent local test run.
(cherry picked from commit 852348ab65783601e0844b6647ea033668b45c11)
* gh-101634: regrtest reports decoding error as failed test (#106169)
When running the Python test suite with -jN option, if a worker stdout
cannot be decoded from the locale encoding report a failed testn so the
exitcode is non-zero.
(cherry picked from commit 2ac3eec103cf450aaaebeb932e51155d2e7fb37b)
* gh-108223: test.pythoninfo and libregrtest log Py_NOGIL (#108238)
Enable with --disable-gil --without-pydebug:
$ make pythoninfo|grep NOGIL
sysconfig[Py_NOGIL]: 1
$ ./python -m test
...
== Python build: nogil debug
...
(cherry picked from commit 5afe0c17ca14df430736e549542a4b85e7e7c7ac)
* gh-90791: test.pythoninfo logs ASAN_OPTIONS env var (#108289)
* Cleanup libregrtest code logging ASAN_OPTIONS.
* Fix a typo on "ASAN_OPTIONS" vs "MSAN_OPTIONS".
(cherry picked from commit 3a1ac87f8f89d3206b46a0df4908afae629d669d)
* gh-108388: regrtest splits test_asyncio package (#108393)
Currently, test_asyncio package is only splitted into sub-tests when
using command "./python -m test". With this change, it's also
splitted when passing it on the command line:
"./python -m test test_asyncio".
Remove the concept of "STDTESTS". Python is now mature enough to not
have to bother with that anymore. Removing STDTESTS simplify the
code.
(cherry picked from commit 174e9da0836844a2138cc8915dd305cb2cd7a583)
* regrtest computes statistics (#108793)
test_netrc, test_pep646_syntax and test_xml_etree now return results
in the test_main() function.
Changes:
* Rewrite TestResult as a dataclass with a new State class.
* Add test.support.TestStats class and Regrtest.stats_dict attribute.
* libregrtest.runtest functions now modify a TestResult instance
in-place.
* libregrtest summary lists the number of run tests and skipped
tests, and denied resources.
* Add TestResult.has_meaningful_duration() method.
* Compute TestResult duration in the upper function.
* Use time.perf_counter() instead of time.monotonic().
* Regrtest: rename 'resource_denieds' attribute to 'resource_denied'.
* Rename CHILD_ERROR to MULTIPROCESSING_ERROR.
* Use match/case syntadx to have different code depending on the
test state.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit d4e534cbb35678c82b3a1276826af55d7bfc23b6)
* gh-108822: Add Changelog entry for regrtest statistics (#108821)
---------
Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Zachary Ware <zach@python.org>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Joshua Herman <zitterbewegung@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-09-03 19:21:53 +02:00
|
|
|
output = self.run_tests("--fail-env-changed", testname,
|
|
|
|
|
exitcode=EXITCODE_ENV_CHANGED)
|
2019-04-26 09:28:53 +02:00
|
|
|
self.check_executed_tests(output, [testname],
|
|
|
|
|
env_changed=[testname],
|
[3.11] gh-108822: Backport libregrtest changes from the main branch (#108820)
* Revert "[3.11] gh-101634: regrtest reports decoding error as failed test (#106169) (#106175)"
This reverts commit d5418e97fc524420011a370ba3c2c3cf6a89a74f.
* Revert "[3.11] bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (GH-30895) (GH-103342)"
This reverts commit ecb09a849689764193e0115d27e220f82b5f6d9f.
* Revert "gh-95027: Fix regrtest stdout encoding on Windows (GH-98492)"
This reverts commit b2aa28eec56d07b9c6777b02b7247cf21839de9f.
* Revert "[3.11] gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253) (GH-94408)"
This reverts commit 0122ab235b5acb52dd99fd05d8802a00f438b828.
* Revert "Run Tools/scripts/reindent.py (GH-94225)"
This reverts commit f0f3a424afb00a15ce8c0140dd218f5b33929be6.
* Revert "gh-94052: Don't re-run failed tests with --python option (GH-94054)"
This reverts commit 1347607db12012f6458ffcba48d8ad797083812e.
* Revert "[3.11] gh-84461: Fix Emscripten umask and permission issues (GH-94002) (GH-94006)"
This reverts commit 10731849184a3101ed18683b0128d689f1671c3f.
* gh-93353: regrtest checks for leaked temporary files (#93776)
When running tests with -jN, create a temporary directory per process
and mark a test as "environment changed" if a test leaks a temporary
file or directory.
(cherry picked from commit e566ce5496f1bad81c431aaee65e36d5e44771c5)
* gh-93353: Fix regrtest for -jN with N >= 2 (GH-93813)
(cherry picked from commit 36934a16e86f34d69ba2d41630fb5b4d06d59cff)
* gh-93353: regrtest supports checking tmp files with -j2 (#93909)
regrtest now also implements checking for leaked temporary files and
directories when using -jN for N >= 2. Use tempfile.mkdtemp() to
create the temporary directory. Skip this check on WASI.
(cherry picked from commit 4f85cec9e2077681b3dacc3108e646d509b720bf)
* gh-84461: Fix Emscripten umask and permission issues (GH-94002)
- Emscripten's default umask is too strict, see
https://github.com/emscripten-core/emscripten/issues/17269
- getuid/getgid and geteuid/getegid are stubs that always return 0
(root). Disable effective uid/gid syscalls and fix tests that use
chmod() current user.
- Cannot drop X bit from directory.
(cherry picked from commit 2702e408fd0e0dd7aec396b4cf8c7ce9caae81d8)
* gh-94052: Don't re-run failed tests with --python option (#94054)
(cherry picked from commit 0ff7b996f5d836e63cdaf652c7aa734285261096)
* Run Tools/scripts/reindent.py (#94225)
Reindent files which were not properly formatted (PEP 8: 4 spaces).
Remove also some trailing spaces.
(cherry picked from commit e87ada48a9e5d9d03f9759138869216df0d7383a)
* gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253)
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 199ba233248ab279f445e0809c2077976f0711bc)
* gh-96465: Clear fractions hash lru_cache under refleak testing (GH-96689)
Automerge-Triggered-By: GH:zware
(cherry picked from commit 9c8f3794337457b1d905a9fa0f38c2978fe32abd)
* gh-95027: Fix regrtest stdout encoding on Windows (#98492)
On Windows, when the Python test suite is run with the -jN option,
the ANSI code page is now used as the encoding for the stdout
temporary file, rather than using UTF-8 which can lead to decoding
errors.
(cherry picked from commit ec1f6f5f139868dc2c1116a7c7c878c38c668d53)
* gh-98903: Test suite fails with exit code 4 if no tests ran (#98904)
The Python test suite now fails wit exit code 4 if no tests ran. It
should help detecting typos in test names and test methods.
* Add "EXITCODE_" constants to Lib/test/libregrtest/main.py.
* Fix a typo: "NO TEST RUN" becomes "NO TESTS RAN"
(cherry picked from commit c76db37c0d23174cbffd6fa978d39693890ef020)
* gh-100086: Add build info to test.libregrtest (#100093)
The Python test runner (libregrtest) now logs Python build information like
"debug" vs "release" build, or LTO and PGO optimizations.
(cherry picked from commit 3c892022472eb975360fb3f0caa6f6fcc6fbf220)
* bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (#30895)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
(cherry picked from commit 995386071f96e4cfebfa027a71ca9134e4651d2a)
* gh-82054: allow test runner to split test_asyncio to execute in parallel by sharding. (#103927)
This runs test_asyncio sub-tests in parallel using sharding from Cinder. This suite is typically the longest-pole in runs because it is a test package with a lot of further sub-tests otherwise run serially. By breaking out the sub-tests as independent modules we can run a lot more in parallel.
After porting we can see the direct impact on a multicore system.
Without this change:
Running make test is 5 min 26 seconds
With this change:
Running make test takes 3 min 39 seconds
That'll vary based on system and parallelism. On a `-j 4` run similar to what CI and buildbot systems often do, it reduced the overall test suite completion latency by 10%.
The drawbacks are that this implementation is hacky and due to the sorting of the tests it obscures when the asyncio tests occur and involves changing CPython test infrastructure but, the wall time saved it is worth it, especially in low-core count CI runs as it pulls a long tail. The win for productivity and reserved CI resource usage is significant.
Future tests that deserve to be refactored into split up suites to benefit from are test_concurrent_futures and the way the _test_multiprocessing suite gets run for all start methods. As exposed by passing the -o flag to python -m test to get a list of the 10 longest running tests.
---------
Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google, LLC]
(cherry picked from commit 9e011e7c77dad7d0bbb944c44891531606caeb21)
* Display the sanitizer config in the regrtest header. (#105301)
Display the sanitizers present in libregrtest.
Having this in the CI output for tests with the relevant environment
variable displayed will help make it easier to do what we need to
create an equivalent local test run.
(cherry picked from commit 852348ab65783601e0844b6647ea033668b45c11)
* gh-101634: regrtest reports decoding error as failed test (#106169)
When running the Python test suite with -jN option, if a worker stdout
cannot be decoded from the locale encoding report a failed testn so the
exitcode is non-zero.
(cherry picked from commit 2ac3eec103cf450aaaebeb932e51155d2e7fb37b)
* gh-108223: test.pythoninfo and libregrtest log Py_NOGIL (#108238)
Enable with --disable-gil --without-pydebug:
$ make pythoninfo|grep NOGIL
sysconfig[Py_NOGIL]: 1
$ ./python -m test
...
== Python build: nogil debug
...
(cherry picked from commit 5afe0c17ca14df430736e549542a4b85e7e7c7ac)
* gh-90791: test.pythoninfo logs ASAN_OPTIONS env var (#108289)
* Cleanup libregrtest code logging ASAN_OPTIONS.
* Fix a typo on "ASAN_OPTIONS" vs "MSAN_OPTIONS".
(cherry picked from commit 3a1ac87f8f89d3206b46a0df4908afae629d669d)
* gh-108388: regrtest splits test_asyncio package (#108393)
Currently, test_asyncio package is only splitted into sub-tests when
using command "./python -m test". With this change, it's also
splitted when passing it on the command line:
"./python -m test test_asyncio".
Remove the concept of "STDTESTS". Python is now mature enough to not
have to bother with that anymore. Removing STDTESTS simplify the
code.
(cherry picked from commit 174e9da0836844a2138cc8915dd305cb2cd7a583)
* regrtest computes statistics (#108793)
test_netrc, test_pep646_syntax and test_xml_etree now return results
in the test_main() function.
Changes:
* Rewrite TestResult as a dataclass with a new State class.
* Add test.support.TestStats class and Regrtest.stats_dict attribute.
* libregrtest.runtest functions now modify a TestResult instance
in-place.
* libregrtest summary lists the number of run tests and skipped
tests, and denied resources.
* Add TestResult.has_meaningful_duration() method.
* Compute TestResult duration in the upper function.
* Use time.perf_counter() instead of time.monotonic().
* Regrtest: rename 'resource_denieds' attribute to 'resource_denied'.
* Rename CHILD_ERROR to MULTIPROCESSING_ERROR.
* Use match/case syntadx to have different code depending on the
test state.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit d4e534cbb35678c82b3a1276826af55d7bfc23b6)
* gh-108822: Add Changelog entry for regrtest statistics (#108821)
---------
Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Zachary Ware <zach@python.org>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Joshua Herman <zitterbewegung@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-09-03 19:21:53 +02:00
|
|
|
fail_env_changed=True,
|
|
|
|
|
stats=1)
|
2019-04-26 09:28:53 +02:00
|
|
|
|
2019-08-14 14:18:51 +02:00
|
|
|
def test_multiprocessing_timeout(self):
|
|
|
|
|
code = textwrap.dedent(r"""
|
|
|
|
|
import time
|
|
|
|
|
import unittest
|
|
|
|
|
try:
|
|
|
|
|
import faulthandler
|
|
|
|
|
except ImportError:
|
|
|
|
|
faulthandler = None
|
|
|
|
|
|
|
|
|
|
class Tests(unittest.TestCase):
|
|
|
|
|
# test hangs and so should be stopped by the timeout
|
|
|
|
|
def test_sleep(self):
|
|
|
|
|
# we want to test regrtest multiprocessing timeout,
|
|
|
|
|
# not faulthandler timeout
|
|
|
|
|
if faulthandler is not None:
|
|
|
|
|
faulthandler.cancel_dump_traceback_later()
|
|
|
|
|
|
|
|
|
|
time.sleep(60 * 5)
|
|
|
|
|
""")
|
|
|
|
|
testname = self.create_test(code=code)
|
|
|
|
|
|
[3.11] gh-108822: Backport libregrtest changes from the main branch (#108820)
* Revert "[3.11] gh-101634: regrtest reports decoding error as failed test (#106169) (#106175)"
This reverts commit d5418e97fc524420011a370ba3c2c3cf6a89a74f.
* Revert "[3.11] bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (GH-30895) (GH-103342)"
This reverts commit ecb09a849689764193e0115d27e220f82b5f6d9f.
* Revert "gh-95027: Fix regrtest stdout encoding on Windows (GH-98492)"
This reverts commit b2aa28eec56d07b9c6777b02b7247cf21839de9f.
* Revert "[3.11] gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253) (GH-94408)"
This reverts commit 0122ab235b5acb52dd99fd05d8802a00f438b828.
* Revert "Run Tools/scripts/reindent.py (GH-94225)"
This reverts commit f0f3a424afb00a15ce8c0140dd218f5b33929be6.
* Revert "gh-94052: Don't re-run failed tests with --python option (GH-94054)"
This reverts commit 1347607db12012f6458ffcba48d8ad797083812e.
* Revert "[3.11] gh-84461: Fix Emscripten umask and permission issues (GH-94002) (GH-94006)"
This reverts commit 10731849184a3101ed18683b0128d689f1671c3f.
* gh-93353: regrtest checks for leaked temporary files (#93776)
When running tests with -jN, create a temporary directory per process
and mark a test as "environment changed" if a test leaks a temporary
file or directory.
(cherry picked from commit e566ce5496f1bad81c431aaee65e36d5e44771c5)
* gh-93353: Fix regrtest for -jN with N >= 2 (GH-93813)
(cherry picked from commit 36934a16e86f34d69ba2d41630fb5b4d06d59cff)
* gh-93353: regrtest supports checking tmp files with -j2 (#93909)
regrtest now also implements checking for leaked temporary files and
directories when using -jN for N >= 2. Use tempfile.mkdtemp() to
create the temporary directory. Skip this check on WASI.
(cherry picked from commit 4f85cec9e2077681b3dacc3108e646d509b720bf)
* gh-84461: Fix Emscripten umask and permission issues (GH-94002)
- Emscripten's default umask is too strict, see
https://github.com/emscripten-core/emscripten/issues/17269
- getuid/getgid and geteuid/getegid are stubs that always return 0
(root). Disable effective uid/gid syscalls and fix tests that use
chmod() current user.
- Cannot drop X bit from directory.
(cherry picked from commit 2702e408fd0e0dd7aec396b4cf8c7ce9caae81d8)
* gh-94052: Don't re-run failed tests with --python option (#94054)
(cherry picked from commit 0ff7b996f5d836e63cdaf652c7aa734285261096)
* Run Tools/scripts/reindent.py (#94225)
Reindent files which were not properly formatted (PEP 8: 4 spaces).
Remove also some trailing spaces.
(cherry picked from commit e87ada48a9e5d9d03f9759138869216df0d7383a)
* gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253)
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 199ba233248ab279f445e0809c2077976f0711bc)
* gh-96465: Clear fractions hash lru_cache under refleak testing (GH-96689)
Automerge-Triggered-By: GH:zware
(cherry picked from commit 9c8f3794337457b1d905a9fa0f38c2978fe32abd)
* gh-95027: Fix regrtest stdout encoding on Windows (#98492)
On Windows, when the Python test suite is run with the -jN option,
the ANSI code page is now used as the encoding for the stdout
temporary file, rather than using UTF-8 which can lead to decoding
errors.
(cherry picked from commit ec1f6f5f139868dc2c1116a7c7c878c38c668d53)
* gh-98903: Test suite fails with exit code 4 if no tests ran (#98904)
The Python test suite now fails wit exit code 4 if no tests ran. It
should help detecting typos in test names and test methods.
* Add "EXITCODE_" constants to Lib/test/libregrtest/main.py.
* Fix a typo: "NO TEST RUN" becomes "NO TESTS RAN"
(cherry picked from commit c76db37c0d23174cbffd6fa978d39693890ef020)
* gh-100086: Add build info to test.libregrtest (#100093)
The Python test runner (libregrtest) now logs Python build information like
"debug" vs "release" build, or LTO and PGO optimizations.
(cherry picked from commit 3c892022472eb975360fb3f0caa6f6fcc6fbf220)
* bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (#30895)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
(cherry picked from commit 995386071f96e4cfebfa027a71ca9134e4651d2a)
* gh-82054: allow test runner to split test_asyncio to execute in parallel by sharding. (#103927)
This runs test_asyncio sub-tests in parallel using sharding from Cinder. This suite is typically the longest-pole in runs because it is a test package with a lot of further sub-tests otherwise run serially. By breaking out the sub-tests as independent modules we can run a lot more in parallel.
After porting we can see the direct impact on a multicore system.
Without this change:
Running make test is 5 min 26 seconds
With this change:
Running make test takes 3 min 39 seconds
That'll vary based on system and parallelism. On a `-j 4` run similar to what CI and buildbot systems often do, it reduced the overall test suite completion latency by 10%.
The drawbacks are that this implementation is hacky and due to the sorting of the tests it obscures when the asyncio tests occur and involves changing CPython test infrastructure but, the wall time saved it is worth it, especially in low-core count CI runs as it pulls a long tail. The win for productivity and reserved CI resource usage is significant.
Future tests that deserve to be refactored into split up suites to benefit from are test_concurrent_futures and the way the _test_multiprocessing suite gets run for all start methods. As exposed by passing the -o flag to python -m test to get a list of the 10 longest running tests.
---------
Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google, LLC]
(cherry picked from commit 9e011e7c77dad7d0bbb944c44891531606caeb21)
* Display the sanitizer config in the regrtest header. (#105301)
Display the sanitizers present in libregrtest.
Having this in the CI output for tests with the relevant environment
variable displayed will help make it easier to do what we need to
create an equivalent local test run.
(cherry picked from commit 852348ab65783601e0844b6647ea033668b45c11)
* gh-101634: regrtest reports decoding error as failed test (#106169)
When running the Python test suite with -jN option, if a worker stdout
cannot be decoded from the locale encoding report a failed testn so the
exitcode is non-zero.
(cherry picked from commit 2ac3eec103cf450aaaebeb932e51155d2e7fb37b)
* gh-108223: test.pythoninfo and libregrtest log Py_NOGIL (#108238)
Enable with --disable-gil --without-pydebug:
$ make pythoninfo|grep NOGIL
sysconfig[Py_NOGIL]: 1
$ ./python -m test
...
== Python build: nogil debug
...
(cherry picked from commit 5afe0c17ca14df430736e549542a4b85e7e7c7ac)
* gh-90791: test.pythoninfo logs ASAN_OPTIONS env var (#108289)
* Cleanup libregrtest code logging ASAN_OPTIONS.
* Fix a typo on "ASAN_OPTIONS" vs "MSAN_OPTIONS".
(cherry picked from commit 3a1ac87f8f89d3206b46a0df4908afae629d669d)
* gh-108388: regrtest splits test_asyncio package (#108393)
Currently, test_asyncio package is only splitted into sub-tests when
using command "./python -m test". With this change, it's also
splitted when passing it on the command line:
"./python -m test test_asyncio".
Remove the concept of "STDTESTS". Python is now mature enough to not
have to bother with that anymore. Removing STDTESTS simplify the
code.
(cherry picked from commit 174e9da0836844a2138cc8915dd305cb2cd7a583)
* regrtest computes statistics (#108793)
test_netrc, test_pep646_syntax and test_xml_etree now return results
in the test_main() function.
Changes:
* Rewrite TestResult as a dataclass with a new State class.
* Add test.support.TestStats class and Regrtest.stats_dict attribute.
* libregrtest.runtest functions now modify a TestResult instance
in-place.
* libregrtest summary lists the number of run tests and skipped
tests, and denied resources.
* Add TestResult.has_meaningful_duration() method.
* Compute TestResult duration in the upper function.
* Use time.perf_counter() instead of time.monotonic().
* Regrtest: rename 'resource_denieds' attribute to 'resource_denied'.
* Rename CHILD_ERROR to MULTIPROCESSING_ERROR.
* Use match/case syntadx to have different code depending on the
test state.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit d4e534cbb35678c82b3a1276826af55d7bfc23b6)
* gh-108822: Add Changelog entry for regrtest statistics (#108821)
---------
Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Zachary Ware <zach@python.org>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Joshua Herman <zitterbewegung@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-09-03 19:21:53 +02:00
|
|
|
output = self.run_tests("-j2", "--timeout=1.0", testname,
|
|
|
|
|
exitcode=EXITCODE_BAD_TEST)
|
2019-08-14 14:18:51 +02:00
|
|
|
self.check_executed_tests(output, [testname],
|
[3.11] gh-108822: Backport libregrtest changes from the main branch (#108820)
* Revert "[3.11] gh-101634: regrtest reports decoding error as failed test (#106169) (#106175)"
This reverts commit d5418e97fc524420011a370ba3c2c3cf6a89a74f.
* Revert "[3.11] bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (GH-30895) (GH-103342)"
This reverts commit ecb09a849689764193e0115d27e220f82b5f6d9f.
* Revert "gh-95027: Fix regrtest stdout encoding on Windows (GH-98492)"
This reverts commit b2aa28eec56d07b9c6777b02b7247cf21839de9f.
* Revert "[3.11] gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253) (GH-94408)"
This reverts commit 0122ab235b5acb52dd99fd05d8802a00f438b828.
* Revert "Run Tools/scripts/reindent.py (GH-94225)"
This reverts commit f0f3a424afb00a15ce8c0140dd218f5b33929be6.
* Revert "gh-94052: Don't re-run failed tests with --python option (GH-94054)"
This reverts commit 1347607db12012f6458ffcba48d8ad797083812e.
* Revert "[3.11] gh-84461: Fix Emscripten umask and permission issues (GH-94002) (GH-94006)"
This reverts commit 10731849184a3101ed18683b0128d689f1671c3f.
* gh-93353: regrtest checks for leaked temporary files (#93776)
When running tests with -jN, create a temporary directory per process
and mark a test as "environment changed" if a test leaks a temporary
file or directory.
(cherry picked from commit e566ce5496f1bad81c431aaee65e36d5e44771c5)
* gh-93353: Fix regrtest for -jN with N >= 2 (GH-93813)
(cherry picked from commit 36934a16e86f34d69ba2d41630fb5b4d06d59cff)
* gh-93353: regrtest supports checking tmp files with -j2 (#93909)
regrtest now also implements checking for leaked temporary files and
directories when using -jN for N >= 2. Use tempfile.mkdtemp() to
create the temporary directory. Skip this check on WASI.
(cherry picked from commit 4f85cec9e2077681b3dacc3108e646d509b720bf)
* gh-84461: Fix Emscripten umask and permission issues (GH-94002)
- Emscripten's default umask is too strict, see
https://github.com/emscripten-core/emscripten/issues/17269
- getuid/getgid and geteuid/getegid are stubs that always return 0
(root). Disable effective uid/gid syscalls and fix tests that use
chmod() current user.
- Cannot drop X bit from directory.
(cherry picked from commit 2702e408fd0e0dd7aec396b4cf8c7ce9caae81d8)
* gh-94052: Don't re-run failed tests with --python option (#94054)
(cherry picked from commit 0ff7b996f5d836e63cdaf652c7aa734285261096)
* Run Tools/scripts/reindent.py (#94225)
Reindent files which were not properly formatted (PEP 8: 4 spaces).
Remove also some trailing spaces.
(cherry picked from commit e87ada48a9e5d9d03f9759138869216df0d7383a)
* gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253)
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 199ba233248ab279f445e0809c2077976f0711bc)
* gh-96465: Clear fractions hash lru_cache under refleak testing (GH-96689)
Automerge-Triggered-By: GH:zware
(cherry picked from commit 9c8f3794337457b1d905a9fa0f38c2978fe32abd)
* gh-95027: Fix regrtest stdout encoding on Windows (#98492)
On Windows, when the Python test suite is run with the -jN option,
the ANSI code page is now used as the encoding for the stdout
temporary file, rather than using UTF-8 which can lead to decoding
errors.
(cherry picked from commit ec1f6f5f139868dc2c1116a7c7c878c38c668d53)
* gh-98903: Test suite fails with exit code 4 if no tests ran (#98904)
The Python test suite now fails wit exit code 4 if no tests ran. It
should help detecting typos in test names and test methods.
* Add "EXITCODE_" constants to Lib/test/libregrtest/main.py.
* Fix a typo: "NO TEST RUN" becomes "NO TESTS RAN"
(cherry picked from commit c76db37c0d23174cbffd6fa978d39693890ef020)
* gh-100086: Add build info to test.libregrtest (#100093)
The Python test runner (libregrtest) now logs Python build information like
"debug" vs "release" build, or LTO and PGO optimizations.
(cherry picked from commit 3c892022472eb975360fb3f0caa6f6fcc6fbf220)
* bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (#30895)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
(cherry picked from commit 995386071f96e4cfebfa027a71ca9134e4651d2a)
* gh-82054: allow test runner to split test_asyncio to execute in parallel by sharding. (#103927)
This runs test_asyncio sub-tests in parallel using sharding from Cinder. This suite is typically the longest-pole in runs because it is a test package with a lot of further sub-tests otherwise run serially. By breaking out the sub-tests as independent modules we can run a lot more in parallel.
After porting we can see the direct impact on a multicore system.
Without this change:
Running make test is 5 min 26 seconds
With this change:
Running make test takes 3 min 39 seconds
That'll vary based on system and parallelism. On a `-j 4` run similar to what CI and buildbot systems often do, it reduced the overall test suite completion latency by 10%.
The drawbacks are that this implementation is hacky and due to the sorting of the tests it obscures when the asyncio tests occur and involves changing CPython test infrastructure but, the wall time saved it is worth it, especially in low-core count CI runs as it pulls a long tail. The win for productivity and reserved CI resource usage is significant.
Future tests that deserve to be refactored into split up suites to benefit from are test_concurrent_futures and the way the _test_multiprocessing suite gets run for all start methods. As exposed by passing the -o flag to python -m test to get a list of the 10 longest running tests.
---------
Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google, LLC]
(cherry picked from commit 9e011e7c77dad7d0bbb944c44891531606caeb21)
* Display the sanitizer config in the regrtest header. (#105301)
Display the sanitizers present in libregrtest.
Having this in the CI output for tests with the relevant environment
variable displayed will help make it easier to do what we need to
create an equivalent local test run.
(cherry picked from commit 852348ab65783601e0844b6647ea033668b45c11)
* gh-101634: regrtest reports decoding error as failed test (#106169)
When running the Python test suite with -jN option, if a worker stdout
cannot be decoded from the locale encoding report a failed testn so the
exitcode is non-zero.
(cherry picked from commit 2ac3eec103cf450aaaebeb932e51155d2e7fb37b)
* gh-108223: test.pythoninfo and libregrtest log Py_NOGIL (#108238)
Enable with --disable-gil --without-pydebug:
$ make pythoninfo|grep NOGIL
sysconfig[Py_NOGIL]: 1
$ ./python -m test
...
== Python build: nogil debug
...
(cherry picked from commit 5afe0c17ca14df430736e549542a4b85e7e7c7ac)
* gh-90791: test.pythoninfo logs ASAN_OPTIONS env var (#108289)
* Cleanup libregrtest code logging ASAN_OPTIONS.
* Fix a typo on "ASAN_OPTIONS" vs "MSAN_OPTIONS".
(cherry picked from commit 3a1ac87f8f89d3206b46a0df4908afae629d669d)
* gh-108388: regrtest splits test_asyncio package (#108393)
Currently, test_asyncio package is only splitted into sub-tests when
using command "./python -m test". With this change, it's also
splitted when passing it on the command line:
"./python -m test test_asyncio".
Remove the concept of "STDTESTS". Python is now mature enough to not
have to bother with that anymore. Removing STDTESTS simplify the
code.
(cherry picked from commit 174e9da0836844a2138cc8915dd305cb2cd7a583)
* regrtest computes statistics (#108793)
test_netrc, test_pep646_syntax and test_xml_etree now return results
in the test_main() function.
Changes:
* Rewrite TestResult as a dataclass with a new State class.
* Add test.support.TestStats class and Regrtest.stats_dict attribute.
* libregrtest.runtest functions now modify a TestResult instance
in-place.
* libregrtest summary lists the number of run tests and skipped
tests, and denied resources.
* Add TestResult.has_meaningful_duration() method.
* Compute TestResult duration in the upper function.
* Use time.perf_counter() instead of time.monotonic().
* Regrtest: rename 'resource_denieds' attribute to 'resource_denied'.
* Rename CHILD_ERROR to MULTIPROCESSING_ERROR.
* Use match/case syntadx to have different code depending on the
test state.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit d4e534cbb35678c82b3a1276826af55d7bfc23b6)
* gh-108822: Add Changelog entry for regrtest statistics (#108821)
---------
Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Zachary Ware <zach@python.org>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Joshua Herman <zitterbewegung@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-09-03 19:21:53 +02:00
|
|
|
failed=testname, stats=0)
|
2019-08-14 14:18:51 +02:00
|
|
|
self.assertRegex(output,
|
|
|
|
|
re.compile('%s timed out' % testname, re.MULTILINE))
|
|
|
|
|
|
2019-06-13 01:09:04 +02:00
|
|
|
def test_unraisable_exc(self):
|
2020-08-03 22:51:23 +02:00
|
|
|
# --fail-env-changed must catch unraisable exception.
|
2021-04-16 14:33:10 +02:00
|
|
|
# The exception must be displayed even if sys.stderr is redirected.
|
2019-06-13 01:09:04 +02:00
|
|
|
code = textwrap.dedent(r"""
|
|
|
|
|
import unittest
|
|
|
|
|
import weakref
|
2020-08-03 22:51:23 +02:00
|
|
|
from test.support import captured_stderr
|
2019-06-13 01:09:04 +02:00
|
|
|
|
|
|
|
|
class MyObject:
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
def weakref_callback(obj):
|
|
|
|
|
raise Exception("weakref callback bug")
|
|
|
|
|
|
|
|
|
|
class Tests(unittest.TestCase):
|
|
|
|
|
def test_unraisable_exc(self):
|
|
|
|
|
obj = MyObject()
|
|
|
|
|
ref = weakref.ref(obj, weakref_callback)
|
2020-08-03 22:51:23 +02:00
|
|
|
with captured_stderr() as stderr:
|
|
|
|
|
# call weakref_callback() which logs
|
|
|
|
|
# an unraisable exception
|
|
|
|
|
obj = None
|
|
|
|
|
self.assertEqual(stderr.getvalue(), '')
|
2019-06-13 01:09:04 +02:00
|
|
|
""")
|
|
|
|
|
testname = self.create_test(code=code)
|
|
|
|
|
|
[3.11] gh-108822: Backport libregrtest changes from the main branch (#108820)
* Revert "[3.11] gh-101634: regrtest reports decoding error as failed test (#106169) (#106175)"
This reverts commit d5418e97fc524420011a370ba3c2c3cf6a89a74f.
* Revert "[3.11] bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (GH-30895) (GH-103342)"
This reverts commit ecb09a849689764193e0115d27e220f82b5f6d9f.
* Revert "gh-95027: Fix regrtest stdout encoding on Windows (GH-98492)"
This reverts commit b2aa28eec56d07b9c6777b02b7247cf21839de9f.
* Revert "[3.11] gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253) (GH-94408)"
This reverts commit 0122ab235b5acb52dd99fd05d8802a00f438b828.
* Revert "Run Tools/scripts/reindent.py (GH-94225)"
This reverts commit f0f3a424afb00a15ce8c0140dd218f5b33929be6.
* Revert "gh-94052: Don't re-run failed tests with --python option (GH-94054)"
This reverts commit 1347607db12012f6458ffcba48d8ad797083812e.
* Revert "[3.11] gh-84461: Fix Emscripten umask and permission issues (GH-94002) (GH-94006)"
This reverts commit 10731849184a3101ed18683b0128d689f1671c3f.
* gh-93353: regrtest checks for leaked temporary files (#93776)
When running tests with -jN, create a temporary directory per process
and mark a test as "environment changed" if a test leaks a temporary
file or directory.
(cherry picked from commit e566ce5496f1bad81c431aaee65e36d5e44771c5)
* gh-93353: Fix regrtest for -jN with N >= 2 (GH-93813)
(cherry picked from commit 36934a16e86f34d69ba2d41630fb5b4d06d59cff)
* gh-93353: regrtest supports checking tmp files with -j2 (#93909)
regrtest now also implements checking for leaked temporary files and
directories when using -jN for N >= 2. Use tempfile.mkdtemp() to
create the temporary directory. Skip this check on WASI.
(cherry picked from commit 4f85cec9e2077681b3dacc3108e646d509b720bf)
* gh-84461: Fix Emscripten umask and permission issues (GH-94002)
- Emscripten's default umask is too strict, see
https://github.com/emscripten-core/emscripten/issues/17269
- getuid/getgid and geteuid/getegid are stubs that always return 0
(root). Disable effective uid/gid syscalls and fix tests that use
chmod() current user.
- Cannot drop X bit from directory.
(cherry picked from commit 2702e408fd0e0dd7aec396b4cf8c7ce9caae81d8)
* gh-94052: Don't re-run failed tests with --python option (#94054)
(cherry picked from commit 0ff7b996f5d836e63cdaf652c7aa734285261096)
* Run Tools/scripts/reindent.py (#94225)
Reindent files which were not properly formatted (PEP 8: 4 spaces).
Remove also some trailing spaces.
(cherry picked from commit e87ada48a9e5d9d03f9759138869216df0d7383a)
* gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253)
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 199ba233248ab279f445e0809c2077976f0711bc)
* gh-96465: Clear fractions hash lru_cache under refleak testing (GH-96689)
Automerge-Triggered-By: GH:zware
(cherry picked from commit 9c8f3794337457b1d905a9fa0f38c2978fe32abd)
* gh-95027: Fix regrtest stdout encoding on Windows (#98492)
On Windows, when the Python test suite is run with the -jN option,
the ANSI code page is now used as the encoding for the stdout
temporary file, rather than using UTF-8 which can lead to decoding
errors.
(cherry picked from commit ec1f6f5f139868dc2c1116a7c7c878c38c668d53)
* gh-98903: Test suite fails with exit code 4 if no tests ran (#98904)
The Python test suite now fails wit exit code 4 if no tests ran. It
should help detecting typos in test names and test methods.
* Add "EXITCODE_" constants to Lib/test/libregrtest/main.py.
* Fix a typo: "NO TEST RUN" becomes "NO TESTS RAN"
(cherry picked from commit c76db37c0d23174cbffd6fa978d39693890ef020)
* gh-100086: Add build info to test.libregrtest (#100093)
The Python test runner (libregrtest) now logs Python build information like
"debug" vs "release" build, or LTO and PGO optimizations.
(cherry picked from commit 3c892022472eb975360fb3f0caa6f6fcc6fbf220)
* bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (#30895)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
(cherry picked from commit 995386071f96e4cfebfa027a71ca9134e4651d2a)
* gh-82054: allow test runner to split test_asyncio to execute in parallel by sharding. (#103927)
This runs test_asyncio sub-tests in parallel using sharding from Cinder. This suite is typically the longest-pole in runs because it is a test package with a lot of further sub-tests otherwise run serially. By breaking out the sub-tests as independent modules we can run a lot more in parallel.
After porting we can see the direct impact on a multicore system.
Without this change:
Running make test is 5 min 26 seconds
With this change:
Running make test takes 3 min 39 seconds
That'll vary based on system and parallelism. On a `-j 4` run similar to what CI and buildbot systems often do, it reduced the overall test suite completion latency by 10%.
The drawbacks are that this implementation is hacky and due to the sorting of the tests it obscures when the asyncio tests occur and involves changing CPython test infrastructure but, the wall time saved it is worth it, especially in low-core count CI runs as it pulls a long tail. The win for productivity and reserved CI resource usage is significant.
Future tests that deserve to be refactored into split up suites to benefit from are test_concurrent_futures and the way the _test_multiprocessing suite gets run for all start methods. As exposed by passing the -o flag to python -m test to get a list of the 10 longest running tests.
---------
Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google, LLC]
(cherry picked from commit 9e011e7c77dad7d0bbb944c44891531606caeb21)
* Display the sanitizer config in the regrtest header. (#105301)
Display the sanitizers present in libregrtest.
Having this in the CI output for tests with the relevant environment
variable displayed will help make it easier to do what we need to
create an equivalent local test run.
(cherry picked from commit 852348ab65783601e0844b6647ea033668b45c11)
* gh-101634: regrtest reports decoding error as failed test (#106169)
When running the Python test suite with -jN option, if a worker stdout
cannot be decoded from the locale encoding report a failed testn so the
exitcode is non-zero.
(cherry picked from commit 2ac3eec103cf450aaaebeb932e51155d2e7fb37b)
* gh-108223: test.pythoninfo and libregrtest log Py_NOGIL (#108238)
Enable with --disable-gil --without-pydebug:
$ make pythoninfo|grep NOGIL
sysconfig[Py_NOGIL]: 1
$ ./python -m test
...
== Python build: nogil debug
...
(cherry picked from commit 5afe0c17ca14df430736e549542a4b85e7e7c7ac)
* gh-90791: test.pythoninfo logs ASAN_OPTIONS env var (#108289)
* Cleanup libregrtest code logging ASAN_OPTIONS.
* Fix a typo on "ASAN_OPTIONS" vs "MSAN_OPTIONS".
(cherry picked from commit 3a1ac87f8f89d3206b46a0df4908afae629d669d)
* gh-108388: regrtest splits test_asyncio package (#108393)
Currently, test_asyncio package is only splitted into sub-tests when
using command "./python -m test". With this change, it's also
splitted when passing it on the command line:
"./python -m test test_asyncio".
Remove the concept of "STDTESTS". Python is now mature enough to not
have to bother with that anymore. Removing STDTESTS simplify the
code.
(cherry picked from commit 174e9da0836844a2138cc8915dd305cb2cd7a583)
* regrtest computes statistics (#108793)
test_netrc, test_pep646_syntax and test_xml_etree now return results
in the test_main() function.
Changes:
* Rewrite TestResult as a dataclass with a new State class.
* Add test.support.TestStats class and Regrtest.stats_dict attribute.
* libregrtest.runtest functions now modify a TestResult instance
in-place.
* libregrtest summary lists the number of run tests and skipped
tests, and denied resources.
* Add TestResult.has_meaningful_duration() method.
* Compute TestResult duration in the upper function.
* Use time.perf_counter() instead of time.monotonic().
* Regrtest: rename 'resource_denieds' attribute to 'resource_denied'.
* Rename CHILD_ERROR to MULTIPROCESSING_ERROR.
* Use match/case syntadx to have different code depending on the
test state.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit d4e534cbb35678c82b3a1276826af55d7bfc23b6)
* gh-108822: Add Changelog entry for regrtest statistics (#108821)
---------
Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Zachary Ware <zach@python.org>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Joshua Herman <zitterbewegung@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-09-03 19:21:53 +02:00
|
|
|
output = self.run_tests("--fail-env-changed", "-v", testname,
|
|
|
|
|
exitcode=EXITCODE_ENV_CHANGED)
|
2019-06-13 01:09:04 +02:00
|
|
|
self.check_executed_tests(output, [testname],
|
|
|
|
|
env_changed=[testname],
|
[3.11] gh-108822: Backport libregrtest changes from the main branch (#108820)
* Revert "[3.11] gh-101634: regrtest reports decoding error as failed test (#106169) (#106175)"
This reverts commit d5418e97fc524420011a370ba3c2c3cf6a89a74f.
* Revert "[3.11] bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (GH-30895) (GH-103342)"
This reverts commit ecb09a849689764193e0115d27e220f82b5f6d9f.
* Revert "gh-95027: Fix regrtest stdout encoding on Windows (GH-98492)"
This reverts commit b2aa28eec56d07b9c6777b02b7247cf21839de9f.
* Revert "[3.11] gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253) (GH-94408)"
This reverts commit 0122ab235b5acb52dd99fd05d8802a00f438b828.
* Revert "Run Tools/scripts/reindent.py (GH-94225)"
This reverts commit f0f3a424afb00a15ce8c0140dd218f5b33929be6.
* Revert "gh-94052: Don't re-run failed tests with --python option (GH-94054)"
This reverts commit 1347607db12012f6458ffcba48d8ad797083812e.
* Revert "[3.11] gh-84461: Fix Emscripten umask and permission issues (GH-94002) (GH-94006)"
This reverts commit 10731849184a3101ed18683b0128d689f1671c3f.
* gh-93353: regrtest checks for leaked temporary files (#93776)
When running tests with -jN, create a temporary directory per process
and mark a test as "environment changed" if a test leaks a temporary
file or directory.
(cherry picked from commit e566ce5496f1bad81c431aaee65e36d5e44771c5)
* gh-93353: Fix regrtest for -jN with N >= 2 (GH-93813)
(cherry picked from commit 36934a16e86f34d69ba2d41630fb5b4d06d59cff)
* gh-93353: regrtest supports checking tmp files with -j2 (#93909)
regrtest now also implements checking for leaked temporary files and
directories when using -jN for N >= 2. Use tempfile.mkdtemp() to
create the temporary directory. Skip this check on WASI.
(cherry picked from commit 4f85cec9e2077681b3dacc3108e646d509b720bf)
* gh-84461: Fix Emscripten umask and permission issues (GH-94002)
- Emscripten's default umask is too strict, see
https://github.com/emscripten-core/emscripten/issues/17269
- getuid/getgid and geteuid/getegid are stubs that always return 0
(root). Disable effective uid/gid syscalls and fix tests that use
chmod() current user.
- Cannot drop X bit from directory.
(cherry picked from commit 2702e408fd0e0dd7aec396b4cf8c7ce9caae81d8)
* gh-94052: Don't re-run failed tests with --python option (#94054)
(cherry picked from commit 0ff7b996f5d836e63cdaf652c7aa734285261096)
* Run Tools/scripts/reindent.py (#94225)
Reindent files which were not properly formatted (PEP 8: 4 spaces).
Remove also some trailing spaces.
(cherry picked from commit e87ada48a9e5d9d03f9759138869216df0d7383a)
* gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253)
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 199ba233248ab279f445e0809c2077976f0711bc)
* gh-96465: Clear fractions hash lru_cache under refleak testing (GH-96689)
Automerge-Triggered-By: GH:zware
(cherry picked from commit 9c8f3794337457b1d905a9fa0f38c2978fe32abd)
* gh-95027: Fix regrtest stdout encoding on Windows (#98492)
On Windows, when the Python test suite is run with the -jN option,
the ANSI code page is now used as the encoding for the stdout
temporary file, rather than using UTF-8 which can lead to decoding
errors.
(cherry picked from commit ec1f6f5f139868dc2c1116a7c7c878c38c668d53)
* gh-98903: Test suite fails with exit code 4 if no tests ran (#98904)
The Python test suite now fails wit exit code 4 if no tests ran. It
should help detecting typos in test names and test methods.
* Add "EXITCODE_" constants to Lib/test/libregrtest/main.py.
* Fix a typo: "NO TEST RUN" becomes "NO TESTS RAN"
(cherry picked from commit c76db37c0d23174cbffd6fa978d39693890ef020)
* gh-100086: Add build info to test.libregrtest (#100093)
The Python test runner (libregrtest) now logs Python build information like
"debug" vs "release" build, or LTO and PGO optimizations.
(cherry picked from commit 3c892022472eb975360fb3f0caa6f6fcc6fbf220)
* bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (#30895)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
(cherry picked from commit 995386071f96e4cfebfa027a71ca9134e4651d2a)
* gh-82054: allow test runner to split test_asyncio to execute in parallel by sharding. (#103927)
This runs test_asyncio sub-tests in parallel using sharding from Cinder. This suite is typically the longest-pole in runs because it is a test package with a lot of further sub-tests otherwise run serially. By breaking out the sub-tests as independent modules we can run a lot more in parallel.
After porting we can see the direct impact on a multicore system.
Without this change:
Running make test is 5 min 26 seconds
With this change:
Running make test takes 3 min 39 seconds
That'll vary based on system and parallelism. On a `-j 4` run similar to what CI and buildbot systems often do, it reduced the overall test suite completion latency by 10%.
The drawbacks are that this implementation is hacky and due to the sorting of the tests it obscures when the asyncio tests occur and involves changing CPython test infrastructure but, the wall time saved it is worth it, especially in low-core count CI runs as it pulls a long tail. The win for productivity and reserved CI resource usage is significant.
Future tests that deserve to be refactored into split up suites to benefit from are test_concurrent_futures and the way the _test_multiprocessing suite gets run for all start methods. As exposed by passing the -o flag to python -m test to get a list of the 10 longest running tests.
---------
Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google, LLC]
(cherry picked from commit 9e011e7c77dad7d0bbb944c44891531606caeb21)
* Display the sanitizer config in the regrtest header. (#105301)
Display the sanitizers present in libregrtest.
Having this in the CI output for tests with the relevant environment
variable displayed will help make it easier to do what we need to
create an equivalent local test run.
(cherry picked from commit 852348ab65783601e0844b6647ea033668b45c11)
* gh-101634: regrtest reports decoding error as failed test (#106169)
When running the Python test suite with -jN option, if a worker stdout
cannot be decoded from the locale encoding report a failed testn so the
exitcode is non-zero.
(cherry picked from commit 2ac3eec103cf450aaaebeb932e51155d2e7fb37b)
* gh-108223: test.pythoninfo and libregrtest log Py_NOGIL (#108238)
Enable with --disable-gil --without-pydebug:
$ make pythoninfo|grep NOGIL
sysconfig[Py_NOGIL]: 1
$ ./python -m test
...
== Python build: nogil debug
...
(cherry picked from commit 5afe0c17ca14df430736e549542a4b85e7e7c7ac)
* gh-90791: test.pythoninfo logs ASAN_OPTIONS env var (#108289)
* Cleanup libregrtest code logging ASAN_OPTIONS.
* Fix a typo on "ASAN_OPTIONS" vs "MSAN_OPTIONS".
(cherry picked from commit 3a1ac87f8f89d3206b46a0df4908afae629d669d)
* gh-108388: regrtest splits test_asyncio package (#108393)
Currently, test_asyncio package is only splitted into sub-tests when
using command "./python -m test". With this change, it's also
splitted when passing it on the command line:
"./python -m test test_asyncio".
Remove the concept of "STDTESTS". Python is now mature enough to not
have to bother with that anymore. Removing STDTESTS simplify the
code.
(cherry picked from commit 174e9da0836844a2138cc8915dd305cb2cd7a583)
* regrtest computes statistics (#108793)
test_netrc, test_pep646_syntax and test_xml_etree now return results
in the test_main() function.
Changes:
* Rewrite TestResult as a dataclass with a new State class.
* Add test.support.TestStats class and Regrtest.stats_dict attribute.
* libregrtest.runtest functions now modify a TestResult instance
in-place.
* libregrtest summary lists the number of run tests and skipped
tests, and denied resources.
* Add TestResult.has_meaningful_duration() method.
* Compute TestResult duration in the upper function.
* Use time.perf_counter() instead of time.monotonic().
* Regrtest: rename 'resource_denieds' attribute to 'resource_denied'.
* Rename CHILD_ERROR to MULTIPROCESSING_ERROR.
* Use match/case syntadx to have different code depending on the
test state.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit d4e534cbb35678c82b3a1276826af55d7bfc23b6)
* gh-108822: Add Changelog entry for regrtest statistics (#108821)
---------
Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Zachary Ware <zach@python.org>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Joshua Herman <zitterbewegung@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-09-03 19:21:53 +02:00
|
|
|
fail_env_changed=True,
|
|
|
|
|
stats=1)
|
2019-06-13 01:09:04 +02:00
|
|
|
self.assertIn("Warning -- Unraisable exception", output)
|
2020-08-03 22:51:23 +02:00
|
|
|
self.assertIn("Exception: weakref callback bug", output)
|
2019-06-13 01:09:04 +02:00
|
|
|
|
2021-04-16 14:33:10 +02:00
|
|
|
def test_threading_excepthook(self):
|
|
|
|
|
# --fail-env-changed must catch uncaught thread exception.
|
|
|
|
|
# The exception must be displayed even if sys.stderr is redirected.
|
|
|
|
|
code = textwrap.dedent(r"""
|
|
|
|
|
import threading
|
|
|
|
|
import unittest
|
|
|
|
|
from test.support import captured_stderr
|
|
|
|
|
|
|
|
|
|
class MyObject:
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
def func_bug():
|
|
|
|
|
raise Exception("bug in thread")
|
|
|
|
|
|
|
|
|
|
class Tests(unittest.TestCase):
|
|
|
|
|
def test_threading_excepthook(self):
|
|
|
|
|
with captured_stderr() as stderr:
|
|
|
|
|
thread = threading.Thread(target=func_bug)
|
|
|
|
|
thread.start()
|
|
|
|
|
thread.join()
|
|
|
|
|
self.assertEqual(stderr.getvalue(), '')
|
|
|
|
|
""")
|
|
|
|
|
testname = self.create_test(code=code)
|
|
|
|
|
|
[3.11] gh-108822: Backport libregrtest changes from the main branch (#108820)
* Revert "[3.11] gh-101634: regrtest reports decoding error as failed test (#106169) (#106175)"
This reverts commit d5418e97fc524420011a370ba3c2c3cf6a89a74f.
* Revert "[3.11] bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (GH-30895) (GH-103342)"
This reverts commit ecb09a849689764193e0115d27e220f82b5f6d9f.
* Revert "gh-95027: Fix regrtest stdout encoding on Windows (GH-98492)"
This reverts commit b2aa28eec56d07b9c6777b02b7247cf21839de9f.
* Revert "[3.11] gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253) (GH-94408)"
This reverts commit 0122ab235b5acb52dd99fd05d8802a00f438b828.
* Revert "Run Tools/scripts/reindent.py (GH-94225)"
This reverts commit f0f3a424afb00a15ce8c0140dd218f5b33929be6.
* Revert "gh-94052: Don't re-run failed tests with --python option (GH-94054)"
This reverts commit 1347607db12012f6458ffcba48d8ad797083812e.
* Revert "[3.11] gh-84461: Fix Emscripten umask and permission issues (GH-94002) (GH-94006)"
This reverts commit 10731849184a3101ed18683b0128d689f1671c3f.
* gh-93353: regrtest checks for leaked temporary files (#93776)
When running tests with -jN, create a temporary directory per process
and mark a test as "environment changed" if a test leaks a temporary
file or directory.
(cherry picked from commit e566ce5496f1bad81c431aaee65e36d5e44771c5)
* gh-93353: Fix regrtest for -jN with N >= 2 (GH-93813)
(cherry picked from commit 36934a16e86f34d69ba2d41630fb5b4d06d59cff)
* gh-93353: regrtest supports checking tmp files with -j2 (#93909)
regrtest now also implements checking for leaked temporary files and
directories when using -jN for N >= 2. Use tempfile.mkdtemp() to
create the temporary directory. Skip this check on WASI.
(cherry picked from commit 4f85cec9e2077681b3dacc3108e646d509b720bf)
* gh-84461: Fix Emscripten umask and permission issues (GH-94002)
- Emscripten's default umask is too strict, see
https://github.com/emscripten-core/emscripten/issues/17269
- getuid/getgid and geteuid/getegid are stubs that always return 0
(root). Disable effective uid/gid syscalls and fix tests that use
chmod() current user.
- Cannot drop X bit from directory.
(cherry picked from commit 2702e408fd0e0dd7aec396b4cf8c7ce9caae81d8)
* gh-94052: Don't re-run failed tests with --python option (#94054)
(cherry picked from commit 0ff7b996f5d836e63cdaf652c7aa734285261096)
* Run Tools/scripts/reindent.py (#94225)
Reindent files which were not properly formatted (PEP 8: 4 spaces).
Remove also some trailing spaces.
(cherry picked from commit e87ada48a9e5d9d03f9759138869216df0d7383a)
* gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253)
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 199ba233248ab279f445e0809c2077976f0711bc)
* gh-96465: Clear fractions hash lru_cache under refleak testing (GH-96689)
Automerge-Triggered-By: GH:zware
(cherry picked from commit 9c8f3794337457b1d905a9fa0f38c2978fe32abd)
* gh-95027: Fix regrtest stdout encoding on Windows (#98492)
On Windows, when the Python test suite is run with the -jN option,
the ANSI code page is now used as the encoding for the stdout
temporary file, rather than using UTF-8 which can lead to decoding
errors.
(cherry picked from commit ec1f6f5f139868dc2c1116a7c7c878c38c668d53)
* gh-98903: Test suite fails with exit code 4 if no tests ran (#98904)
The Python test suite now fails wit exit code 4 if no tests ran. It
should help detecting typos in test names and test methods.
* Add "EXITCODE_" constants to Lib/test/libregrtest/main.py.
* Fix a typo: "NO TEST RUN" becomes "NO TESTS RAN"
(cherry picked from commit c76db37c0d23174cbffd6fa978d39693890ef020)
* gh-100086: Add build info to test.libregrtest (#100093)
The Python test runner (libregrtest) now logs Python build information like
"debug" vs "release" build, or LTO and PGO optimizations.
(cherry picked from commit 3c892022472eb975360fb3f0caa6f6fcc6fbf220)
* bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (#30895)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
(cherry picked from commit 995386071f96e4cfebfa027a71ca9134e4651d2a)
* gh-82054: allow test runner to split test_asyncio to execute in parallel by sharding. (#103927)
This runs test_asyncio sub-tests in parallel using sharding from Cinder. This suite is typically the longest-pole in runs because it is a test package with a lot of further sub-tests otherwise run serially. By breaking out the sub-tests as independent modules we can run a lot more in parallel.
After porting we can see the direct impact on a multicore system.
Without this change:
Running make test is 5 min 26 seconds
With this change:
Running make test takes 3 min 39 seconds
That'll vary based on system and parallelism. On a `-j 4` run similar to what CI and buildbot systems often do, it reduced the overall test suite completion latency by 10%.
The drawbacks are that this implementation is hacky and due to the sorting of the tests it obscures when the asyncio tests occur and involves changing CPython test infrastructure but, the wall time saved it is worth it, especially in low-core count CI runs as it pulls a long tail. The win for productivity and reserved CI resource usage is significant.
Future tests that deserve to be refactored into split up suites to benefit from are test_concurrent_futures and the way the _test_multiprocessing suite gets run for all start methods. As exposed by passing the -o flag to python -m test to get a list of the 10 longest running tests.
---------
Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google, LLC]
(cherry picked from commit 9e011e7c77dad7d0bbb944c44891531606caeb21)
* Display the sanitizer config in the regrtest header. (#105301)
Display the sanitizers present in libregrtest.
Having this in the CI output for tests with the relevant environment
variable displayed will help make it easier to do what we need to
create an equivalent local test run.
(cherry picked from commit 852348ab65783601e0844b6647ea033668b45c11)
* gh-101634: regrtest reports decoding error as failed test (#106169)
When running the Python test suite with -jN option, if a worker stdout
cannot be decoded from the locale encoding report a failed testn so the
exitcode is non-zero.
(cherry picked from commit 2ac3eec103cf450aaaebeb932e51155d2e7fb37b)
* gh-108223: test.pythoninfo and libregrtest log Py_NOGIL (#108238)
Enable with --disable-gil --without-pydebug:
$ make pythoninfo|grep NOGIL
sysconfig[Py_NOGIL]: 1
$ ./python -m test
...
== Python build: nogil debug
...
(cherry picked from commit 5afe0c17ca14df430736e549542a4b85e7e7c7ac)
* gh-90791: test.pythoninfo logs ASAN_OPTIONS env var (#108289)
* Cleanup libregrtest code logging ASAN_OPTIONS.
* Fix a typo on "ASAN_OPTIONS" vs "MSAN_OPTIONS".
(cherry picked from commit 3a1ac87f8f89d3206b46a0df4908afae629d669d)
* gh-108388: regrtest splits test_asyncio package (#108393)
Currently, test_asyncio package is only splitted into sub-tests when
using command "./python -m test". With this change, it's also
splitted when passing it on the command line:
"./python -m test test_asyncio".
Remove the concept of "STDTESTS". Python is now mature enough to not
have to bother with that anymore. Removing STDTESTS simplify the
code.
(cherry picked from commit 174e9da0836844a2138cc8915dd305cb2cd7a583)
* regrtest computes statistics (#108793)
test_netrc, test_pep646_syntax and test_xml_etree now return results
in the test_main() function.
Changes:
* Rewrite TestResult as a dataclass with a new State class.
* Add test.support.TestStats class and Regrtest.stats_dict attribute.
* libregrtest.runtest functions now modify a TestResult instance
in-place.
* libregrtest summary lists the number of run tests and skipped
tests, and denied resources.
* Add TestResult.has_meaningful_duration() method.
* Compute TestResult duration in the upper function.
* Use time.perf_counter() instead of time.monotonic().
* Regrtest: rename 'resource_denieds' attribute to 'resource_denied'.
* Rename CHILD_ERROR to MULTIPROCESSING_ERROR.
* Use match/case syntadx to have different code depending on the
test state.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit d4e534cbb35678c82b3a1276826af55d7bfc23b6)
* gh-108822: Add Changelog entry for regrtest statistics (#108821)
---------
Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Zachary Ware <zach@python.org>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Joshua Herman <zitterbewegung@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-09-03 19:21:53 +02:00
|
|
|
output = self.run_tests("--fail-env-changed", "-v", testname,
|
|
|
|
|
exitcode=EXITCODE_ENV_CHANGED)
|
2021-04-16 14:33:10 +02:00
|
|
|
self.check_executed_tests(output, [testname],
|
|
|
|
|
env_changed=[testname],
|
[3.11] gh-108822: Backport libregrtest changes from the main branch (#108820)
* Revert "[3.11] gh-101634: regrtest reports decoding error as failed test (#106169) (#106175)"
This reverts commit d5418e97fc524420011a370ba3c2c3cf6a89a74f.
* Revert "[3.11] bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (GH-30895) (GH-103342)"
This reverts commit ecb09a849689764193e0115d27e220f82b5f6d9f.
* Revert "gh-95027: Fix regrtest stdout encoding on Windows (GH-98492)"
This reverts commit b2aa28eec56d07b9c6777b02b7247cf21839de9f.
* Revert "[3.11] gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253) (GH-94408)"
This reverts commit 0122ab235b5acb52dd99fd05d8802a00f438b828.
* Revert "Run Tools/scripts/reindent.py (GH-94225)"
This reverts commit f0f3a424afb00a15ce8c0140dd218f5b33929be6.
* Revert "gh-94052: Don't re-run failed tests with --python option (GH-94054)"
This reverts commit 1347607db12012f6458ffcba48d8ad797083812e.
* Revert "[3.11] gh-84461: Fix Emscripten umask and permission issues (GH-94002) (GH-94006)"
This reverts commit 10731849184a3101ed18683b0128d689f1671c3f.
* gh-93353: regrtest checks for leaked temporary files (#93776)
When running tests with -jN, create a temporary directory per process
and mark a test as "environment changed" if a test leaks a temporary
file or directory.
(cherry picked from commit e566ce5496f1bad81c431aaee65e36d5e44771c5)
* gh-93353: Fix regrtest for -jN with N >= 2 (GH-93813)
(cherry picked from commit 36934a16e86f34d69ba2d41630fb5b4d06d59cff)
* gh-93353: regrtest supports checking tmp files with -j2 (#93909)
regrtest now also implements checking for leaked temporary files and
directories when using -jN for N >= 2. Use tempfile.mkdtemp() to
create the temporary directory. Skip this check on WASI.
(cherry picked from commit 4f85cec9e2077681b3dacc3108e646d509b720bf)
* gh-84461: Fix Emscripten umask and permission issues (GH-94002)
- Emscripten's default umask is too strict, see
https://github.com/emscripten-core/emscripten/issues/17269
- getuid/getgid and geteuid/getegid are stubs that always return 0
(root). Disable effective uid/gid syscalls and fix tests that use
chmod() current user.
- Cannot drop X bit from directory.
(cherry picked from commit 2702e408fd0e0dd7aec396b4cf8c7ce9caae81d8)
* gh-94052: Don't re-run failed tests with --python option (#94054)
(cherry picked from commit 0ff7b996f5d836e63cdaf652c7aa734285261096)
* Run Tools/scripts/reindent.py (#94225)
Reindent files which were not properly formatted (PEP 8: 4 spaces).
Remove also some trailing spaces.
(cherry picked from commit e87ada48a9e5d9d03f9759138869216df0d7383a)
* gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253)
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 199ba233248ab279f445e0809c2077976f0711bc)
* gh-96465: Clear fractions hash lru_cache under refleak testing (GH-96689)
Automerge-Triggered-By: GH:zware
(cherry picked from commit 9c8f3794337457b1d905a9fa0f38c2978fe32abd)
* gh-95027: Fix regrtest stdout encoding on Windows (#98492)
On Windows, when the Python test suite is run with the -jN option,
the ANSI code page is now used as the encoding for the stdout
temporary file, rather than using UTF-8 which can lead to decoding
errors.
(cherry picked from commit ec1f6f5f139868dc2c1116a7c7c878c38c668d53)
* gh-98903: Test suite fails with exit code 4 if no tests ran (#98904)
The Python test suite now fails wit exit code 4 if no tests ran. It
should help detecting typos in test names and test methods.
* Add "EXITCODE_" constants to Lib/test/libregrtest/main.py.
* Fix a typo: "NO TEST RUN" becomes "NO TESTS RAN"
(cherry picked from commit c76db37c0d23174cbffd6fa978d39693890ef020)
* gh-100086: Add build info to test.libregrtest (#100093)
The Python test runner (libregrtest) now logs Python build information like
"debug" vs "release" build, or LTO and PGO optimizations.
(cherry picked from commit 3c892022472eb975360fb3f0caa6f6fcc6fbf220)
* bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (#30895)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
(cherry picked from commit 995386071f96e4cfebfa027a71ca9134e4651d2a)
* gh-82054: allow test runner to split test_asyncio to execute in parallel by sharding. (#103927)
This runs test_asyncio sub-tests in parallel using sharding from Cinder. This suite is typically the longest-pole in runs because it is a test package with a lot of further sub-tests otherwise run serially. By breaking out the sub-tests as independent modules we can run a lot more in parallel.
After porting we can see the direct impact on a multicore system.
Without this change:
Running make test is 5 min 26 seconds
With this change:
Running make test takes 3 min 39 seconds
That'll vary based on system and parallelism. On a `-j 4` run similar to what CI and buildbot systems often do, it reduced the overall test suite completion latency by 10%.
The drawbacks are that this implementation is hacky and due to the sorting of the tests it obscures when the asyncio tests occur and involves changing CPython test infrastructure but, the wall time saved it is worth it, especially in low-core count CI runs as it pulls a long tail. The win for productivity and reserved CI resource usage is significant.
Future tests that deserve to be refactored into split up suites to benefit from are test_concurrent_futures and the way the _test_multiprocessing suite gets run for all start methods. As exposed by passing the -o flag to python -m test to get a list of the 10 longest running tests.
---------
Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google, LLC]
(cherry picked from commit 9e011e7c77dad7d0bbb944c44891531606caeb21)
* Display the sanitizer config in the regrtest header. (#105301)
Display the sanitizers present in libregrtest.
Having this in the CI output for tests with the relevant environment
variable displayed will help make it easier to do what we need to
create an equivalent local test run.
(cherry picked from commit 852348ab65783601e0844b6647ea033668b45c11)
* gh-101634: regrtest reports decoding error as failed test (#106169)
When running the Python test suite with -jN option, if a worker stdout
cannot be decoded from the locale encoding report a failed testn so the
exitcode is non-zero.
(cherry picked from commit 2ac3eec103cf450aaaebeb932e51155d2e7fb37b)
* gh-108223: test.pythoninfo and libregrtest log Py_NOGIL (#108238)
Enable with --disable-gil --without-pydebug:
$ make pythoninfo|grep NOGIL
sysconfig[Py_NOGIL]: 1
$ ./python -m test
...
== Python build: nogil debug
...
(cherry picked from commit 5afe0c17ca14df430736e549542a4b85e7e7c7ac)
* gh-90791: test.pythoninfo logs ASAN_OPTIONS env var (#108289)
* Cleanup libregrtest code logging ASAN_OPTIONS.
* Fix a typo on "ASAN_OPTIONS" vs "MSAN_OPTIONS".
(cherry picked from commit 3a1ac87f8f89d3206b46a0df4908afae629d669d)
* gh-108388: regrtest splits test_asyncio package (#108393)
Currently, test_asyncio package is only splitted into sub-tests when
using command "./python -m test". With this change, it's also
splitted when passing it on the command line:
"./python -m test test_asyncio".
Remove the concept of "STDTESTS". Python is now mature enough to not
have to bother with that anymore. Removing STDTESTS simplify the
code.
(cherry picked from commit 174e9da0836844a2138cc8915dd305cb2cd7a583)
* regrtest computes statistics (#108793)
test_netrc, test_pep646_syntax and test_xml_etree now return results
in the test_main() function.
Changes:
* Rewrite TestResult as a dataclass with a new State class.
* Add test.support.TestStats class and Regrtest.stats_dict attribute.
* libregrtest.runtest functions now modify a TestResult instance
in-place.
* libregrtest summary lists the number of run tests and skipped
tests, and denied resources.
* Add TestResult.has_meaningful_duration() method.
* Compute TestResult duration in the upper function.
* Use time.perf_counter() instead of time.monotonic().
* Regrtest: rename 'resource_denieds' attribute to 'resource_denied'.
* Rename CHILD_ERROR to MULTIPROCESSING_ERROR.
* Use match/case syntadx to have different code depending on the
test state.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit d4e534cbb35678c82b3a1276826af55d7bfc23b6)
* gh-108822: Add Changelog entry for regrtest statistics (#108821)
---------
Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Zachary Ware <zach@python.org>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Joshua Herman <zitterbewegung@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-09-03 19:21:53 +02:00
|
|
|
fail_env_changed=True,
|
|
|
|
|
stats=1)
|
2021-04-16 14:33:10 +02:00
|
|
|
self.assertIn("Warning -- Uncaught thread exception", output)
|
|
|
|
|
self.assertIn("Exception: bug in thread", output)
|
|
|
|
|
|
2021-10-13 17:35:21 +02:00
|
|
|
def test_print_warning(self):
|
|
|
|
|
# bpo-45410: The order of messages must be preserved when -W and
|
|
|
|
|
# support.print_warning() are used.
|
|
|
|
|
code = textwrap.dedent(r"""
|
|
|
|
|
import sys
|
|
|
|
|
import unittest
|
|
|
|
|
from test import support
|
|
|
|
|
|
|
|
|
|
class MyObject:
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
def func_bug():
|
|
|
|
|
raise Exception("bug in thread")
|
|
|
|
|
|
|
|
|
|
class Tests(unittest.TestCase):
|
|
|
|
|
def test_print_warning(self):
|
|
|
|
|
print("msg1: stdout")
|
|
|
|
|
support.print_warning("msg2: print_warning")
|
|
|
|
|
# Fail with ENV CHANGED to see print_warning() log
|
|
|
|
|
support.environment_altered = True
|
|
|
|
|
""")
|
|
|
|
|
testname = self.create_test(code=code)
|
|
|
|
|
|
|
|
|
|
# Expect an output like:
|
|
|
|
|
#
|
|
|
|
|
# test_threading_excepthook (test.test_x.Tests) ... msg1: stdout
|
|
|
|
|
# Warning -- msg2: print_warning
|
|
|
|
|
# ok
|
|
|
|
|
regex = (r"test_print_warning.*msg1: stdout\n"
|
|
|
|
|
r"Warning -- msg2: print_warning\n"
|
|
|
|
|
r"ok\n")
|
|
|
|
|
for option in ("-v", "-W"):
|
|
|
|
|
with self.subTest(option=option):
|
|
|
|
|
cmd = ["--fail-env-changed", option, testname]
|
[3.11] gh-108822: Backport libregrtest changes from the main branch (#108820)
* Revert "[3.11] gh-101634: regrtest reports decoding error as failed test (#106169) (#106175)"
This reverts commit d5418e97fc524420011a370ba3c2c3cf6a89a74f.
* Revert "[3.11] bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (GH-30895) (GH-103342)"
This reverts commit ecb09a849689764193e0115d27e220f82b5f6d9f.
* Revert "gh-95027: Fix regrtest stdout encoding on Windows (GH-98492)"
This reverts commit b2aa28eec56d07b9c6777b02b7247cf21839de9f.
* Revert "[3.11] gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253) (GH-94408)"
This reverts commit 0122ab235b5acb52dd99fd05d8802a00f438b828.
* Revert "Run Tools/scripts/reindent.py (GH-94225)"
This reverts commit f0f3a424afb00a15ce8c0140dd218f5b33929be6.
* Revert "gh-94052: Don't re-run failed tests with --python option (GH-94054)"
This reverts commit 1347607db12012f6458ffcba48d8ad797083812e.
* Revert "[3.11] gh-84461: Fix Emscripten umask and permission issues (GH-94002) (GH-94006)"
This reverts commit 10731849184a3101ed18683b0128d689f1671c3f.
* gh-93353: regrtest checks for leaked temporary files (#93776)
When running tests with -jN, create a temporary directory per process
and mark a test as "environment changed" if a test leaks a temporary
file or directory.
(cherry picked from commit e566ce5496f1bad81c431aaee65e36d5e44771c5)
* gh-93353: Fix regrtest for -jN with N >= 2 (GH-93813)
(cherry picked from commit 36934a16e86f34d69ba2d41630fb5b4d06d59cff)
* gh-93353: regrtest supports checking tmp files with -j2 (#93909)
regrtest now also implements checking for leaked temporary files and
directories when using -jN for N >= 2. Use tempfile.mkdtemp() to
create the temporary directory. Skip this check on WASI.
(cherry picked from commit 4f85cec9e2077681b3dacc3108e646d509b720bf)
* gh-84461: Fix Emscripten umask and permission issues (GH-94002)
- Emscripten's default umask is too strict, see
https://github.com/emscripten-core/emscripten/issues/17269
- getuid/getgid and geteuid/getegid are stubs that always return 0
(root). Disable effective uid/gid syscalls and fix tests that use
chmod() current user.
- Cannot drop X bit from directory.
(cherry picked from commit 2702e408fd0e0dd7aec396b4cf8c7ce9caae81d8)
* gh-94052: Don't re-run failed tests with --python option (#94054)
(cherry picked from commit 0ff7b996f5d836e63cdaf652c7aa734285261096)
* Run Tools/scripts/reindent.py (#94225)
Reindent files which were not properly formatted (PEP 8: 4 spaces).
Remove also some trailing spaces.
(cherry picked from commit e87ada48a9e5d9d03f9759138869216df0d7383a)
* gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253)
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 199ba233248ab279f445e0809c2077976f0711bc)
* gh-96465: Clear fractions hash lru_cache under refleak testing (GH-96689)
Automerge-Triggered-By: GH:zware
(cherry picked from commit 9c8f3794337457b1d905a9fa0f38c2978fe32abd)
* gh-95027: Fix regrtest stdout encoding on Windows (#98492)
On Windows, when the Python test suite is run with the -jN option,
the ANSI code page is now used as the encoding for the stdout
temporary file, rather than using UTF-8 which can lead to decoding
errors.
(cherry picked from commit ec1f6f5f139868dc2c1116a7c7c878c38c668d53)
* gh-98903: Test suite fails with exit code 4 if no tests ran (#98904)
The Python test suite now fails wit exit code 4 if no tests ran. It
should help detecting typos in test names and test methods.
* Add "EXITCODE_" constants to Lib/test/libregrtest/main.py.
* Fix a typo: "NO TEST RUN" becomes "NO TESTS RAN"
(cherry picked from commit c76db37c0d23174cbffd6fa978d39693890ef020)
* gh-100086: Add build info to test.libregrtest (#100093)
The Python test runner (libregrtest) now logs Python build information like
"debug" vs "release" build, or LTO and PGO optimizations.
(cherry picked from commit 3c892022472eb975360fb3f0caa6f6fcc6fbf220)
* bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (#30895)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
(cherry picked from commit 995386071f96e4cfebfa027a71ca9134e4651d2a)
* gh-82054: allow test runner to split test_asyncio to execute in parallel by sharding. (#103927)
This runs test_asyncio sub-tests in parallel using sharding from Cinder. This suite is typically the longest-pole in runs because it is a test package with a lot of further sub-tests otherwise run serially. By breaking out the sub-tests as independent modules we can run a lot more in parallel.
After porting we can see the direct impact on a multicore system.
Without this change:
Running make test is 5 min 26 seconds
With this change:
Running make test takes 3 min 39 seconds
That'll vary based on system and parallelism. On a `-j 4` run similar to what CI and buildbot systems often do, it reduced the overall test suite completion latency by 10%.
The drawbacks are that this implementation is hacky and due to the sorting of the tests it obscures when the asyncio tests occur and involves changing CPython test infrastructure but, the wall time saved it is worth it, especially in low-core count CI runs as it pulls a long tail. The win for productivity and reserved CI resource usage is significant.
Future tests that deserve to be refactored into split up suites to benefit from are test_concurrent_futures and the way the _test_multiprocessing suite gets run for all start methods. As exposed by passing the -o flag to python -m test to get a list of the 10 longest running tests.
---------
Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google, LLC]
(cherry picked from commit 9e011e7c77dad7d0bbb944c44891531606caeb21)
* Display the sanitizer config in the regrtest header. (#105301)
Display the sanitizers present in libregrtest.
Having this in the CI output for tests with the relevant environment
variable displayed will help make it easier to do what we need to
create an equivalent local test run.
(cherry picked from commit 852348ab65783601e0844b6647ea033668b45c11)
* gh-101634: regrtest reports decoding error as failed test (#106169)
When running the Python test suite with -jN option, if a worker stdout
cannot be decoded from the locale encoding report a failed testn so the
exitcode is non-zero.
(cherry picked from commit 2ac3eec103cf450aaaebeb932e51155d2e7fb37b)
* gh-108223: test.pythoninfo and libregrtest log Py_NOGIL (#108238)
Enable with --disable-gil --without-pydebug:
$ make pythoninfo|grep NOGIL
sysconfig[Py_NOGIL]: 1
$ ./python -m test
...
== Python build: nogil debug
...
(cherry picked from commit 5afe0c17ca14df430736e549542a4b85e7e7c7ac)
* gh-90791: test.pythoninfo logs ASAN_OPTIONS env var (#108289)
* Cleanup libregrtest code logging ASAN_OPTIONS.
* Fix a typo on "ASAN_OPTIONS" vs "MSAN_OPTIONS".
(cherry picked from commit 3a1ac87f8f89d3206b46a0df4908afae629d669d)
* gh-108388: regrtest splits test_asyncio package (#108393)
Currently, test_asyncio package is only splitted into sub-tests when
using command "./python -m test". With this change, it's also
splitted when passing it on the command line:
"./python -m test test_asyncio".
Remove the concept of "STDTESTS". Python is now mature enough to not
have to bother with that anymore. Removing STDTESTS simplify the
code.
(cherry picked from commit 174e9da0836844a2138cc8915dd305cb2cd7a583)
* regrtest computes statistics (#108793)
test_netrc, test_pep646_syntax and test_xml_etree now return results
in the test_main() function.
Changes:
* Rewrite TestResult as a dataclass with a new State class.
* Add test.support.TestStats class and Regrtest.stats_dict attribute.
* libregrtest.runtest functions now modify a TestResult instance
in-place.
* libregrtest summary lists the number of run tests and skipped
tests, and denied resources.
* Add TestResult.has_meaningful_duration() method.
* Compute TestResult duration in the upper function.
* Use time.perf_counter() instead of time.monotonic().
* Regrtest: rename 'resource_denieds' attribute to 'resource_denied'.
* Rename CHILD_ERROR to MULTIPROCESSING_ERROR.
* Use match/case syntadx to have different code depending on the
test state.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit d4e534cbb35678c82b3a1276826af55d7bfc23b6)
* gh-108822: Add Changelog entry for regrtest statistics (#108821)
---------
Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Zachary Ware <zach@python.org>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Joshua Herman <zitterbewegung@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-09-03 19:21:53 +02:00
|
|
|
output = self.run_tests(*cmd, exitcode=EXITCODE_ENV_CHANGED)
|
2021-10-13 17:35:21 +02:00
|
|
|
self.check_executed_tests(output, [testname],
|
|
|
|
|
env_changed=[testname],
|
[3.11] gh-108822: Backport libregrtest changes from the main branch (#108820)
* Revert "[3.11] gh-101634: regrtest reports decoding error as failed test (#106169) (#106175)"
This reverts commit d5418e97fc524420011a370ba3c2c3cf6a89a74f.
* Revert "[3.11] bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (GH-30895) (GH-103342)"
This reverts commit ecb09a849689764193e0115d27e220f82b5f6d9f.
* Revert "gh-95027: Fix regrtest stdout encoding on Windows (GH-98492)"
This reverts commit b2aa28eec56d07b9c6777b02b7247cf21839de9f.
* Revert "[3.11] gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253) (GH-94408)"
This reverts commit 0122ab235b5acb52dd99fd05d8802a00f438b828.
* Revert "Run Tools/scripts/reindent.py (GH-94225)"
This reverts commit f0f3a424afb00a15ce8c0140dd218f5b33929be6.
* Revert "gh-94052: Don't re-run failed tests with --python option (GH-94054)"
This reverts commit 1347607db12012f6458ffcba48d8ad797083812e.
* Revert "[3.11] gh-84461: Fix Emscripten umask and permission issues (GH-94002) (GH-94006)"
This reverts commit 10731849184a3101ed18683b0128d689f1671c3f.
* gh-93353: regrtest checks for leaked temporary files (#93776)
When running tests with -jN, create a temporary directory per process
and mark a test as "environment changed" if a test leaks a temporary
file or directory.
(cherry picked from commit e566ce5496f1bad81c431aaee65e36d5e44771c5)
* gh-93353: Fix regrtest for -jN with N >= 2 (GH-93813)
(cherry picked from commit 36934a16e86f34d69ba2d41630fb5b4d06d59cff)
* gh-93353: regrtest supports checking tmp files with -j2 (#93909)
regrtest now also implements checking for leaked temporary files and
directories when using -jN for N >= 2. Use tempfile.mkdtemp() to
create the temporary directory. Skip this check on WASI.
(cherry picked from commit 4f85cec9e2077681b3dacc3108e646d509b720bf)
* gh-84461: Fix Emscripten umask and permission issues (GH-94002)
- Emscripten's default umask is too strict, see
https://github.com/emscripten-core/emscripten/issues/17269
- getuid/getgid and geteuid/getegid are stubs that always return 0
(root). Disable effective uid/gid syscalls and fix tests that use
chmod() current user.
- Cannot drop X bit from directory.
(cherry picked from commit 2702e408fd0e0dd7aec396b4cf8c7ce9caae81d8)
* gh-94052: Don't re-run failed tests with --python option (#94054)
(cherry picked from commit 0ff7b996f5d836e63cdaf652c7aa734285261096)
* Run Tools/scripts/reindent.py (#94225)
Reindent files which were not properly formatted (PEP 8: 4 spaces).
Remove also some trailing spaces.
(cherry picked from commit e87ada48a9e5d9d03f9759138869216df0d7383a)
* gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253)
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 199ba233248ab279f445e0809c2077976f0711bc)
* gh-96465: Clear fractions hash lru_cache under refleak testing (GH-96689)
Automerge-Triggered-By: GH:zware
(cherry picked from commit 9c8f3794337457b1d905a9fa0f38c2978fe32abd)
* gh-95027: Fix regrtest stdout encoding on Windows (#98492)
On Windows, when the Python test suite is run with the -jN option,
the ANSI code page is now used as the encoding for the stdout
temporary file, rather than using UTF-8 which can lead to decoding
errors.
(cherry picked from commit ec1f6f5f139868dc2c1116a7c7c878c38c668d53)
* gh-98903: Test suite fails with exit code 4 if no tests ran (#98904)
The Python test suite now fails wit exit code 4 if no tests ran. It
should help detecting typos in test names and test methods.
* Add "EXITCODE_" constants to Lib/test/libregrtest/main.py.
* Fix a typo: "NO TEST RUN" becomes "NO TESTS RAN"
(cherry picked from commit c76db37c0d23174cbffd6fa978d39693890ef020)
* gh-100086: Add build info to test.libregrtest (#100093)
The Python test runner (libregrtest) now logs Python build information like
"debug" vs "release" build, or LTO and PGO optimizations.
(cherry picked from commit 3c892022472eb975360fb3f0caa6f6fcc6fbf220)
* bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (#30895)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
(cherry picked from commit 995386071f96e4cfebfa027a71ca9134e4651d2a)
* gh-82054: allow test runner to split test_asyncio to execute in parallel by sharding. (#103927)
This runs test_asyncio sub-tests in parallel using sharding from Cinder. This suite is typically the longest-pole in runs because it is a test package with a lot of further sub-tests otherwise run serially. By breaking out the sub-tests as independent modules we can run a lot more in parallel.
After porting we can see the direct impact on a multicore system.
Without this change:
Running make test is 5 min 26 seconds
With this change:
Running make test takes 3 min 39 seconds
That'll vary based on system and parallelism. On a `-j 4` run similar to what CI and buildbot systems often do, it reduced the overall test suite completion latency by 10%.
The drawbacks are that this implementation is hacky and due to the sorting of the tests it obscures when the asyncio tests occur and involves changing CPython test infrastructure but, the wall time saved it is worth it, especially in low-core count CI runs as it pulls a long tail. The win for productivity and reserved CI resource usage is significant.
Future tests that deserve to be refactored into split up suites to benefit from are test_concurrent_futures and the way the _test_multiprocessing suite gets run for all start methods. As exposed by passing the -o flag to python -m test to get a list of the 10 longest running tests.
---------
Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google, LLC]
(cherry picked from commit 9e011e7c77dad7d0bbb944c44891531606caeb21)
* Display the sanitizer config in the regrtest header. (#105301)
Display the sanitizers present in libregrtest.
Having this in the CI output for tests with the relevant environment
variable displayed will help make it easier to do what we need to
create an equivalent local test run.
(cherry picked from commit 852348ab65783601e0844b6647ea033668b45c11)
* gh-101634: regrtest reports decoding error as failed test (#106169)
When running the Python test suite with -jN option, if a worker stdout
cannot be decoded from the locale encoding report a failed testn so the
exitcode is non-zero.
(cherry picked from commit 2ac3eec103cf450aaaebeb932e51155d2e7fb37b)
* gh-108223: test.pythoninfo and libregrtest log Py_NOGIL (#108238)
Enable with --disable-gil --without-pydebug:
$ make pythoninfo|grep NOGIL
sysconfig[Py_NOGIL]: 1
$ ./python -m test
...
== Python build: nogil debug
...
(cherry picked from commit 5afe0c17ca14df430736e549542a4b85e7e7c7ac)
* gh-90791: test.pythoninfo logs ASAN_OPTIONS env var (#108289)
* Cleanup libregrtest code logging ASAN_OPTIONS.
* Fix a typo on "ASAN_OPTIONS" vs "MSAN_OPTIONS".
(cherry picked from commit 3a1ac87f8f89d3206b46a0df4908afae629d669d)
* gh-108388: regrtest splits test_asyncio package (#108393)
Currently, test_asyncio package is only splitted into sub-tests when
using command "./python -m test". With this change, it's also
splitted when passing it on the command line:
"./python -m test test_asyncio".
Remove the concept of "STDTESTS". Python is now mature enough to not
have to bother with that anymore. Removing STDTESTS simplify the
code.
(cherry picked from commit 174e9da0836844a2138cc8915dd305cb2cd7a583)
* regrtest computes statistics (#108793)
test_netrc, test_pep646_syntax and test_xml_etree now return results
in the test_main() function.
Changes:
* Rewrite TestResult as a dataclass with a new State class.
* Add test.support.TestStats class and Regrtest.stats_dict attribute.
* libregrtest.runtest functions now modify a TestResult instance
in-place.
* libregrtest summary lists the number of run tests and skipped
tests, and denied resources.
* Add TestResult.has_meaningful_duration() method.
* Compute TestResult duration in the upper function.
* Use time.perf_counter() instead of time.monotonic().
* Regrtest: rename 'resource_denieds' attribute to 'resource_denied'.
* Rename CHILD_ERROR to MULTIPROCESSING_ERROR.
* Use match/case syntadx to have different code depending on the
test state.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit d4e534cbb35678c82b3a1276826af55d7bfc23b6)
* gh-108822: Add Changelog entry for regrtest statistics (#108821)
---------
Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Zachary Ware <zach@python.org>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Joshua Herman <zitterbewegung@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-09-03 19:21:53 +02:00
|
|
|
fail_env_changed=True,
|
|
|
|
|
stats=1)
|
2021-10-13 17:35:21 +02:00
|
|
|
self.assertRegex(output, regex)
|
|
|
|
|
|
2021-07-16 15:24:02 +02:00
|
|
|
def test_unicode_guard_env(self):
|
|
|
|
|
guard = os.environ.get(setup.UNICODE_GUARD_ENV)
|
|
|
|
|
self.assertIsNotNone(guard, f"{setup.UNICODE_GUARD_ENV} not set")
|
2022-04-25 17:35:14 +03:00
|
|
|
if guard.isascii():
|
2021-07-16 15:24:02 +02:00
|
|
|
# Skip to signify that the env var value was changed by the user;
|
|
|
|
|
# possibly to something ASCII to work around Unicode issues.
|
|
|
|
|
self.skipTest("Modified guard")
|
|
|
|
|
|
2019-06-24 12:03:00 +02:00
|
|
|
def test_cleanup(self):
|
|
|
|
|
dirname = os.path.join(self.tmptestdir, "test_python_123")
|
|
|
|
|
os.mkdir(dirname)
|
|
|
|
|
filename = os.path.join(self.tmptestdir, "test_python_456")
|
|
|
|
|
open(filename, "wb").close()
|
|
|
|
|
names = [dirname, filename]
|
|
|
|
|
|
|
|
|
|
cmdargs = ['-m', 'test',
|
|
|
|
|
'--tempdir=%s' % self.tmptestdir,
|
|
|
|
|
'--cleanup']
|
|
|
|
|
self.run_python(cmdargs)
|
|
|
|
|
|
|
|
|
|
for name in names:
|
|
|
|
|
self.assertFalse(os.path.exists(name), name)
|
|
|
|
|
|
[3.11] gh-108822: Backport libregrtest changes from the main branch (#108820)
* Revert "[3.11] gh-101634: regrtest reports decoding error as failed test (#106169) (#106175)"
This reverts commit d5418e97fc524420011a370ba3c2c3cf6a89a74f.
* Revert "[3.11] bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (GH-30895) (GH-103342)"
This reverts commit ecb09a849689764193e0115d27e220f82b5f6d9f.
* Revert "gh-95027: Fix regrtest stdout encoding on Windows (GH-98492)"
This reverts commit b2aa28eec56d07b9c6777b02b7247cf21839de9f.
* Revert "[3.11] gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253) (GH-94408)"
This reverts commit 0122ab235b5acb52dd99fd05d8802a00f438b828.
* Revert "Run Tools/scripts/reindent.py (GH-94225)"
This reverts commit f0f3a424afb00a15ce8c0140dd218f5b33929be6.
* Revert "gh-94052: Don't re-run failed tests with --python option (GH-94054)"
This reverts commit 1347607db12012f6458ffcba48d8ad797083812e.
* Revert "[3.11] gh-84461: Fix Emscripten umask and permission issues (GH-94002) (GH-94006)"
This reverts commit 10731849184a3101ed18683b0128d689f1671c3f.
* gh-93353: regrtest checks for leaked temporary files (#93776)
When running tests with -jN, create a temporary directory per process
and mark a test as "environment changed" if a test leaks a temporary
file or directory.
(cherry picked from commit e566ce5496f1bad81c431aaee65e36d5e44771c5)
* gh-93353: Fix regrtest for -jN with N >= 2 (GH-93813)
(cherry picked from commit 36934a16e86f34d69ba2d41630fb5b4d06d59cff)
* gh-93353: regrtest supports checking tmp files with -j2 (#93909)
regrtest now also implements checking for leaked temporary files and
directories when using -jN for N >= 2. Use tempfile.mkdtemp() to
create the temporary directory. Skip this check on WASI.
(cherry picked from commit 4f85cec9e2077681b3dacc3108e646d509b720bf)
* gh-84461: Fix Emscripten umask and permission issues (GH-94002)
- Emscripten's default umask is too strict, see
https://github.com/emscripten-core/emscripten/issues/17269
- getuid/getgid and geteuid/getegid are stubs that always return 0
(root). Disable effective uid/gid syscalls and fix tests that use
chmod() current user.
- Cannot drop X bit from directory.
(cherry picked from commit 2702e408fd0e0dd7aec396b4cf8c7ce9caae81d8)
* gh-94052: Don't re-run failed tests with --python option (#94054)
(cherry picked from commit 0ff7b996f5d836e63cdaf652c7aa734285261096)
* Run Tools/scripts/reindent.py (#94225)
Reindent files which were not properly formatted (PEP 8: 4 spaces).
Remove also some trailing spaces.
(cherry picked from commit e87ada48a9e5d9d03f9759138869216df0d7383a)
* gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253)
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 199ba233248ab279f445e0809c2077976f0711bc)
* gh-96465: Clear fractions hash lru_cache under refleak testing (GH-96689)
Automerge-Triggered-By: GH:zware
(cherry picked from commit 9c8f3794337457b1d905a9fa0f38c2978fe32abd)
* gh-95027: Fix regrtest stdout encoding on Windows (#98492)
On Windows, when the Python test suite is run with the -jN option,
the ANSI code page is now used as the encoding for the stdout
temporary file, rather than using UTF-8 which can lead to decoding
errors.
(cherry picked from commit ec1f6f5f139868dc2c1116a7c7c878c38c668d53)
* gh-98903: Test suite fails with exit code 4 if no tests ran (#98904)
The Python test suite now fails wit exit code 4 if no tests ran. It
should help detecting typos in test names and test methods.
* Add "EXITCODE_" constants to Lib/test/libregrtest/main.py.
* Fix a typo: "NO TEST RUN" becomes "NO TESTS RAN"
(cherry picked from commit c76db37c0d23174cbffd6fa978d39693890ef020)
* gh-100086: Add build info to test.libregrtest (#100093)
The Python test runner (libregrtest) now logs Python build information like
"debug" vs "release" build, or LTO and PGO optimizations.
(cherry picked from commit 3c892022472eb975360fb3f0caa6f6fcc6fbf220)
* bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (#30895)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
(cherry picked from commit 995386071f96e4cfebfa027a71ca9134e4651d2a)
* gh-82054: allow test runner to split test_asyncio to execute in parallel by sharding. (#103927)
This runs test_asyncio sub-tests in parallel using sharding from Cinder. This suite is typically the longest-pole in runs because it is a test package with a lot of further sub-tests otherwise run serially. By breaking out the sub-tests as independent modules we can run a lot more in parallel.
After porting we can see the direct impact on a multicore system.
Without this change:
Running make test is 5 min 26 seconds
With this change:
Running make test takes 3 min 39 seconds
That'll vary based on system and parallelism. On a `-j 4` run similar to what CI and buildbot systems often do, it reduced the overall test suite completion latency by 10%.
The drawbacks are that this implementation is hacky and due to the sorting of the tests it obscures when the asyncio tests occur and involves changing CPython test infrastructure but, the wall time saved it is worth it, especially in low-core count CI runs as it pulls a long tail. The win for productivity and reserved CI resource usage is significant.
Future tests that deserve to be refactored into split up suites to benefit from are test_concurrent_futures and the way the _test_multiprocessing suite gets run for all start methods. As exposed by passing the -o flag to python -m test to get a list of the 10 longest running tests.
---------
Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google, LLC]
(cherry picked from commit 9e011e7c77dad7d0bbb944c44891531606caeb21)
* Display the sanitizer config in the regrtest header. (#105301)
Display the sanitizers present in libregrtest.
Having this in the CI output for tests with the relevant environment
variable displayed will help make it easier to do what we need to
create an equivalent local test run.
(cherry picked from commit 852348ab65783601e0844b6647ea033668b45c11)
* gh-101634: regrtest reports decoding error as failed test (#106169)
When running the Python test suite with -jN option, if a worker stdout
cannot be decoded from the locale encoding report a failed testn so the
exitcode is non-zero.
(cherry picked from commit 2ac3eec103cf450aaaebeb932e51155d2e7fb37b)
* gh-108223: test.pythoninfo and libregrtest log Py_NOGIL (#108238)
Enable with --disable-gil --without-pydebug:
$ make pythoninfo|grep NOGIL
sysconfig[Py_NOGIL]: 1
$ ./python -m test
...
== Python build: nogil debug
...
(cherry picked from commit 5afe0c17ca14df430736e549542a4b85e7e7c7ac)
* gh-90791: test.pythoninfo logs ASAN_OPTIONS env var (#108289)
* Cleanup libregrtest code logging ASAN_OPTIONS.
* Fix a typo on "ASAN_OPTIONS" vs "MSAN_OPTIONS".
(cherry picked from commit 3a1ac87f8f89d3206b46a0df4908afae629d669d)
* gh-108388: regrtest splits test_asyncio package (#108393)
Currently, test_asyncio package is only splitted into sub-tests when
using command "./python -m test". With this change, it's also
splitted when passing it on the command line:
"./python -m test test_asyncio".
Remove the concept of "STDTESTS". Python is now mature enough to not
have to bother with that anymore. Removing STDTESTS simplify the
code.
(cherry picked from commit 174e9da0836844a2138cc8915dd305cb2cd7a583)
* regrtest computes statistics (#108793)
test_netrc, test_pep646_syntax and test_xml_etree now return results
in the test_main() function.
Changes:
* Rewrite TestResult as a dataclass with a new State class.
* Add test.support.TestStats class and Regrtest.stats_dict attribute.
* libregrtest.runtest functions now modify a TestResult instance
in-place.
* libregrtest summary lists the number of run tests and skipped
tests, and denied resources.
* Add TestResult.has_meaningful_duration() method.
* Compute TestResult duration in the upper function.
* Use time.perf_counter() instead of time.monotonic().
* Regrtest: rename 'resource_denieds' attribute to 'resource_denied'.
* Rename CHILD_ERROR to MULTIPROCESSING_ERROR.
* Use match/case syntadx to have different code depending on the
test state.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit d4e534cbb35678c82b3a1276826af55d7bfc23b6)
* gh-108822: Add Changelog entry for regrtest statistics (#108821)
---------
Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Zachary Ware <zach@python.org>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Joshua Herman <zitterbewegung@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-09-03 19:21:53 +02:00
|
|
|
@unittest.skipIf(support.is_wasi,
|
|
|
|
|
'checking temp files is not implemented on WASI')
|
|
|
|
|
def test_leak_tmp_file(self):
|
|
|
|
|
code = textwrap.dedent(r"""
|
|
|
|
|
import os.path
|
|
|
|
|
import tempfile
|
|
|
|
|
import unittest
|
|
|
|
|
|
|
|
|
|
class FileTests(unittest.TestCase):
|
|
|
|
|
def test_leak_tmp_file(self):
|
|
|
|
|
filename = os.path.join(tempfile.gettempdir(), 'mytmpfile')
|
|
|
|
|
with open(filename, "wb") as fp:
|
|
|
|
|
fp.write(b'content')
|
|
|
|
|
""")
|
|
|
|
|
testnames = [self.create_test(code=code) for _ in range(3)]
|
|
|
|
|
|
|
|
|
|
output = self.run_tests("--fail-env-changed", "-v", "-j2", *testnames,
|
|
|
|
|
exitcode=EXITCODE_ENV_CHANGED)
|
|
|
|
|
self.check_executed_tests(output, testnames,
|
|
|
|
|
env_changed=testnames,
|
|
|
|
|
fail_env_changed=True,
|
|
|
|
|
randomize=True,
|
|
|
|
|
stats=len(testnames))
|
|
|
|
|
for testname in testnames:
|
|
|
|
|
self.assertIn(f"Warning -- {testname} leaked temporary "
|
|
|
|
|
f"files (1): mytmpfile",
|
|
|
|
|
output)
|
|
|
|
|
|
2023-06-28 04:58:34 +02:00
|
|
|
def test_mp_decode_error(self):
|
|
|
|
|
# gh-101634: If a worker stdout cannot be decoded, report a failed test
|
|
|
|
|
# and a non-zero exit code.
|
|
|
|
|
if sys.platform == 'win32':
|
|
|
|
|
encoding = locale.getencoding()
|
|
|
|
|
else:
|
|
|
|
|
encoding = sys.stdout.encoding
|
|
|
|
|
if encoding is None:
|
|
|
|
|
encoding = sys.__stdout__.encoding
|
|
|
|
|
if encoding is None:
|
|
|
|
|
self.skipTest(f"cannot get regrtest worker encoding")
|
|
|
|
|
|
|
|
|
|
nonascii = b"byte:\xa0\xa9\xff\n"
|
|
|
|
|
try:
|
|
|
|
|
nonascii.decode(encoding)
|
|
|
|
|
except UnicodeDecodeError:
|
|
|
|
|
pass
|
|
|
|
|
else:
|
|
|
|
|
self.skipTest(f"{encoding} can decode non-ASCII bytes {nonascii!a}")
|
|
|
|
|
|
|
|
|
|
code = textwrap.dedent(fr"""
|
|
|
|
|
import sys
|
|
|
|
|
# bytes which cannot be decoded from UTF-8
|
|
|
|
|
nonascii = {nonascii!a}
|
|
|
|
|
sys.stdout.buffer.write(nonascii)
|
|
|
|
|
sys.stdout.buffer.flush()
|
|
|
|
|
""")
|
|
|
|
|
testname = self.create_test(code=code)
|
|
|
|
|
|
|
|
|
|
output = self.run_tests("--fail-env-changed", "-v", "-j1", testname,
|
|
|
|
|
exitcode=EXITCODE_BAD_TEST)
|
|
|
|
|
self.check_executed_tests(output, [testname],
|
|
|
|
|
failed=[testname],
|
[3.11] gh-108822: Backport libregrtest changes from the main branch (#108820)
* Revert "[3.11] gh-101634: regrtest reports decoding error as failed test (#106169) (#106175)"
This reverts commit d5418e97fc524420011a370ba3c2c3cf6a89a74f.
* Revert "[3.11] bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (GH-30895) (GH-103342)"
This reverts commit ecb09a849689764193e0115d27e220f82b5f6d9f.
* Revert "gh-95027: Fix regrtest stdout encoding on Windows (GH-98492)"
This reverts commit b2aa28eec56d07b9c6777b02b7247cf21839de9f.
* Revert "[3.11] gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253) (GH-94408)"
This reverts commit 0122ab235b5acb52dd99fd05d8802a00f438b828.
* Revert "Run Tools/scripts/reindent.py (GH-94225)"
This reverts commit f0f3a424afb00a15ce8c0140dd218f5b33929be6.
* Revert "gh-94052: Don't re-run failed tests with --python option (GH-94054)"
This reverts commit 1347607db12012f6458ffcba48d8ad797083812e.
* Revert "[3.11] gh-84461: Fix Emscripten umask and permission issues (GH-94002) (GH-94006)"
This reverts commit 10731849184a3101ed18683b0128d689f1671c3f.
* gh-93353: regrtest checks for leaked temporary files (#93776)
When running tests with -jN, create a temporary directory per process
and mark a test as "environment changed" if a test leaks a temporary
file or directory.
(cherry picked from commit e566ce5496f1bad81c431aaee65e36d5e44771c5)
* gh-93353: Fix regrtest for -jN with N >= 2 (GH-93813)
(cherry picked from commit 36934a16e86f34d69ba2d41630fb5b4d06d59cff)
* gh-93353: regrtest supports checking tmp files with -j2 (#93909)
regrtest now also implements checking for leaked temporary files and
directories when using -jN for N >= 2. Use tempfile.mkdtemp() to
create the temporary directory. Skip this check on WASI.
(cherry picked from commit 4f85cec9e2077681b3dacc3108e646d509b720bf)
* gh-84461: Fix Emscripten umask and permission issues (GH-94002)
- Emscripten's default umask is too strict, see
https://github.com/emscripten-core/emscripten/issues/17269
- getuid/getgid and geteuid/getegid are stubs that always return 0
(root). Disable effective uid/gid syscalls and fix tests that use
chmod() current user.
- Cannot drop X bit from directory.
(cherry picked from commit 2702e408fd0e0dd7aec396b4cf8c7ce9caae81d8)
* gh-94052: Don't re-run failed tests with --python option (#94054)
(cherry picked from commit 0ff7b996f5d836e63cdaf652c7aa734285261096)
* Run Tools/scripts/reindent.py (#94225)
Reindent files which were not properly formatted (PEP 8: 4 spaces).
Remove also some trailing spaces.
(cherry picked from commit e87ada48a9e5d9d03f9759138869216df0d7383a)
* gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253)
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 199ba233248ab279f445e0809c2077976f0711bc)
* gh-96465: Clear fractions hash lru_cache under refleak testing (GH-96689)
Automerge-Triggered-By: GH:zware
(cherry picked from commit 9c8f3794337457b1d905a9fa0f38c2978fe32abd)
* gh-95027: Fix regrtest stdout encoding on Windows (#98492)
On Windows, when the Python test suite is run with the -jN option,
the ANSI code page is now used as the encoding for the stdout
temporary file, rather than using UTF-8 which can lead to decoding
errors.
(cherry picked from commit ec1f6f5f139868dc2c1116a7c7c878c38c668d53)
* gh-98903: Test suite fails with exit code 4 if no tests ran (#98904)
The Python test suite now fails wit exit code 4 if no tests ran. It
should help detecting typos in test names and test methods.
* Add "EXITCODE_" constants to Lib/test/libregrtest/main.py.
* Fix a typo: "NO TEST RUN" becomes "NO TESTS RAN"
(cherry picked from commit c76db37c0d23174cbffd6fa978d39693890ef020)
* gh-100086: Add build info to test.libregrtest (#100093)
The Python test runner (libregrtest) now logs Python build information like
"debug" vs "release" build, or LTO and PGO optimizations.
(cherry picked from commit 3c892022472eb975360fb3f0caa6f6fcc6fbf220)
* bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (#30895)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
(cherry picked from commit 995386071f96e4cfebfa027a71ca9134e4651d2a)
* gh-82054: allow test runner to split test_asyncio to execute in parallel by sharding. (#103927)
This runs test_asyncio sub-tests in parallel using sharding from Cinder. This suite is typically the longest-pole in runs because it is a test package with a lot of further sub-tests otherwise run serially. By breaking out the sub-tests as independent modules we can run a lot more in parallel.
After porting we can see the direct impact on a multicore system.
Without this change:
Running make test is 5 min 26 seconds
With this change:
Running make test takes 3 min 39 seconds
That'll vary based on system and parallelism. On a `-j 4` run similar to what CI and buildbot systems often do, it reduced the overall test suite completion latency by 10%.
The drawbacks are that this implementation is hacky and due to the sorting of the tests it obscures when the asyncio tests occur and involves changing CPython test infrastructure but, the wall time saved it is worth it, especially in low-core count CI runs as it pulls a long tail. The win for productivity and reserved CI resource usage is significant.
Future tests that deserve to be refactored into split up suites to benefit from are test_concurrent_futures and the way the _test_multiprocessing suite gets run for all start methods. As exposed by passing the -o flag to python -m test to get a list of the 10 longest running tests.
---------
Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google, LLC]
(cherry picked from commit 9e011e7c77dad7d0bbb944c44891531606caeb21)
* Display the sanitizer config in the regrtest header. (#105301)
Display the sanitizers present in libregrtest.
Having this in the CI output for tests with the relevant environment
variable displayed will help make it easier to do what we need to
create an equivalent local test run.
(cherry picked from commit 852348ab65783601e0844b6647ea033668b45c11)
* gh-101634: regrtest reports decoding error as failed test (#106169)
When running the Python test suite with -jN option, if a worker stdout
cannot be decoded from the locale encoding report a failed testn so the
exitcode is non-zero.
(cherry picked from commit 2ac3eec103cf450aaaebeb932e51155d2e7fb37b)
* gh-108223: test.pythoninfo and libregrtest log Py_NOGIL (#108238)
Enable with --disable-gil --without-pydebug:
$ make pythoninfo|grep NOGIL
sysconfig[Py_NOGIL]: 1
$ ./python -m test
...
== Python build: nogil debug
...
(cherry picked from commit 5afe0c17ca14df430736e549542a4b85e7e7c7ac)
* gh-90791: test.pythoninfo logs ASAN_OPTIONS env var (#108289)
* Cleanup libregrtest code logging ASAN_OPTIONS.
* Fix a typo on "ASAN_OPTIONS" vs "MSAN_OPTIONS".
(cherry picked from commit 3a1ac87f8f89d3206b46a0df4908afae629d669d)
* gh-108388: regrtest splits test_asyncio package (#108393)
Currently, test_asyncio package is only splitted into sub-tests when
using command "./python -m test". With this change, it's also
splitted when passing it on the command line:
"./python -m test test_asyncio".
Remove the concept of "STDTESTS". Python is now mature enough to not
have to bother with that anymore. Removing STDTESTS simplify the
code.
(cherry picked from commit 174e9da0836844a2138cc8915dd305cb2cd7a583)
* regrtest computes statistics (#108793)
test_netrc, test_pep646_syntax and test_xml_etree now return results
in the test_main() function.
Changes:
* Rewrite TestResult as a dataclass with a new State class.
* Add test.support.TestStats class and Regrtest.stats_dict attribute.
* libregrtest.runtest functions now modify a TestResult instance
in-place.
* libregrtest summary lists the number of run tests and skipped
tests, and denied resources.
* Add TestResult.has_meaningful_duration() method.
* Compute TestResult duration in the upper function.
* Use time.perf_counter() instead of time.monotonic().
* Regrtest: rename 'resource_denieds' attribute to 'resource_denied'.
* Rename CHILD_ERROR to MULTIPROCESSING_ERROR.
* Use match/case syntadx to have different code depending on the
test state.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit d4e534cbb35678c82b3a1276826af55d7bfc23b6)
* gh-108822: Add Changelog entry for regrtest statistics (#108821)
---------
Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Zachary Ware <zach@python.org>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Joshua Herman <zitterbewegung@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-09-03 19:21:53 +02:00
|
|
|
randomize=True,
|
|
|
|
|
stats=0)
|
|
|
|
|
|
|
|
|
|
def test_doctest(self):
|
|
|
|
|
code = textwrap.dedent(fr'''
|
|
|
|
|
import doctest
|
|
|
|
|
import sys
|
|
|
|
|
from test import support
|
|
|
|
|
|
|
|
|
|
def my_function():
|
|
|
|
|
"""
|
|
|
|
|
Pass:
|
|
|
|
|
|
|
|
|
|
>>> 1 + 1
|
|
|
|
|
2
|
|
|
|
|
|
|
|
|
|
Failure:
|
|
|
|
|
|
|
|
|
|
>>> 2 + 3
|
|
|
|
|
23
|
|
|
|
|
>>> 1 + 1
|
|
|
|
|
11
|
|
|
|
|
|
|
|
|
|
Skipped test (ignored):
|
|
|
|
|
|
|
|
|
|
>>> id(1.0) # doctest: +SKIP
|
|
|
|
|
7948648
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
def test_main():
|
|
|
|
|
testmod = sys.modules[__name__]
|
|
|
|
|
return support.run_doctest(testmod)
|
|
|
|
|
''')
|
|
|
|
|
testname = self.create_test(code=code)
|
|
|
|
|
|
|
|
|
|
output = self.run_tests("--fail-env-changed", "-v", "-j1", testname,
|
|
|
|
|
exitcode=EXITCODE_BAD_TEST)
|
|
|
|
|
self.check_executed_tests(output, [testname],
|
|
|
|
|
failed=[testname],
|
|
|
|
|
randomize=True,
|
|
|
|
|
stats=TestStats(3, 2, 0))
|
2023-06-28 04:58:34 +02:00
|
|
|
|
2015-09-28 23:16:17 +02:00
|
|
|
|
2018-06-14 14:58:13 +02:00
|
|
|
class TestUtils(unittest.TestCase):
|
|
|
|
|
def test_format_duration(self):
|
|
|
|
|
self.assertEqual(utils.format_duration(0),
|
|
|
|
|
'0 ms')
|
|
|
|
|
self.assertEqual(utils.format_duration(1e-9),
|
|
|
|
|
'1 ms')
|
|
|
|
|
self.assertEqual(utils.format_duration(10e-3),
|
|
|
|
|
'10 ms')
|
|
|
|
|
self.assertEqual(utils.format_duration(1.5),
|
2019-10-03 16:15:16 +02:00
|
|
|
'1.5 sec')
|
2018-06-14 14:58:13 +02:00
|
|
|
self.assertEqual(utils.format_duration(1),
|
2019-10-03 16:15:16 +02:00
|
|
|
'1.0 sec')
|
2018-06-14 14:58:13 +02:00
|
|
|
self.assertEqual(utils.format_duration(2 * 60),
|
|
|
|
|
'2 min')
|
|
|
|
|
self.assertEqual(utils.format_duration(2 * 60 + 1),
|
|
|
|
|
'2 min 1 sec')
|
|
|
|
|
self.assertEqual(utils.format_duration(3 * 3600),
|
|
|
|
|
'3 hour')
|
|
|
|
|
self.assertEqual(utils.format_duration(3 * 3600 + 2 * 60 + 1),
|
|
|
|
|
'3 hour 2 min')
|
|
|
|
|
self.assertEqual(utils.format_duration(3 * 3600 + 1),
|
|
|
|
|
'3 hour 1 sec')
|
|
|
|
|
|
|
|
|
|
|
2012-12-27 18:53:12 -08:00
|
|
|
if __name__ == '__main__':
|
2013-08-29 12:26:23 +03:00
|
|
|
unittest.main()
|