updated run_CI_tests.py
This commit is contained in:
@@ -22,72 +22,72 @@ from time import sleep;
|
|||||||
# Override system command.
|
# Override system command.
|
||||||
# run command. if not successful, complain and exit with error
|
# run command. if not successful, complain and exit with error
|
||||||
def eval_cmd(cmd):
|
def eval_cmd(cmd):
|
||||||
# print cmd
|
# print cmd
|
||||||
res = subprocess.call (cmd, shell=True)
|
res = subprocess.call (cmd, shell=True)
|
||||||
if res < 0:
|
if res < 0:
|
||||||
print "Failed running: %s" % (cmd)
|
print "Failed running: %s" % (cmd)
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def eval_cmd_output(cmd):
|
def eval_cmd_output(cmd):
|
||||||
# print cmd
|
# print cmd
|
||||||
p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||||
if p:
|
if p:
|
||||||
return p.communicate()[0]
|
return p.communicate()[0]
|
||||||
else:
|
else:
|
||||||
print "Failed running: %s" % (cmd)
|
print "Failed running: %s" % (cmd)
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
|
|
||||||
def rm_dir(d):
|
def rm_dir(d):
|
||||||
if os.path.isdir(d):
|
if os.path.isdir(d):
|
||||||
shutil.rmtree(d)
|
shutil.rmtree(d)
|
||||||
|
|
||||||
|
|
||||||
def runTestForProject(where):
|
def runTestForProject(where):
|
||||||
if not os.path.isdir(where):
|
if not os.path.isdir(where):
|
||||||
print "Directory %s does not exist" % (where)
|
print "Directory %s does not exist" % (where)
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
|
|
||||||
os.chdir(where)
|
os.chdir(where)
|
||||||
# First we have to remove old compilation
|
# First we have to remove old compilation
|
||||||
clobber = len(sys.argv) >= 2 and sys.argv[1] == "-clobber"
|
clobber = len(sys.argv) >= 2 and sys.argv[1] == "-clobber"
|
||||||
if clobber:
|
if clobber:
|
||||||
rm_dir("EIFGENs")
|
rm_dir("EIFGENs")
|
||||||
|
|
||||||
# compile the library
|
# compile the library
|
||||||
cmd = "ecb -config %s -target restbucks -batch -c_compile -project_path . " % (os.path.join ("examples", "restbucks", "restbucks-safe.ecf"))
|
cmd = "ecb -config %s -target restbucks -batch -c_compile -project_path . " % (os.path.join ("examples", "restbucks", "restbucks-safe.ecf"))
|
||||||
res = eval_cmd(cmd)
|
res = eval_cmd(cmd)
|
||||||
|
|
||||||
sleep(1)
|
sleep(1)
|
||||||
|
|
||||||
if sys.platform == 'win32':
|
if sys.platform == 'win32':
|
||||||
cmd = "tests\\check_compilations.bat"
|
cmd = "tests\\check_compilations.bat"
|
||||||
else:
|
else:
|
||||||
cmd = "tests//check_compilations.sh"
|
cmd = "tests//check_compilations.sh"
|
||||||
if clobber:
|
if clobber:
|
||||||
cmd = "%s -clean" % (cmd)
|
cmd = "%s -clean" % (cmd)
|
||||||
res_output = eval_cmd_output(cmd)
|
res_output = eval_cmd_output(cmd)
|
||||||
|
|
||||||
lines = re.split ("\n", res_output)
|
lines = re.split ("\n", res_output)
|
||||||
regexp = "^(\S+)\s+(\S+)\s+from\s+(\S+)\s+\(([^\)]+)\)\.\.\.(\S+)$"
|
regexp = "^(\S+)\s+(\S+)\s+from\s+(\S+)\s+\(([^\)]+)\)\.\.\.(\S+)$"
|
||||||
p = re.compile (regexp);
|
p = re.compile (regexp);
|
||||||
failures = [];
|
failures = [];
|
||||||
non_failures = [];
|
non_failures = [];
|
||||||
for line in lines:
|
for line in lines:
|
||||||
p_res = p.search(line.strip(), 0)
|
p_res = p.search(line.strip(), 0)
|
||||||
if p_res:
|
if p_res:
|
||||||
# name, target, ecf, result
|
# name, target, ecf, result
|
||||||
if p_res.group(5) == "Failed":
|
if p_res.group(5) == "Failed":
|
||||||
failures.append ({"name": p_res.group(2), "target": p_res.group(3), "ecf": p_res.group(4), "result": p_res.group(5)})
|
failures.append ({"name": p_res.group(2), "target": p_res.group(3), "ecf": p_res.group(4), "result": p_res.group(5)})
|
||||||
else:
|
else:
|
||||||
non_failures.append ({"name": p_res.group(2), "target": p_res.group(3), "ecf": p_res.group(4), "result": p_res.group(5)})
|
non_failures.append ({"name": p_res.group(2), "target": p_res.group(3), "ecf": p_res.group(4), "result": p_res.group(5)})
|
||||||
for non_fails in non_failures:
|
for non_fails in non_failures:
|
||||||
print "[%s] %s : %s @ %s" % (non_fails["result"], non_fails["name"], non_fails["ecf"], non_fails["target"])
|
print "[%s] %s : %s @ %s" % (non_fails["result"], non_fails["name"], non_fails["ecf"], non_fails["target"])
|
||||||
for fails in failures:
|
for fails in failures:
|
||||||
print "[FAILURE] %s : %s @ %s" % (fails["name"], fails["ecf"], fails["target"])
|
print "[FAILURE] %s : %s @ %s" % (fails["name"], fails["ecf"], fails["target"])
|
||||||
sleep(1)
|
sleep(1)
|
||||||
if len(failures) > 0:
|
if len(failures) > 0:
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
runTestForProject(os.path.join (os.getcwd(), '..'))
|
runTestForProject(os.path.join (os.getcwd(), '..'))
|
||||||
|
|||||||
Reference in New Issue
Block a user