|
2 | 2 | # |
3 | 3 | # Run the test suite against all the Python versions we can find. |
4 | 4 | # |
5 | | - |
6 | | - |
7 | | - |
8 | | -import sys |
9 | 5 | import os |
10 | | -from os.path import dirname, abspath, join |
11 | 6 | import re |
12 | | - |
| 7 | +import subprocess |
| 8 | +import sys |
| 9 | +from os.path import abspath, dirname, join |
13 | 10 |
|
14 | 11 | TOP = dirname(dirname(abspath(__file__))) |
15 | 12 | sys.path.insert(0, join(TOP, "tools")) |
@@ -43,15 +40,34 @@ def _gen_pythons(): |
43 | 40 | yield ver, python |
44 | 41 |
|
45 | 42 | def testall(): |
| 43 | + all_warnings = [] |
46 | 44 | for ver, python in _gen_pythons(): |
47 | 45 | if ver < (3, 5): |
48 | 46 | # Don't support Python < 3.5 |
49 | 47 | continue |
50 | 48 | ver_str = "%s.%s" % ver |
51 | 49 | print("-- test with Python %s (%s)" % (ver_str, python)) |
52 | 50 | assert ' ' not in python |
53 | | - rv = os.system("MACOSX_DEPLOYMENT_TARGET= %s test.py -- -knownfailure" % python) |
54 | | - if rv: |
55 | | - sys.exit(os.WEXITSTATUS(rv)) |
| 51 | + |
| 52 | + proc = subprocess.Popen( |
| 53 | + # pass "-u" option to force unbuffered output |
| 54 | + "MACOSX_DEPLOYMENT_TARGET= %s -u test.py -- -knownfailure" % python, |
| 55 | + shell=True, stderr=subprocess.PIPE |
| 56 | + ) |
| 57 | + |
| 58 | + while proc.poll() is None: |
| 59 | + # capture and re-print stderr while process is running |
| 60 | + line = proc.stderr.readline().decode().strip() |
| 61 | + print(line, file=sys.stderr) |
| 62 | + if 'WARNING:test:' in line: |
| 63 | + # if stderr contains a warning, save this for later |
| 64 | + all_warnings.append((python, ver_str, line)) |
| 65 | + |
| 66 | + if proc.returncode: |
| 67 | + sys.exit(os.WEXITSTATUS(proc.returncode)) |
| 68 | + |
| 69 | + for python, ver_str, warning in all_warnings: |
| 70 | + # now re-print all warnings to make sure they are seen |
| 71 | + print('-- warning raised by Python %s (%s) -- %s' % (ver_str, python, warning)) |
56 | 72 |
|
57 | 73 | testall() |
0 commit comments