From 673d0297aa7155f6dbdbdec2dbad9842e603b56e Mon Sep 17 00:00:00 2001 From: Boyan Date: Sat, 7 Dec 2024 09:43:35 +0100 Subject: [PATCH 1/5] Sorted the test cases by modified time --- ucompile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ucompile b/ucompile index 7b2158c..d06645b 100755 --- a/ucompile +++ b/ucompile @@ -23,8 +23,8 @@ def run_input_cases(program, args): tests_dir = args.tests_dir if args.tests_dir else "." time_flag = args.time - input_files = glob(os.path.join(tests_dir, "*.in")) - + input_files = sorted(glob(os.path.join(tests_dir, "*.in")), key=os.path.getmtime) + if len(input_files) < 1: if time_flag: start_time = time.perf_counter() From 8d424848639cc848968969571ddeeb2ea3fc3303 Mon Sep 17 00:00:00 2001 From: Boyan Date: Sat, 7 Dec 2024 09:49:35 +0100 Subject: [PATCH 2/5] Added conditional temmies support --- ucompile | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/ucompile b/ucompile index d06645b..86e7a58 100755 --- a/ucompile +++ b/ucompile @@ -25,6 +25,7 @@ def run_input_cases(program, args): input_files = sorted(glob(os.path.join(tests_dir, "*.in")), key=os.path.getmtime) + passed = True if len(input_files) < 1: if time_flag: start_time = time.perf_counter() @@ -96,6 +97,7 @@ def run_input_cases(program, args): if program_output == expected_output: print("✅") else: + passed = False print("❌") # green expected output and red program output print(f"{Fore.GREEN}Expected output:{Style.RESET_ALL}") @@ -118,7 +120,7 @@ def run_input_cases(program, args): print(f"⏳: {elapsed_time:.4f} s") print("-----------") - return + return failed def python_compile(file_name, args): @@ -213,7 +215,13 @@ def main(): args.tests_dir = args.tests if args.tests else "." - SUPPORTED_LANGS[file_ext](file_name, args) + if not SUPPORTED_LANGS[file_ext](file_name, args) # don't do submit dialogue if failed + return + + temmies_check = os.path.join(os.path.dirname(file_name), ".temmies") + if os.path.exists(temmies_check): + if input("Would you like to submit? (y/N): ") == "y": + os.system("temmies submit") return From 6ca7201203aec020b662fa7ef7cce0bfeb227c41 Mon Sep 17 00:00:00 2001 From: Boyan Date: Sat, 7 Dec 2024 09:49:52 +0100 Subject: [PATCH 3/5] stupid colon --- ucompile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ucompile b/ucompile index 86e7a58..92add3d 100755 --- a/ucompile +++ b/ucompile @@ -215,7 +215,7 @@ def main(): args.tests_dir = args.tests if args.tests else "." - if not SUPPORTED_LANGS[file_ext](file_name, args) # don't do submit dialogue if failed + if not SUPPORTED_LANGS[file_ext](file_name, args): # don't do submit dialogue if failed return temmies_check = os.path.join(os.path.dirname(file_name), ".temmies") From bc7e232aeb364a924774b2c157d824812653ef86 Mon Sep 17 00:00:00 2001 From: Boyan Date: Sat, 7 Dec 2024 09:50:15 +0100 Subject: [PATCH 4/5] gotta look thru my code b4 committing fr --- ucompile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ucompile b/ucompile index 92add3d..5dcc1e2 100755 --- a/ucompile +++ b/ucompile @@ -120,7 +120,7 @@ def run_input_cases(program, args): print(f"⏳: {elapsed_time:.4f} s") print("-----------") - return failed + return passed def python_compile(file_name, args): From 1118341f26b056a8e92ddaf44ac01a5aa362ca4c Mon Sep 17 00:00:00 2001 From: Boyan Date: Sat, 7 Dec 2024 09:55:57 +0100 Subject: [PATCH 5/5] actually added conditional temmies cli support --- ucompile | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/ucompile b/ucompile index 5dcc1e2..13dac60 100755 --- a/ucompile +++ b/ucompile @@ -17,7 +17,7 @@ def check_dependencies() -> None: return -def run_input_cases(program, args): +def run_input_cases(program, args) -> bool: verbose = args.verbose output = args.output tests_dir = args.tests_dir if args.tests_dir else "." @@ -97,8 +97,8 @@ def run_input_cases(program, args): if program_output == expected_output: print("✅") else: - passed = False print("❌") + passed = False # green expected output and red program output print(f"{Fore.GREEN}Expected output:{Style.RESET_ALL}") print(expected_output) @@ -123,18 +123,16 @@ def run_input_cases(program, args): return passed -def python_compile(file_name, args): +def python_compile(file_name, args) -> bool: + passed = None try: if os.system("which pypy3 &> /dev/null") == 0: print(f"{Fore.LIGHTMAGENTA_EX}Using pypy3{Style.RESET_ALL}") - run_input_cases("pypy3 " + file_name, args) - return + return run_input_cases("pypy3 " + file_name, args) except Exception: pass print(f"{Fore.MAGENTA}WARNING: pypy3 not found, using python3 instead{Style.RESET_ALL}") - run_input_cases("python3 " + file_name, args) - return - + return run_input_cases("python3 " + file_name, args) def java_compile(file_name, args): if args.alternative: @@ -149,8 +147,7 @@ def java_compile(file_name, args): def haskell_compile(file_name, args): os.system("ghc -O2 " + file_name + " -o program") - run_input_cases("./program", args) - return + return run_input_cases("./program", args) def c_compile(file_name, args): @@ -220,7 +217,7 @@ def main(): temmies_check = os.path.join(os.path.dirname(file_name), ".temmies") if os.path.exists(temmies_check): - if input("Would you like to submit? (y/N): ") == "y": + if input("🎉✨ -- Submit? (y/N): ") == "y": os.system("temmies submit") return