11#!/usr/bin/env python3
22import subprocess
33from subprocess import Popen
4- from os import system
5- from sys import argv , exit , platform , executable , version_info
6-
7-
8- # Use the Python provided to execute the script, or fall back to a sane default
9- if version_info >= (3 , 5 , 0 ):
10- python_name = executable
11- else :
12- if platform == 'win32' :
13- python_name = 'py -3'
14- else :
15- python_name = 'python3'
4+ from sys import argv , exit , executable
165
176# Slow test suites
187CMDLINE = 'PythonCmdline'
5544# time to run.
5645cmds = {
5746 # Self type check
58- 'self' : python_name + ' -m mypy --config-file mypy_self_check.ini -p mypy' ,
47+ 'self' : [ executable , '-m' , ' mypy' , ' --config-file' , ' mypy_self_check.ini' , '-p' , ' mypy'] ,
5948 # Lint
60- 'lint' : 'flake8 -j0' ,
49+ 'lint' : [ 'flake8' , ' -j0'] ,
6150 # Fast test cases only (this is the bulk of the test suite)
62- 'pytest-fast' : 'pytest -q -k " not (%s)" ' % ' or ' .join (ALL_NON_FAST ),
51+ 'pytest-fast' : [ 'pytest' , '-q' , '-k' , ' not (%s)' % ' or ' .join (ALL_NON_FAST )] ,
6352 # Test cases that invoke mypy (with small inputs)
64- 'pytest-cmdline' : 'pytest -q -k "%s"' % ' or ' .join ([CMDLINE ,
65- EVALUATION ,
66- STUBGEN_CMD ,
67- STUBGEN_PY ]),
53+ 'pytest-cmdline' : [ 'pytest' , '-q' , '-k' , ' or ' .join ([CMDLINE ,
54+ EVALUATION ,
55+ STUBGEN_CMD ,
56+ STUBGEN_PY ])] ,
6857 # Test cases that may take seconds to run each
69- 'pytest-slow' : 'pytest -q -k "%s"' % ' or ' .join (
58+ 'pytest-slow' : [ 'pytest' , '-q' , '-k' , ' or ' .join (
7059 [SAMPLES ,
7160 TYPESHED ,
7261 PEP561 ,
7362 DAEMON ,
7463 MYPYC_EXTERNAL ,
7564 MYPYC_COMMAND_LINE ,
76- ERROR_STREAM ]),
65+ ERROR_STREAM ])] ,
7766 # Test cases to run in typeshed CI
78- 'typeshed-ci' : 'pytest -q -k "%s"' % ' or ' .join ([CMDLINE , EVALUATION , SAMPLES , TYPESHED ]),
67+ 'typeshed-ci' : ['pytest' , '-q' , '-k' , ' or ' .join ([CMDLINE ,
68+ EVALUATION ,
69+ SAMPLES ,
70+ TYPESHED ])],
7971 # Mypyc tests that aren't run by default, since they are slow and rarely
8072 # fail for commits that don't touch mypyc
81- 'mypyc-extra' : 'pytest -q -k "%s"' % ' or ' .join (MYPYC_OPT_IN ),
73+ 'mypyc-extra' : [ 'pytest' , '-q' , '-k' , ' or ' .join (MYPYC_OPT_IN )] ,
8274}
8375
8476# Stop run immediately if these commands fail
@@ -93,10 +85,10 @@ def run_cmd(name: str) -> int:
9385 status = 0
9486 cmd = cmds [name ]
9587 print ('run %s: %s' % (name , cmd ))
96- res = ( system ( cmd ) & 0x7F00 ) >> 8
97- if res :
88+ proc = subprocess . run ( cmd , stderr = subprocess . STDOUT )
89+ if proc . returncode :
9890 print ('\n FAILED: %s' % name )
99- status = res
91+ status = proc . returncode
10092 if name in FAST_FAIL :
10193 exit (status )
10294 return status
@@ -105,7 +97,6 @@ def run_cmd(name: str) -> int:
10597def start_background_cmd (name : str ) -> Popen :
10698 cmd = cmds [name ]
10799 proc = subprocess .Popen (cmd ,
108- shell = True ,
109100 stderr = subprocess .STDOUT ,
110101 stdout = subprocess .PIPE )
111102 return proc
0 commit comments