Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clearer warning when not all tests are ran #459

Merged
merged 2 commits into from
Jun 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 25 additions & 9 deletions test/testall.py
Original file line number Diff line number Diff line change
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()