mirror of
https://github.com/python/cpython.git
synced 2025-09-27 18:59:43 +00:00
This commit is contained in:
parent
36dbebed44
commit
acc62db8af
7 changed files with 18 additions and 12 deletions
|
@ -3,7 +3,7 @@ import os.path
|
||||||
import shlex
|
import shlex
|
||||||
import sys
|
import sys
|
||||||
from test.support import os_helper
|
from test.support import os_helper
|
||||||
from .utils import ALL_RESOURCES, RESOURCE_NAMES
|
from .utils import ALL_RESOURCES, RESOURCE_NAMES, TestFilter
|
||||||
|
|
||||||
|
|
||||||
USAGE = """\
|
USAGE = """\
|
||||||
|
@ -161,7 +161,7 @@ class Namespace(argparse.Namespace):
|
||||||
self.forever = False
|
self.forever = False
|
||||||
self.header = False
|
self.header = False
|
||||||
self.failfast = False
|
self.failfast = False
|
||||||
self.match_tests = []
|
self.match_tests: TestFilter = []
|
||||||
self.pgo = False
|
self.pgo = False
|
||||||
self.pgo_extended = False
|
self.pgo_extended = False
|
||||||
self.worker_json = None
|
self.worker_json = None
|
||||||
|
|
|
@ -52,7 +52,8 @@ def runtest_refleak(test_name, test_func,
|
||||||
except ImportError:
|
except ImportError:
|
||||||
zdc = None # Run unmodified on platforms without zipimport support
|
zdc = None # Run unmodified on platforms without zipimport support
|
||||||
else:
|
else:
|
||||||
zdc = zipimport._zip_directory_cache.copy()
|
# private attribute that mypy doesn't know about:
|
||||||
|
zdc = zipimport._zip_directory_cache.copy() # type: ignore[attr-defined]
|
||||||
abcs = {}
|
abcs = {}
|
||||||
for abc in [getattr(collections.abc, a) for a in collections.abc.__all__]:
|
for abc in [getattr(collections.abc, a) for a in collections.abc.__all__]:
|
||||||
if not isabstract(abc):
|
if not isabstract(abc):
|
||||||
|
|
|
@ -33,7 +33,7 @@ class TestResults:
|
||||||
self.test_times: list[tuple[float, TestName]] = []
|
self.test_times: list[tuple[float, TestName]] = []
|
||||||
self.stats = TestStats()
|
self.stats = TestStats()
|
||||||
# used by --junit-xml
|
# used by --junit-xml
|
||||||
self.testsuite_xml: list[str] = []
|
self.testsuite_xml: list = []
|
||||||
|
|
||||||
def is_all_good(self):
|
def is_all_good(self):
|
||||||
return (not self.bad
|
return (not self.bad
|
||||||
|
|
|
@ -10,7 +10,7 @@ import tempfile
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
import traceback
|
import traceback
|
||||||
from typing import Literal, TextIO
|
from typing import Any, Literal, TextIO
|
||||||
|
|
||||||
from test import support
|
from test import support
|
||||||
from test.support import os_helper, MS_WINDOWS
|
from test.support import os_helper, MS_WINDOWS
|
||||||
|
@ -243,7 +243,9 @@ class WorkerThread(threading.Thread):
|
||||||
|
|
||||||
json_fd = json_tmpfile.fileno()
|
json_fd = json_tmpfile.fileno()
|
||||||
if MS_WINDOWS:
|
if MS_WINDOWS:
|
||||||
json_handle = msvcrt.get_osfhandle(json_fd)
|
# The msvcrt module is only available on Windows;
|
||||||
|
# we run mypy with `--platform=linux` in CI
|
||||||
|
json_handle: int = msvcrt.get_osfhandle(json_fd) # type: ignore[attr-defined]
|
||||||
json_file = JsonFile(json_handle,
|
json_file = JsonFile(json_handle,
|
||||||
JsonFileType.WINDOWS_HANDLE)
|
JsonFileType.WINDOWS_HANDLE)
|
||||||
else:
|
else:
|
||||||
|
@ -257,7 +259,7 @@ class WorkerThread(threading.Thread):
|
||||||
else:
|
else:
|
||||||
match_tests = None
|
match_tests = None
|
||||||
|
|
||||||
kwargs = {}
|
kwargs: dict[str, Any] = {}
|
||||||
if match_tests:
|
if match_tests:
|
||||||
kwargs['match_tests'] = [(test, True) for test in match_tests]
|
kwargs['match_tests'] = [(test, True) for test in match_tests]
|
||||||
if self.runtests.output_on_failure:
|
if self.runtests.output_on_failure:
|
||||||
|
@ -343,6 +345,7 @@ class WorkerThread(threading.Thread):
|
||||||
json_file, json_tmpfile = self.create_json_file(stack)
|
json_file, json_tmpfile = self.create_json_file(stack)
|
||||||
worker_runtests = self.create_worker_runtests(test_name, json_file)
|
worker_runtests = self.create_worker_runtests(test_name, json_file)
|
||||||
|
|
||||||
|
retcode: str | int | None
|
||||||
retcode, tmp_files = self.run_tmp_files(worker_runtests,
|
retcode, tmp_files = self.run_tmp_files(worker_runtests,
|
||||||
stdout_file.fileno())
|
stdout_file.fileno())
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,8 @@ class JsonFile:
|
||||||
popen_kwargs['pass_fds'] = [self.file]
|
popen_kwargs['pass_fds'] = [self.file]
|
||||||
case JsonFileType.WINDOWS_HANDLE:
|
case JsonFileType.WINDOWS_HANDLE:
|
||||||
# Windows handle
|
# Windows handle
|
||||||
startupinfo = subprocess.STARTUPINFO()
|
# We run mypy with `--platform=linux` so it complains about this:
|
||||||
|
startupinfo = subprocess.STARTUPINFO() # type: ignore[attr-defined]
|
||||||
startupinfo.lpAttributeList = {"handle_list": [self.file]}
|
startupinfo.lpAttributeList = {"handle_list": [self.file]}
|
||||||
popen_kwargs['startupinfo'] = startupinfo
|
popen_kwargs['startupinfo'] = startupinfo
|
||||||
|
|
||||||
|
|
|
@ -124,7 +124,8 @@ def setup_tests(runtests: RunTests):
|
||||||
support.LONG_TIMEOUT = min(support.LONG_TIMEOUT, timeout)
|
support.LONG_TIMEOUT = min(support.LONG_TIMEOUT, timeout)
|
||||||
|
|
||||||
if runtests.hunt_refleak:
|
if runtests.hunt_refleak:
|
||||||
unittest.BaseTestSuite._cleanup = False
|
# private attribute that mypy doesn't know about:
|
||||||
|
unittest.BaseTestSuite._cleanup = False # type: ignore[attr-defined]
|
||||||
|
|
||||||
if runtests.gc_threshold is not None:
|
if runtests.gc_threshold is not None:
|
||||||
gc.set_threshold(runtests.gc_threshold)
|
gc.set_threshold(runtests.gc_threshold)
|
||||||
|
|
|
@ -12,7 +12,7 @@ import sys
|
||||||
import sysconfig
|
import sysconfig
|
||||||
import tempfile
|
import tempfile
|
||||||
import textwrap
|
import textwrap
|
||||||
from collections.abc import Callable
|
from collections.abc import Callable, Iterable
|
||||||
|
|
||||||
from test import support
|
from test import support
|
||||||
from test.support import os_helper
|
from test.support import os_helper
|
||||||
|
@ -556,7 +556,7 @@ def is_cross_compiled():
|
||||||
return ('_PYTHON_HOST_PLATFORM' in os.environ)
|
return ('_PYTHON_HOST_PLATFORM' in os.environ)
|
||||||
|
|
||||||
|
|
||||||
def format_resources(use_resources: tuple[str, ...]):
|
def format_resources(use_resources: Iterable[str]):
|
||||||
use_resources = set(use_resources)
|
use_resources = set(use_resources)
|
||||||
all_resources = set(ALL_RESOURCES)
|
all_resources = set(ALL_RESOURCES)
|
||||||
|
|
||||||
|
@ -596,7 +596,7 @@ def display_header(use_resources: tuple[str, ...],
|
||||||
print("== Python build:", ' '.join(get_build_info()))
|
print("== Python build:", ' '.join(get_build_info()))
|
||||||
print("== cwd:", os.getcwd())
|
print("== cwd:", os.getcwd())
|
||||||
|
|
||||||
cpu_count = os.cpu_count()
|
cpu_count: object = os.cpu_count()
|
||||||
if cpu_count:
|
if cpu_count:
|
||||||
affinity = process_cpu_count()
|
affinity = process_cpu_count()
|
||||||
if affinity and affinity != cpu_count:
|
if affinity and affinity != cpu_count:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue