diff --git a/test/testall.py b/test/testall.py index 795e798a..92efd1de 100644 --- a/test/testall.py +++ b/test/testall.py @@ -40,6 +40,7 @@ def _gen_pythons(): yield ver, python def testall(): + all_warnings = [] for ver, python in _gen_pythons(): if ver < (3, 5): # Don't support Python < 3.5 @@ -47,12 +48,26 @@ def testall(): ver_str = "%s.%s" % ver print("-- test with Python %s (%s)" % (ver_str, python)) assert ' ' not in python + proc = subprocess.Popen( - "MACOSX_DEPLOYMENT_TARGET= %s test.py -- -knownfailure" % python, - shell=True + # pass "-u" option to force unbuffered output + "MACOSX_DEPLOYMENT_TARGET= %s -u test.py -- -knownfailure" % python, + shell=True, stderr=subprocess.PIPE ) - rv = proc.wait() - if rv: - sys.exit(os.WEXITSTATUS(rv)) + + while proc.poll() is None: + # capture and re-print stderr while process is running + line = proc.stderr.readline().decode().strip() + print(line, file=sys.stderr) + if 'WARNING:test:' in line: + # if stderr contains a warning, save this for later + all_warnings.append((python, ver_str, line)) + + if proc.returncode: + sys.exit(os.WEXITSTATUS(proc.returncode)) + + for python, ver_str, warning in all_warnings: + # now re-print all warnings to make sure they are seen + print('-- warning raised by Python %s (%s) -- %s' % (ver_str, python, warning)) testall()