Skip to content
Merged
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 CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,14 @@ python runtests.py self
# or equivalently:
python -m mypy --config-file mypy_self_check.ini -p mypy

# Run a single test from the test suite
pytest -n0 -k 'test_name'
# Run a single test from the test suite (uses pytest substring expression matching)
python runtests.py test_name
# or equivalently:
pytest -n0 -k test_name

# Run all test cases in the "test-data/unit/check-dataclasses.test" file
python runtests.py check-dataclasses.test
# or equivalently:
pytest mypy/test/testcheck.py::TypeCheckSuite::check-dataclasses.test

# Run the formatters and linters
Expand Down
23 changes: 19 additions & 4 deletions runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,13 @@

def run_cmd(name: str) -> int:
status = 0
cmd = cmds[name]
if name in cmds:
cmd = cmds[name]
else:
if name.endswith(".test"):
cmd = ["pytest", f"mypy/test/testcheck.py::TypeCheckSuite::{name}"]
else:
cmd = ["pytest", "-n0", "-k", name]
print(f"run {name}: {cmd}")
proc = subprocess.run(cmd, stderr=subprocess.STDOUT)
if proc.returncode:
Expand Down Expand Up @@ -144,13 +150,22 @@ def main() -> None:
prog, *args = argv

if not set(args).issubset(cmds):
print("usage:", prog, " ".join(f"[{k}]" for k in cmds))
print(
"usage:",
prog,
" ".join(f"[{k}]" for k in cmds),
"[names of individual tests and files...]",
)
print()
print(
"Run the given tests. If given no arguments, run everything except"
+ " pytest-extra and mypyc-extra."
+ " pytest-extra and mypyc-extra. Unrecognized arguments will be"
+ " interpreted as individual test names / substring expressions"
+ " (or, if they end in .test, individual test files)"
+ " and this script will try to run them."
)
exit(1)
if "-h" in args or "--help" in args:
exit(1)

if not args:
args = DEFAULT_COMMANDS.copy()
Expand Down