From f553596f870d0d9eabee871009fc9a089f8eddb1 Mon Sep 17 00:00:00 2001 From: Maximilien Rigaut Date: Fri, 24 Jun 2022 04:38:01 +0200 Subject: [PATCH] It's not ok, but it works --- modules/main_runner.py | 41 ++++++++++++++++++++++++++++++++++------ modules/test_template.py | 1 + 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/modules/main_runner.py b/modules/main_runner.py index cfca3ac..4551b70 100644 --- a/modules/main_runner.py +++ b/modules/main_runner.py @@ -14,7 +14,7 @@ argparse argument : [module_name, class_name] """ _TEST_MODULES = { "spidey": ["spidey_test", "SpideyTest"], - # "test_walk": ["test_template", "TestWalkTemplate"], + #"test_walk": ["test_template", "TestWalkTemplate"], } PROGRAM_VERSION = "1.0.0" @@ -22,6 +22,28 @@ POST_RUN_ALLOWED = False queue_lock = threading.Lock() +CLEAR_CODE = r""" + _______ _ +(_______) | + _ | | _____ _____ ____ +| | | || ___ (____ |/ ___) +| |_____| || ____/ ___ | | + \______)\_)_____)_____|_| + """ + +INFECTED_CODE = r""" + _ ___ _ +| | / __) _ | | +| |____ _| |__ _____ ____ _| |_ _____ __| | +| | _ (_ __) ___ |/ ___|_ _) ___ |/ _ | +| | | | || | | ____( (___ | |_| ____( (_| | +|_|_| |_||_| |_____)\____) \__)_____)\____| +""" + +if os.name == "nt": + CLEAR_CODE = r"" + CLEAR_CODE + r"" + INFECTED_CODE = r"" + INFECTED_CODE + r"" + class TestRunner: def __init__(self, args, agnpath): @@ -250,22 +272,29 @@ def run_check(args, agnpath): time.sleep(0.5) print("The test sequence is now finished") - print(tr.get_status()) # TODO: Print the final status, test still running are actually skipped + status = tr.get_status() + print(status) # TODO: Print the final status, test still running are actually skipped + if status.tests_failed > 0: + print(INFECTED_CODE) + tr.is_infected = True + else: + print(CLEAR_CODE) + tr.is_infected = False + if args.gen_data: print("Generating data...") data = tr.get_test_data() - print("Making folder...") file_path = os.path.join(os.path.join("databases", args.gen_data[0])) folder = os.path.dirname(file_path) if not os.path.exists(folder): + print("Making folder...") os.makedirs(args.gen_data) - print("Exporting data...") + print("Exporting data...") # TODO : Advertize where the data is exported main_data = export_data(tr, data) # print(main_data) with open(file_path, "w") as f: json.dump(main_data, f, indent=4) - # print(tr.get_test_data()) # TODO: Transorm the data into a yaml or json file - print(f"Exiting in {args.timeout}...") + print(f"Exiting in {args.timeout} seconds...") time.sleep(args.timeout) sys.exit(tr.get_exit_code()) diff --git a/modules/test_template.py b/modules/test_template.py index 92cbba0..fdf2a84 100644 --- a/modules/test_template.py +++ b/modules/test_template.py @@ -205,6 +205,7 @@ class TestWalkTemplate(TestTemplate): self.set_status("running", "The test will begin shortly, please wait...") for path in self.walk(): + print(path) if not self.compare(path, "test", lambda x: True, [], {}): self.add_failure(path, f"Test {self.name()} failed on {path}") if not self.args.continue_on_error: