-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_tests.py
executable file
·65 lines (52 loc) · 1.72 KB
/
run_tests.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env python
import os, subprocess
# Go to base dir
os.chdir(os.path.dirname(os.path.realpath(__file__)))
if not os.path.exists("./build"):
subprocess.run(["cmake", "-Bbuild", "-DDUSK_ENABLE_SANITIZERS=ON", "-DCMAKE_BUILD_TYPE=Debug", os.getcwd()])
subprocess.run(["cmake", "--build", "build"])
if os.name == "nt":
if os.path.exists("build/duskc.exe"):
compiler_exe = "build/duskc.exe"
elif os.path.exists("build/Debug/duskc.exe"):
compiler_exe = "build/Debug/duskc.exe"
elif os.path.exists("build/Release/duskc.exe"):
compiler_exe = "build/Release/duskc.exe"
else:
compiler_exe = "./build/duskc"
def run_proc(cmd_line):
print("Running:", cmd_line)
return subprocess.run(cmd_line.split(" ")).returncode == 0
tests = []
for filename in os.listdir("./tests/"):
if not filename.endswith(".dusk"):
continue
test_name = os.path.splitext(filename)[0]
tests.append(test_name)
tests.sort()
failed_tests = []
for test_name in tests:
print(f"\n=> Testing: {test_name}")
in_path = f"tests/{test_name}.dusk"
out_path = f"tests/out/{test_name}.spv"
success = run_proc(f"{compiler_exe} {in_path} -o {out_path}")
if test_name.startswith("valid"):
if not success:
failed_tests.append(test_name)
continue
success = run_proc(f"spirv-val {out_path}")
if not success:
failed_tests.append(test_name)
continue
elif test_name.startswith("invalid"):
if success:
failed_tests.append(test_name)
continue
if len(failed_tests) > 0:
print("Tests failed:")
for f in failed_tests:
print(f)
exit(1)
else:
print("All tests passed")
exit(0)