Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,19 @@ jobs:
regression-tests:
name: Run mypy on the test cases
runs-on: ubuntu-latest
strategy:
matrix:
platform: ["linux", "darwin", "win32"]
fail-fast: false
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: "3.11"
python-version: "3.12"
cache: pip
cache-dependency-path: requirements-tests.txt
- run: pip install -r requirements-tests.txt
- run: python ./tests/regr_test.py --all --verbosity QUIET
- run: python ./tests/regr_test.py --platform=${{ matrix.platform }} --all-python-versions --verbosity QUIET

pyright:
name: Test typeshed with pyright
Expand Down
21 changes: 20 additions & 1 deletion tests/regr_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ class Verbosity(IntEnum):
"Note that this cannot be specified if --platform and/or --python-version are specified."
),
)
parser.add_argument(
"--all-python-versions",
action="store_true",
help=(
'Run tests on all available Python versions (defaults to "False"). '
"Note that this cannot be specified if --all and/or --python-version are specified."
),
)
parser.add_argument(
"--verbosity",
choices=[member.name for member in Verbosity],
Expand Down Expand Up @@ -308,7 +316,11 @@ def concurrently_run_testcases(
printer_thread = threading.Thread(target=print_queued_messages, args=(event,))
printer_thread.start()

with concurrent.futures.ThreadPoolExecutor(max_workers=os.cpu_count()) as executor:
# Limit the number of workers to 1 for now. There are intermittent mypy
# crashes when running with multiple workers. See
# https://github.com/python/typeshed/issues/11220 for details.
max_workers = 1 # os.cpu_count() or 2
with concurrent.futures.ThreadPoolExecutor(max_workers=max_workers) as executor:
# Each temporary directory may be used by multiple processes concurrently during the next step;
# must make sure that they're all setup correctly before starting the next step,
# in order to avoid race conditions
Expand All @@ -334,9 +346,16 @@ def main() -> ReturnCode:
if args.all:
if args.platforms_to_test:
parser.error("Cannot specify both --platform and --all")
if args.all_python_versions:
parser.error("Cannot specify both --all-python-versions and --all")
if args.versions_to_test:
parser.error("Cannot specify both --python-version and --all")
platforms_to_test, versions_to_test = SUPPORTED_PLATFORMS, SUPPORTED_VERSIONS
elif args.all_python_versions:
if args.versions_to_test:
parser.error("Cannot specify both --python-version and --all-python-versions")
platforms_to_test = args.platforms_to_test or [sys.platform]
versions_to_test = SUPPORTED_VERSIONS
else:
platforms_to_test = args.platforms_to_test or [sys.platform]
versions_to_test = args.versions_to_test or [PYTHON_VERSION]
Expand Down