summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xpyjutest41
1 files changed, 31 insertions, 10 deletions
diff --git a/pyjutest b/pyjutest
index 96766cb..ee04fdd 100755
--- a/pyjutest
+++ b/pyjutest
@@ -14,6 +14,7 @@ from subprocess import Popen, PIPE, STDOUT
from optparse import OptionParser
import os
+import select
import sys
import time
@@ -48,12 +49,39 @@ else:
start = time.time()
p = Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE)
-out,err = p.communicate()
+fds = [ p.stdout, p.stderr ]
+
+out = ""
+err = ""
+
+while True:
+ readable, writable, exceptional = select.select(fds, [], [])
+ done = 0
+
+ if p.stderr in readable:
+ l = p.stderr.readline().decode('utf-8')
+ if len(l):
+ print(l[:-1], file=sys.stderr)
+ sys.stderr.flush()
+ err += l
+ else:
+ done = 1
+
+ if p.stdout in readable:
+ l = p.stdout.readline().decode('utf-8')
+ if len(l):
+ print(l[:-1])
+ sys.stdout.flush()
+ out += l
+ else:
+ if done:
+ break
+
+p.wait()
duration = time.time() - start
-tc = TestCase(opt.uname, opt.uclass, duration, out[:-1].decode('utf-8'),
- err[:-1].decode('utf-8'))
+tc = TestCase(opt.uname, opt.uclass, duration, out, err)
if p.returncode:
tc.add_failure_info(err, "return: %d" % p.returncode)
@@ -65,10 +93,3 @@ with open('pyjutest.dat', 'wb') as dat:
with open('pyjutest.xml', 'w') as xml:
TestSuite.to_file(xml, tss, prettyprint=True)
-
-print("%s STDOUT:" % opt.uname)
-for l in out.decode().split("\n"):
- print(l)
-print("%s STDERR:" % opt.uname)
-for l in err.decode().split("\n"):
- print(l, file=sys.stderr)