Commit b03802ad authored by Denis Bilenko's avatar Denis Bilenko

test__benchmarks.py: better error reporting

parent 30e9e05f
...@@ -4,11 +4,13 @@ import mysubprocess as subprocess ...@@ -4,11 +4,13 @@ import mysubprocess as subprocess
import time import time
TIMEOUT = 10
def system(command): def system(command):
p = subprocess.Popen(command, shell=True) p = subprocess.Popen(command, shell=True)
try: try:
start = time.time() start = time.time()
while time.time() < start + 10 and p.poll() is None: while time.time() < start + TIMEOUT and p.poll() is None:
time.sleep(0.1) time.sleep(0.1)
if p.poll() is None: if p.poll() is None:
p.kill() p.kill()
...@@ -24,20 +26,21 @@ modules = set() ...@@ -24,20 +26,21 @@ modules = set()
for path in glob.glob('bench_*.py'): for path in glob.glob('bench_*.py'):
modules.add(path) modules.add(path)
assert modules
error = 0
if __name__ == '__main__': if __name__ == '__main__':
assert modules
errors = []
for path in modules: for path in modules:
print (path) sys.stderr.write(path + '\n')
sys.stdout.flush() sys.stdout.flush()
res = system('%s %s all' % (sys.executable, path)) command = '%s %s all' % (sys.executable, path)
res = system(command)
if res: if res:
error = 1 error = '%r failed with code %s' % (command, res)
print ('%s %s' % (path, 'failed')) sys.stderr.write(error + '\n')
print ('-----') errors.append(error)
sys.stderr.write('-----\n\n')
if error: if errors:
sys.exit(1) sys.exit('\n'.join(errors))
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment