+def clean_tests(makefile_paths):
+ cmds = [("make -j -C {} clean".format(path), path) for path in makefile_paths]
+
+ failed = 0
+ passed = 0
+
+ for cmd, is_successful, cmd_text, debug_info in run_cmds(cmds):
+ if not is_successful:
+ print("\033[41mtest failed to clean\033[0m {}".format(debug_info[0]))
+ failed += 1
+ else :
+ print("\033[42mtest cleaned successfully\033[0m {}".format(debug_info[0]))
+ passed += 1
+ if not failed:
+ print ("\n\033[42mAll tests cleaned successfully\033[0m")
+ else :
+ print ("\n\033[42mTests failed to clean successfully\033[0m")
+ print("ran {}, passed {}, failed {}".format(len(cmds), passed, failed))
+
+def run_tests(makefile_paths):
+ cmds = [("make -j -C {} test".format(path), path) for path in makefile_paths]
+
+ failed = 0
+ passed = 0
+
+ print("running tests")
+ for cmd, is_successful, cmd_text, debug_info in run_cmds(cmds):
+ if not is_successful:
+ print("\033[41mtest failed\033[0m {}".format(debug_info[0]))
+ failed += 1
+ else :
+ print("\033[42mtest passed\033[0m {}".format(debug_info[0]))
+ passed += 1
+ if not failed:
+ print ("\n\033[42mAll tests passed\033[0m")
+ else :
+ print ("\n\033[41mTests failed\033[0m")
+ print("ran {}, passed {}, failed {}".format(len(cmds), passed, failed))
+
+def run_cmds(cmds):
+ output = []
+ for cmd, *debug_info in cmds:
+ try:
+ subprocess.check_output(cmd, shell=True)
+ output.append((cmd, True, "todo add getting text for non failing test", debug_info))
+ except subprocess.CalledProcessError as e:
+ output.append((cmd, False, e.output.decode('UTF-8'), debug_info))
+ return output