-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
36 lines (29 loc) · 1 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
import subprocess
flag = 0
for i in range(1, 23):
try:
# Run the highway.exe program with input file
process = subprocess.Popen(
["./Series3/visit.exe"],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True,
)
with open(f"visit/input{i}.txt", "r") as input_file:
program_output, stderr = process.communicate(input=input_file.read())
expected_output = open(f"visit/output{i}.txt", "r").read()
if process.returncode != 0 or program_output != expected_output:
flag = 1
print(f"Input {i}:")
print(f"Expected {expected_output.strip()}")
print(f"But got {program_output.strip()}")
print("-------")
except Exception as e:
flag = 1
print(f"Error while processing input {i}: {str(e)}")
print("-------")
if flag == 0:
print("Everything is good")
else:
print("There were issues")