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
import time
TIMEOUT = 10
def system(command):
p = subprocess.Popen(command, shell=True)
try:
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)
if p.poll() is None:
p.kill()
......@@ -24,20 +26,21 @@ modules = set()
for path in glob.glob('bench_*.py'):
modules.add(path)
assert modules
error = 0
if __name__ == '__main__':
assert modules
errors = []
for path in modules:
print (path)
sys.stderr.write(path + '\n')
sys.stdout.flush()
res = system('%s %s all' % (sys.executable, path))
command = '%s %s all' % (sys.executable, path)
res = system(command)
if res:
error = 1
print ('%s %s' % (path, 'failed'))
print ('-----')
error = '%r failed with code %s' % (command, res)
sys.stderr.write(error + '\n')
errors.append(error)
sys.stderr.write('-----\n\n')
if error:
sys.exit(1)
if errors:
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