Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Commit 121ddda

Browse files
committed
Capture stdout/stderr, check stderr for warnings
1 parent c15182f commit 121ddda

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

tests/test_scripts.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from __future__ import print_function
1111
import os
1212
import sys
13+
import subprocess
1314

1415
filename = os.path.split(__file__)[1]
1516
if os.path.isfile(filename):
@@ -28,14 +29,22 @@
2829
def check(script):
2930
"""Runs script and Will increment good, warn or errors."""
3031
global good, warn, errors
31-
#TODO - Capture stderr, look for warnings
3232
#TODO - This assumes 'python' will be aliased as on TravisCI
33-
rc = os.system("python %s" % script)
34-
if rc:
33+
child = subprocess.Popen(["python", script],
34+
stdout=subprocess.PIPE,
35+
stderr=subprocess.PIPE,
36+
)
37+
stdout, stderr = child.communicate()
38+
if child.returncode:
3539
errors += 1
36-
sys.stderr.write("Return code %i from %s\n" % (rc, script))
40+
sys.stderr.write("Return code %i from %s\n" % (child.returncode, script))
41+
elif stderr:
42+
warn += 1
43+
sys.stderr.write(stderr)
3744
else:
3845
good += 1
46+
# TODO - shorten this when verbose
47+
sys.stdout.write(stdout)
3948

4049

4150
good = 0

0 commit comments

Comments
 (0)