|
14 | 14 | else:
|
15 | 15 | python_name = 'python3'
|
16 | 16 |
|
| 17 | +# Slow test suites |
| 18 | +CMDLINE = 'PythonCmdline' |
| 19 | +SAMPLES = 'SamplesSuite' |
| 20 | +TYPESHED = 'TypeshedSuite' |
| 21 | +PEP561 = 'TestPEP561' |
| 22 | +EVALUATION = 'PythonEvaluation' |
| 23 | + |
| 24 | +ALL_NON_FAST = [CMDLINE, SAMPLES, TYPESHED, PEP561, EVALUATION] |
| 25 | + |
| 26 | +# We split the pytest run into three parts to improve test |
| 27 | +# parallelization. Each run should have tests that each take a roughly similiar |
| 28 | +# time to run. |
17 | 29 | cmds = {
|
| 30 | + # Self type check |
18 | 31 | 'self': python_name + ' -m mypy --config-file mypy_self_check.ini -p mypy',
|
| 32 | + # Lint |
19 | 33 | 'lint': 'flake8 -j0',
|
20 |
| - 'pytest': 'pytest' |
| 34 | + # Fast test cases only (this is the bulk of the test suite) |
| 35 | + 'pytest-fast': 'pytest -k "not (%s)"' % ' or '.join(ALL_NON_FAST), |
| 36 | + # Test cases that invoke mypy (with small inputs) |
| 37 | + 'pytest-cmdline': 'pytest -k "%s"' % ' or '.join([CMDLINE, EVALUATION]), |
| 38 | + # Test cases that may take seconds to run each |
| 39 | + 'pytest-slow': 'pytest -k "%s"' % ' or '.join([SAMPLES, TYPESHED, PEP561]), |
21 | 40 | }
|
22 | 41 |
|
| 42 | +# Stop run immediately if these commands fail |
| 43 | +FAST_FAIL = ['self', 'lint'] |
| 44 | + |
| 45 | +assert all(cmd in cmds for cmd in FAST_FAIL) |
| 46 | + |
23 | 47 | if not set(args).issubset(cmds):
|
24 | 48 | print("usage:", prog, " ".join('[%s]' % k for k in cmds))
|
25 | 49 | exit(1)
|
26 | 50 |
|
27 | 51 | if not args:
|
28 | 52 | args = list(cmds)
|
29 | 53 |
|
| 54 | +status = 0 |
| 55 | + |
30 | 56 | for arg in args:
|
31 | 57 | cmd = cmds[arg]
|
32 |
| - print('$', cmd) |
| 58 | + print('run %s: %s' % (arg, cmd)) |
33 | 59 | res = (system(cmd) & 0x7F00) >> 8
|
34 | 60 | if res:
|
35 |
| - exit(res) |
| 61 | + print('\nFAILED: %s' % arg) |
| 62 | + status = res |
| 63 | + if arg in FAST_FAIL: |
| 64 | + exit(status) |
| 65 | + |
| 66 | +exit(status) |
0 commit comments