Commit a87a0a87 authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Move test script to python3

parent 34245e42
#!/usr/bin/env python3
import subprocess
import sys
import time
import os
from functools import partial
try:
from concurrent import futures
except ImportError:
print "To run multicore, first 'pip install --user futures'"
from concurrent import futures
def getProcessors():
......@@ -17,7 +14,7 @@ def getProcessors():
def colorMe(result, msg):
if sys.stdout.isatty():
code = "2" if result else "1"
code = "1" if result else "2"
msg = chr(27) + "[3" + code + "m" + msg + chr(27) + "[0m"
return msg
......@@ -28,25 +25,12 @@ def main():
rule = sys.argv[1]
paths = sys.argv[2:]
try:
with futures.ProcessPoolExecutor(max_workers=totalCPUs) as executor:
for result in executor.map(partial(make, rule), paths):
print "%40s: %s" % (result[3], colorMe(result[0],
'[OK]' if result[0]==0 else '[FAILED]'))
executor.map(partial(make, 'clean'), paths)
except NameError:
# no multiprocessing available
for path in paths:
sys.stdout.write('\033[0m')
sys.stdout.write(path[:-1] + ' ... ')
sys.stdout.flush()
result = make(rule, path)
make('clean', path)
with futures.ProcessPoolExecutor(max_workers=totalCPUs) as executor:
for result in executor.map(partial(make, rule), paths):
print("%40s: %s" % (result[3], colorMe(result[0],
'[OK]' if result[0]==0 else '[FAILED]')))
results.append(result)
sys.stdout.write('\033[1m\033[')
sys.stdout.write('32m[OK]\n' if result[0] == 0 else '31m[FAILED]\n')
sys.stdout.flush()
executor.map(partial(make, 'clean'), paths)
sys.stdout.write('\n')
elapsed = time.time() - start
......@@ -70,17 +54,17 @@ def summarize(results, elapsed):
if errcode == 0:
continue
failed += 1
print "======================================================================"
print "ERROR: %s %s" % (path, rule)
print("=" * 80)
print("ERROR: %s %s" % (path, rule))
if stdout:
print "- stdout -------------------------------------------------------------"
print stdout
print("-- stdout " + "-" * 70)
print(stdout)
if stderr:
print "- stderr -------------------------------------------------------------"
print stderr
print "----------------------------------------------------------------------"
print "Finished in %.3fs" % elapsed
print "%s tests, %s errors" % (len(results), failed)
print("-- stderr " + "-" * 70)
print(stderr)
print("-" * 80)
print("Finished in %.3fs" % elapsed)
print("%s tests, %s errors" % (len(results), failed))
return 0 if not failed else 1
......
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