-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
50 lines (43 loc) · 1.77 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
from os import popen
from glob import glob
if __name__ == "__main__":
incorrect_programs, incorrect_programs_out = [
sorted(glob("tests/error/*.pyind")),
sorted(glob("tests/error/*.output")),
]
correct_programs, correct_programs_out = [
sorted(glob("tests/success/*.pyind")),
sorted(glob("tests/success/*.output")),
]
print("==============================")
print("[+] Testing incorrect programs")
print("==============================")
# Test all incorrect programs
for iteration, program, output in zip(
range(len(incorrect_programs)), incorrect_programs, incorrect_programs_out
):
program_out = popen(f"python3 main.py {program}").read().lstrip("\n")
expected_out = open(output, "r").read()
print(f"[{iteration + 1}] {program} ", end="")
if program_out == expected_out:
print("\033[92m(PASSED)\033[0m")
else:
print("\033[91m(FAIL)\033[0m")
print(f"Expected: `{expected_out}`")
print(f"Got: `{program_out}`", end="\n\n")
print("\n============================")
print("[+] Testing correct programs")
print("============================")
# Test all correct programs
for iteration, program, output in zip(
range(len(correct_programs)), correct_programs, correct_programs_out
):
program_out = popen(f"python3 main.py {program}").read().lstrip("\n")
expected_out = open(output, "r").read()
print(f"[{iteration + 1}] {program} ", end="")
if program_out == expected_out:
print("\033[92m(PASSED)\033[0m")
else:
print("\033[91m(FAIL)\033[0m")
print(f"Expected: `{expected_out}`")
print(f"Got: `{program_out}`", end="\n\n")