summaryrefslogtreecommitdiffstats
path: root/Lib/test/libregrtest/setup.py
Commit message (Collapse)AuthorAgeFilesLines
* [3.13] gh-109413: Add more type hints to `libregrtest` (GH-126352) (#126388)Miss Islington (bot)2025-01-081-4/+5
| | | | | | gh-109413: Add more type hints to `libregrtest` (GH-126352) (cherry picked from commit bfc1d2504c183a9464e65c290e48516d176ea41f) Co-authored-by: sobolevn <mail@sobolevn.me>
* gh-109413: Run mypy on `libregrtest` in CI (#112558)Alex Waygood2023-11-301-1/+2
| | | Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
* gh-111165: Move test running code from test.support to libregrtest (GH-111166)Serhiy Storchaka2023-10-251-2/+3
| | | | Remove no longer used functions run_unittest() and run_doctest() from the test.support module.
* gh-110918: regrtest: allow to intermix --match and --ignore options (GH-110919)Serhiy Storchaka2023-10-211-1/+1
| | | | | | | Test case matching patterns specified by options --match, --ignore, --matchfile and --ignorefile are now tested in the order of specification, and the last match determines whether the test case be run or ignored.
* gh-110167: Increase support.LOOPBACK_TIMEOUT to 10 seconds (#110413)Victor Stinner2023-10-051-0/+2
| | | | | | Increase support.LOOPBACK_TIMEOUT from 5 to 10 seconds. Also increase the timeout depending on the --timeout option. For example, for a test timeout of 40 minutes (ARM Raspbian 3.x), use LOOPBACK_TIMEOUT of 20 seconds instead of 5 seconds before.
* gh-110171: `libregrtest` always sets `random.seed` (#110172)Nikita Sobolev2023-10-041-2/+1
|
* gh-109276, gh-109508: Fix libregrtest stdout (#109903)Victor Stinner2023-09-261-2/+2
| | | | | | | | | Remove replace_stdout(): call sys.stdout.reconfigure() instead of set the error handler to backslashreplace. display_header() logs an empty line and flush stdout. Remove encoding workaround in display_header() since stdout error handler is now set to backslashreplace earlier.
* gh-109413: libregrtest: Add and improve type annotations (#109405)Alex Waygood2023-09-141-4/+1
|
* gh-109276: libregrtest calls random.seed() before each test (#109279)Victor Stinner2023-09-121-0/+4
| | | | | | | | | | | | | libregrtest now calls random.seed() before running each test file when -r/--randomize command line option is used. Moreover, it's also called in worker processes. It should help to make tests more deterministic. Previously, it was only called once in the main process before running all test files and it was not called in worker processes. * Convert some f-strings to regular strings in test_regrtest when f-string is not needed. * Remove unused all_methods variable from test_regrtest. * Add RunTests members are now mandatory.
* gh-109162: libregrtest: use relative imports (#109250)Victor Stinner2023-09-111-2/+2
| | | | libregrtest.__init__ no longer exposes any symbol, so "python -m test.libregrtest.worker" imports less modules.
* gh-109162: libregrtest: rename runtest_mp.py to run_workers.py (#109248)Victor Stinner2023-09-111-86/+38
| | | | | | | | | | | | | | | * Rename runtest_mp.py to run_workers.py * Move exit_timeout() and temp_cwd() context managers from Regrtest.main() to Regrtest.run_tests(). Actions like --list-tests or --list-cases don't need these protections. * Regrtest: remove selected and tests attributes. Pass 'selected' to list_tests(), list_cases() and run_tests(). display_result() now expects a TestTuple, instead of TestList. * Rename setup_tests() to setup_process() and rename setup_support() to setup_tests(). * Move _adjust_resource_limits() to utils and rename it to adjust_rlimit_nofile(). * Move replace_stdout() to utils. * Fix RunTests.verbose type: it's an int.
* gh-109162: libregrtest: add single.py and result.py (#109243)Victor Stinner2023-09-111-0/+13
| | | | | | | | | | | * Add single.py and result.py files. * Rename runtest.py to runtests.py. * Move run_single_test() function and its helper functions to single.py. * Move remove_testfn(), abs_module_name() and normalize_test_name() to utils.py. * Move setup_support() to setup.py. * Move type hints like TestName to utils.py. * Rename runtest.py to runtests.py.
* gh-109162: libregrtest: add worker.py (#109229)Victor Stinner2023-09-101-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | Add new worker.py file: * Move create_worker_process() and worker_process() to this file. * Add main() function to worker.py. create_worker_process() now runs the command: "python -m test.libregrtest.worker JSON". * create_worker_process() now starts the worker process in the current working directory. Regrtest now gets the absolute path of the reflog.txt filename: -R command line option filename. * Remove --worker-json command line option. Remove test_regrtest.test_worker_json(). Related changes: * Add write_json() and from_json() methods to TestResult. * Rename select_temp_dir() to get_temp_dir() and move it to utils. * Rename make_temp_dir() to get_work_dir() and move it to utils. It no longer calls os.makedirs(): Regrtest.main() now calls it. * Move fix_umask() to utils. The function is now called by setup_tests(). * Move StrPath to utils. * Add exit_timeout() context manager to utils. * RunTests: Replace junit_filename (StrPath) with use_junit (bool).
* gh-109162: libregrtest: remove WorkerJob class (#109204)Victor Stinner2023-09-091-6/+6
| | | | | | | | | | | | | | | * Add attributes to Regrtest and RunTests: * gc_threshold * memory_limit * python_cmd * use_resources * Remove WorkerJob class. Add as_json() and from_json() methods to RunTests. A worker process now only uses RunTests for all parameters. * Add tests on support.set_memlimit() in test_support. Create _parse_memlimit() and also adds tests on it. * Remove 'ns' parameter from runtest.py.
* gh-109162: Refactor libregrtest.RunTests (#109177)Victor Stinner2023-09-091-4/+4
| | | | | | | | | | | | * Rename dash_R() runtest_refleak(). The function now gets huntrleaks and quiet arguments, instead of 'ns' argument. * Add attributes to Regrtest and RunTests: * verbose * quiet * huntrleaks * test_dir * Add HuntRefleak class.
* gh-109162: Refactor libregrtest.runtest (#109172)Victor Stinner2023-09-091-13/+16
| | | | | | | | | | | | | | | | | | | | | | * Rename runtest() to run_single_test(). * Pass runtests to run_single_test(). * Add type annotation to Regrtest attributes. Add missing attributes to Namespace. * Add attributes to Regrtest and RunTests: * fail_fast * ignore_tests * match_tests * output_on_failure * pgo * pgo_extended * timeout * Get pgo from 'runtests', rather than from 'ns'. * Remove WorkerJob.match_tests. * setup_support() now gets pgo_extended from runtests. * save_env(): change parameter order, pass test_name first. * Add setup_test_dir() function. * Pass runtests to setup_tests().
* Run Tools/scripts/reindent.py (#94225)Victor Stinner2022-06-261-1/+0
| | | | | Reindent files which were not properly formatted (PEP 8: 4 spaces). Remove also some trailing spaces.
* gh-84623: Remove unused imports in tests (#93772)Victor Stinner2022-06-131-1/+1
|
* gh-91904: Fix setting envvar PYTHONREGRTEST_UNICODE_GUARD (GH-91905)Serhiy Storchaka2022-04-251-4/+5
| | | | It always failed on non-UTF-8 locale and prevented running regrtests.
* bpo-43592: Raise RLIMIT_NOFILE in test.libregrtest (GH-29127)Gregory P. Smith2021-10-221-0/+24
| | | | | | | Raise RLIMIT_NOFILE in test.libregrtest. On macOS the default is often too low for our testsuite to succeed. Co-authored by reviewer: Victor Stinner
* bpo-44647: Add a permanent Unicode-valued env var to regrtest (#27187)Łukasz Langa2021-07-161-0/+10
|
* Remove sys._deactivate_opcache() now that is not needed (GH-27154)Pablo Galindo Salgado2021-07-151-1/+0
|
* bpo-43843: libregrtest uses threading.excepthook (GH-25400)Victor Stinner2021-04-161-1/+3
| | | | | | | | | test.libregrtest now marks a test as ENV_CHANGED (altered the execution environment) if a thread raises an exception but does not catch it. It sets a hook on threading.excepthook. Use --fail-env-changed option to mark the test as failed. libregrtest regrtest_unraisable_hook() explicitly flushs sys.stdout, sys.stderr and sys.__stderr__.
* bpo-41718: Disable support.testresult XML output by default (GH-24982)Victor Stinner2021-03-231-0/+4
| | | | | | | RegressionTestResult.USE_XML must now be set to True to get the JUnit XML output. Reduce the number of imports when --junit-xml=FILE option is not used: 153 => 144 (-9).
* bpo-37146: Deactivate opcode cache only when using huntrleaks in the test ↵Pablo Galindo2021-02-281-0/+1
| | | | suite (GH-24643)
* bpo-40826: Fix test_repl.test_close_stdin() on Windows (GH-20779)Victor Stinner2020-06-101-26/+1
| | | | | | | | | | | | test_repl.test_close_stdin() now calls support.suppress_msvcrt_asserts() to fix the test on Windows. * Move suppress_msvcrt_asserts() from test.libregrtest.setup to test.support. Make its verbose parameter optional: verbose=False by default. * Add msvcrt.GetErrorMode(). * SuppressCrashReport now uses GetErrorMode() and SetErrorMode() of the msvcrt module, rather than using ctypes. * Remove also an unused variable (deadline) in wait_process().
* bpo-38614: Add timeout constants to test.support (GH-16964)Victor Stinner2019-10-301-0/+11
| | | | | | | | Add timeout constants to test.support: * LOOPBACK_TIMEOUT * INTERNET_TIMEOUT * SHORT_TIMEOUT * LONG_TIMEOUT
* bpo-34602: Avoid failures setting macOS stack resource limit (GH-14546)Ned Deily2019-07-021-16/+0
| | | | | | | | | | | | | | | | | Under some conditions the earlier fix for bpo-18075, "Infinite recursion tests triggering a segfault on Mac OS X", now causes failures on macOS when attempting to change stack limit with resource.setrlimit resource.RLIMIT_STACK, like regrtest does when running the test suite. The reverted change had specified a non-default stack size when linking the python executable on macOS. As of macOS 10.14.4, the previous code causes a hard failure when running tests, although similar failures had been seen under some conditions under some earlier systems. Reverting the change to the interpreter stack size at link time helped for release builds but caused some tests to fail when built --with-pydebug. Try the opposite approach: continue to build the interpreter with an increased stack size on macOS and remove the failing setrlimit call in regrtest initialization. This will definitely avoid the resource.RLIMIT_STACK error and should have no, or fewer, side effects.
* bpo-37069: regrtest uses sys.unraisablehook (GH-13759)Victor Stinner2019-06-121-0/+4
| | | | | | | | regrtest now uses sys.unraisablehook() to mark a test as "environment altered" (ENV_CHANGED) if it emits an "unraisable exception". Moreover, regrtest logs a warning in this case. Use "python3 -m test --fail-env-changed" to catch unraisable exceptions in tests.
* bpo-36842: Fix reference leak in tests by running out-of-proc (GH-13556)Steve Dower2019-05-291-21/+26
|
* bpo-36842: Implement PEP 578 (GH-12613)Steve Dower2019-05-231-0/+6
| | | Adds sys.audit, sys.addaudithook, io.open_code, and associated C APIs.
* bpo-36560: Fix reference leak hunting in regrtest (GH-12744)Victor Stinner2019-04-091-6/+0
| | | | | | | | | | | | | | | | | | Fix reference leak hunting in regrtest: compute also deltas (of reference count, allocated memory blocks, file descriptor count) during warmup, to ensure that everything is initialized before starting to hunt reference leaks. Other changes: * Replace gc.collect() with support.gc_collect() * Move calls to read memory statistics from dash_R_cleanup() to dash_R() * Pass regrtest 'ns' to dash_R() * dash_R() is now more quiet with --quiet option (don't display progress). * Precompute the full range for "for it in range(repcount):" to ensure that the iteration doesn't allocate anything new. * dash_R() now is responsible to call warm_caches().
* bpo-32872: Avoid regrtest compatibility issue with namespace packages. (GH-6276)Ned Deily2018-03-281-1/+1
|
* bpo-25588: Fix regrtest when run inside IDLE (#3962)Victor Stinner2017-10-131-12/+31
| | | | | | | When regrtest in run inside IDLE, sys.stdout and sys.stderr are not TextIOWrapper objects and have no file descriptor associated: sys.stderr.fileno() raises io.UnsupportedOperation. Disable faulthandler and don't replace sys.stdout in that case.
* Issue #26295: When using "python3 -m test --testdir=TESTDIR", regrtest doesn'tVictor Stinner2016-03-301-0/+5
| | | | | | add "test." prefix to test module names. regrtest also prepends testdir to sys.path.
* regrtest: Fix module.__path__Victor Stinner2016-03-151-2/+2
| | | | | | | Issue #26538: libregrtest: Fix setup_tests() to keep module.__path__ type (_NamespacePath), don't convert to a list. Add _NamespacePath.__setitem__() method to importlib._bootstrap_external.
* Issue #23919: Prevents assert dialogs appearing in the test suite.Steve Dower2015-10-081-3/+9
|
* Issue #25220, libregrtest: Set support.use_resources in setup_tests()Victor Stinner2015-09-301-1/+3
| | | | | * Rename setup_python() to setup_tests() * Remove use_resources parameter of runtest()
* Issue #25220, libregrtest: Move setup_python() to a new submoduleVictor Stinner2015-09-291-0/+108