Skip to content

Commit

Permalink
Merge pull request #459 from Crozzers/clearer-test-warnings
Browse files Browse the repository at this point in the history
Clearer warning when not all tests are ran
  • Loading branch information
nicholasserra committed Jun 22, 2023
2 parents d022ba9 + faee13e commit e26158c
Showing 1 changed file with 25 additions and 9 deletions.
34 changes: 25 additions & 9 deletions test/testall.py
Expand Up @@ -2,14 +2,11 @@
#
# Run the test suite against all the Python versions we can find.
#



import sys
import os
from os.path import dirname, abspath, join
import re

import subprocess
import sys
from os.path import abspath, dirname, join

TOP = dirname(dirname(abspath(__file__)))
sys.path.insert(0, join(TOP, "tools"))
Expand Down Expand Up @@ -43,15 +40,34 @@ 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
continue
ver_str = "%s.%s" % ver
print("-- test with Python %s (%s)" % (ver_str, python))
assert ' ' not in python
rv = os.system("MACOSX_DEPLOYMENT_TARGET= %s test.py -- -knownfailure" % python)
if rv:
sys.exit(os.WEXITSTATUS(rv))

proc = subprocess.Popen(
# pass "-u" option to force unbuffered output
"MACOSX_DEPLOYMENT_TARGET= %s -u test.py -- -knownfailure" % python,
shell=True, stderr=subprocess.PIPE
)

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()

0 comments on commit e26158c

Please sign in to comment.