Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split runtests.py pytest run into 3 parts to improve parallelization #5764

Merged
merged 1 commit into from Oct 11, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
37 changes: 34 additions & 3 deletions runtests.py
Expand Up @@ -14,22 +14,53 @@
else:
python_name = 'python3'

# Slow test suites
CMDLINE = 'PythonCmdline'
SAMPLES = 'SamplesSuite'
TYPESHED = 'TypeshedSuite'
PEP561 = 'TestPEP561'
EVALUATION = 'PythonEvaluation'

ALL_NON_FAST = [CMDLINE, SAMPLES, TYPESHED, PEP561, EVALUATION]

# We split the pytest run into three parts to improve test
# parallelization. Each run should have tests that each take a roughly similiar
# time to run.
cmds = {
# Self type check
'self': python_name + ' -m mypy --config-file mypy_self_check.ini -p mypy',
# Lint
'lint': 'flake8 -j0',
'pytest': 'pytest'
# Fast test cases only (this is the bulk of the test suite)
'pytest-fast': 'pytest -k "not (%s)"' % ' or '.join(ALL_NON_FAST),
# Test cases that invoke mypy (with small inputs)
'pytest-cmdline': 'pytest -k "%s"' % ' or '.join([CMDLINE, EVALUATION]),
# Test cases that may take seconds to run each
'pytest-slow': 'pytest -k "%s"' % ' or '.join([SAMPLES, TYPESHED, PEP561]),
}

# Stop run immediately if these commands fail
FAST_FAIL = ['self', 'lint']

assert all(cmd in cmds for cmd in FAST_FAIL)

if not set(args).issubset(cmds):
print("usage:", prog, " ".join('[%s]' % k for k in cmds))
exit(1)

if not args:
args = list(cmds)

status = 0

for arg in args:
cmd = cmds[arg]
print('$', cmd)
print('run %s: %s' % (arg, cmd))
res = (system(cmd) & 0x7F00) >> 8
if res:
exit(res)
print('\nFAILED: %s' % arg)
status = res
if arg in FAST_FAIL:
exit(status)

exit(status)