-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathintegration_test.py
More file actions
72 lines (54 loc) · 1.99 KB
/
integration_test.py
File metadata and controls
72 lines (54 loc) · 1.99 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import subprocess
def run_command(command):
try:
# Run the command and capture the output
result = subprocess.run(command, text=True, capture_output=True, shell=True)
# Get the stdout and stderr
stdout = result.stdout
stderr = result.stderr
return stdout, stderr, result.returncode
except Exception as e:
return None, str(e), -1
def read_file(file_path):
try:
with open(file_path, 'r') as file:
content = file.read()
return content, None
except Exception as e:
return None, str(e)
def run_test(file_name):
psx_file_name = file_name+".psx"
expected_path = "./test/integration_test/expected_files/"+file_name+".c"
actual_path ="./test/integration_test/actual_files/output_"+file_name+".c"
# Execute the the test
stdout, stderr, status = run_command("make int_test " + psx_file_name)
# print(stdout)
if stderr:
print("Error while executing make command:", stderr)
# Read the file
actual_content, actual_error = read_file(actual_path)
expected_content, expected_error = read_file(expected_path)
if actual_error:
print("Error while reading actual file:", actual_error)
elif expected_error:
print("Error while reading expected file:", expected_error)
else:
# Check if the specific string is part of the file content
if expected_content in actual_content:
print("Specific output block found in file content.")
print("test passed")
else:
print("Specific output block not found in file content.")
print("Exit status:", status)
def main():
# Make main
stdout, stderr, status = run_command("make all")
print(stdout)
if stderr:
print("Error while executing make command:", stderr)
run_test("test_sum")
run_test("test_class")
run_test("test_arrays")
#run_test("")
if __name__ == "__main__":
main()