actually added conditional temmies cli support

This commit is contained in:
Boyan 2024-12-07 09:55:57 +01:00
parent bc7e232aeb
commit 1118341f26

View File

@ -17,7 +17,7 @@ def check_dependencies() -> None:
return return
def run_input_cases(program, args): def run_input_cases(program, args) -> bool:
verbose = args.verbose verbose = args.verbose
output = args.output output = args.output
tests_dir = args.tests_dir if args.tests_dir else "." 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: if program_output == expected_output:
print("✅") print("✅")
else: else:
passed = False
print("❌") print("❌")
passed = False
# green expected output and red program output # green expected output and red program output
print(f"{Fore.GREEN}Expected output:{Style.RESET_ALL}") print(f"{Fore.GREEN}Expected output:{Style.RESET_ALL}")
print(expected_output) print(expected_output)
@ -123,18 +123,16 @@ def run_input_cases(program, args):
return passed return passed
def python_compile(file_name, args): def python_compile(file_name, args) -> bool:
passed = None
try: try:
if os.system("which pypy3 &> /dev/null") == 0: if os.system("which pypy3 &> /dev/null") == 0:
print(f"{Fore.LIGHTMAGENTA_EX}Using pypy3{Style.RESET_ALL}") print(f"{Fore.LIGHTMAGENTA_EX}Using pypy3{Style.RESET_ALL}")
run_input_cases("pypy3 " + file_name, args) return run_input_cases("pypy3 " + file_name, args)
return
except Exception: except Exception:
pass pass
print(f"{Fore.MAGENTA}WARNING: pypy3 not found, using python3 instead{Style.RESET_ALL}") print(f"{Fore.MAGENTA}WARNING: pypy3 not found, using python3 instead{Style.RESET_ALL}")
run_input_cases("python3 " + file_name, args) return run_input_cases("python3 " + file_name, args)
return
def java_compile(file_name, args): def java_compile(file_name, args):
if args.alternative: if args.alternative:
@ -149,8 +147,7 @@ def java_compile(file_name, args):
def haskell_compile(file_name, args): def haskell_compile(file_name, args):
os.system("ghc -O2 " + file_name + " -o program") os.system("ghc -O2 " + file_name + " -o program")
run_input_cases("./program", args) return run_input_cases("./program", args)
return
def c_compile(file_name, args): def c_compile(file_name, args):
@ -220,7 +217,7 @@ def main():
temmies_check = os.path.join(os.path.dirname(file_name), ".temmies") temmies_check = os.path.join(os.path.dirname(file_name), ".temmies")
if os.path.exists(temmies_check): 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") os.system("temmies submit")
return return