Skip to content

Commit e26158c

Browse files
Merge pull request #459 from Crozzers/clearer-test-warnings
Clearer warning when not all tests are ran
2 parents d022ba9 + faee13e commit e26158c

File tree

1 file changed

+25
-9
lines changed

1 file changed

+25
-9
lines changed

test/testall.py

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,11 @@
22
#
33
# Run the test suite against all the Python versions we can find.
44
#
5-
6-
7-
8-
import sys
95
import os
10-
from os.path import dirname, abspath, join
116
import re
12-
7+
import subprocess
8+
import sys
9+
from os.path import abspath, dirname, join
1310

1411
TOP = dirname(dirname(abspath(__file__)))
1512
sys.path.insert(0, join(TOP, "tools"))
@@ -43,15 +40,34 @@ def _gen_pythons():
4340
yield ver, python
4441

4542
def testall():
43+
all_warnings = []
4644
for ver, python in _gen_pythons():
4745
if ver < (3, 5):
4846
# Don't support Python < 3.5
4947
continue
5048
ver_str = "%s.%s" % ver
5149
print("-- test with Python %s (%s)" % (ver_str, python))
5250
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))
5672

5773
testall()

0 commit comments

Comments
 (0)