Add cleanup and better formatting

multiline-output
drunkendog 2023-09-12 14:10:27 +01:00
parent 906c9df10d
commit d8ca74e6b1
1 changed files with 2 additions and 1 deletions

View File

@ -15,7 +15,7 @@ if sys.platform == "win32":
for file_name in glob.glob("*.c", recursive=False): for file_name in glob.glob("*.c", recursive=False):
if file_name.rstrip(".c") in file_only_list: if file_name.rstrip(".c") in file_only_list:
should_continue = input(f"{file_name}; run (y/N)?").lower() should_continue = input(f"{file_name}; run (y/N)? ").lower()
if should_continue != "y": if should_continue != "y":
continue continue
subprocess.run(["gcc", "-std=c11", "-Wall", "-g", file_name], check=True) subprocess.run(["gcc", "-std=c11", "-Wall", "-g", file_name], check=True)
@ -25,3 +25,4 @@ for file_name in glob.glob("*.c", recursive=False):
x_split = x.split("\n") x_split = x.split("\n")
return_data = subprocess.run(["./a.out"], input=x_split[0].rstrip().encode(), capture_output=True).stdout.decode().rstrip() return_data = subprocess.run(["./a.out"], input=x_split[0].rstrip().encode(), capture_output=True).stdout.decode().rstrip()
print(f"\u001b[{31 + int(return_data == x_split[1].rstrip())}m{return_data}\u001b[0m", x[1]) print(f"\u001b[{31 + int(return_data == x_split[1].rstrip())}m{return_data}\u001b[0m", x[1])
os.remove("a.out")