-
Notifications
You must be signed in to change notification settings - Fork 3
/
test.py
39 lines (33 loc) · 1.27 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
import os
import sys
import subprocess
all_examples = [x for x in os.listdir("./examples") if x.endswith(".vasm")]
ignore_direct_execution = ["consts.vasm"]
exit_code = 0
error_count = 0
for example_file in all_examples:
if example_file in ignore_direct_execution:
continue
print("---------------------------")
print(f"Executing: {example_file}")
process = subprocess.Popen(['./vm-go', '-i', f"examples/{example_file}"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = process.communicate()
file_content = open(f"./tests/expected/{example_file.removesuffix('.vasm')}.expected").read()
try:
print(f"Testing : {example_file}",end="")
assert stdout.decode("utf-8") == file_content, "TestFail"
print("...Ok")
except Exception as e:
print("\n")
print("stdout:")
print()
print(stdout.decode("utf-8"))
error_count = error_count + 1
print("---------------------------")
if error_count > 0:
exit_code = 1
print("-----\nSTATS\n-----")
print(f"Total : {len(all_examples) - len(ignore_direct_execution)}")
print(f"Passed : {len(all_examples) - len(ignore_direct_execution) - error_count}")
print(f"Failed : {error_count}")
sys.exit(exit_code)