This commit is contained in:
Boyan 2025-03-17 17:50:48 +01:00
parent 5dbf86164a
commit 30ecc9b87c

View File

@ -13,7 +13,7 @@ def check_dependencies() -> None:
for command in commands: for command in commands:
if os.system(f"which {command} > /dev/null") != 0: if os.system(f"which {command} > /dev/null") != 0:
print(f"{Fore.RED}WARNING: {command} not found{Style.RESET_ALL}") print(f"{Fore.ORANGE}WARNING: {command} not found{Style.RESET_ALL}")
return return
@ -100,10 +100,18 @@ def run_input_cases(program, args) -> bool:
print("❌") print("❌")
passed = False 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)
print(f"{Fore.RED}Program output:{Style.RESET_ALL}") # print(f"{Fore.RED}Program output:{Style.RESET_ALL}")
print(program_output.strip()) # print(program_output.strip())
# print a diff
print(f"{Fore.YELLOW}Diff:{Style.RESET_ALL}")
# temporary file to store program output
with open("temp", "w") as f:
f.write(program_output)
os.system(f"diff -u {out_file} - < temp")
os.remove("temp")
else: else:
print( print(
f"{Fore.YELLOW}Expected output file not found; cannot compare outputs.{Style.RESET_ALL}" f"{Fore.YELLOW}Expected output file not found; cannot compare outputs.{Style.RESET_ALL}"
@ -152,10 +160,15 @@ def haskell_compile(file_name, args):
def c_compile(file_name, args): def c_compile(file_name, args):
# Style the code in Meijster's way # Style the code in Meijster's way
os.system("astyle -A2s2cxgk3W3xbj " + file_name) # os.system("astyle -A2s2cxgk3W3xbj " + file_name)
os.system( # If you want
"gcc -Wall -pedantic --std=c99 -g -o program -lm -Wno-unused-result " + file_name
) # stop if compilation fails
if os.system(
"gcc -Wall -pedantic --std=c99 -g -o program -pthread -lm -Wno-unused-result " + file_name
):
return False
run_input_cases("./program", args) run_input_cases("./program", args)
return return