| 1 |
#!/usr/bin/env python |
| 2 |
|
| 3 |
import os, sys |
| 4 |
from sys import platform |
| 5 |
|
| 6 |
num_tested = 0 |
| 7 |
num_errors = 0 |
| 8 |
|
| 9 |
def get_executable_path(name): |
| 10 |
if platform == "win32": |
| 11 |
return "build\\Debug\\" + name |
| 12 |
else: |
| 13 |
return "build/" + name |
| 14 |
|
| 15 |
def collect_files(path, type, name): |
| 16 |
global num_tested |
| 17 |
global num_errors |
| 18 |
exe = get_executable_path(name) |
| 19 |
for the_file in os.listdir(path): |
| 20 |
file_path = os.path.join(os.path.normpath(path), the_file) |
| 21 |
if os.path.isfile(file_path): |
| 22 |
if the_file.endswith(type): |
| 23 |
num_tested = num_tested +1 |
| 24 |
print("### " + name + " " + file_path) |
| 25 |
result = os.system("{0} \"{1}\"".format(exe, file_path)) |
| 26 |
print("### Result: " + str(result) + "\n") |
| 27 |
if result != 0: |
| 28 |
num_errors = num_errors + 1 |
| 29 |
print("Error.") |
| 30 |
sys.exit(1) |
| 31 |
elif os.path.isdir(file_path): |
| 32 |
collect_files(file_path, type, name) |
| 33 |
|
| 34 |
if __name__ == "__main__": |
| 35 |
if not os.path.exists("build/"): |
| 36 |
os.makedirs("build/") |
| 37 |
os.chdir("build/") |
| 38 |
os.system("cmake ..") |
| 39 |
if os.system("cmake --build .") != 0: |
| 40 |
print("Unable to build.") |
| 41 |
exit(1) |
| 42 |
os.chdir("..") |
| 43 |
if not os.path.exists("glTF-Sample-Models/"): |
| 44 |
os.system("git init glTF-Sample-Models") |
| 45 |
os.chdir("glTF-Sample-Models") |
| 46 |
os.system("git remote add origin https://github.com/KhronosGroup/glTF-Sample-Models.git") |
| 47 |
os.system("git config core.sparsecheckout true") |
| 48 |
f = open(".git/info/sparse-checkout", "w+") |
| 49 |
f.write("2.0/*\n") |
| 50 |
f.close() |
| 51 |
os.system("git pull --depth=1 origin master") |
| 52 |
os.chdir("..") |
| 53 |
collect_files("glTF-Sample-Models/2.0/", ".glb", "cgltf_test") |
| 54 |
collect_files("glTF-Sample-Models/2.0/", ".gltf", "cgltf_test") |
| 55 |
collect_files("glTF-Sample-Models/2.0/", ".glb", "test_conversion") |
| 56 |
collect_files("glTF-Sample-Models/2.0/", ".gltf", "test_conversion") |
| 57 |
collect_files("glTF-Sample-Models/2.0/", ".gltf", "test_write") |
| 58 |
|
| 59 |
result = os.system(get_executable_path("test_math")) |
| 60 |
if result != 0: |
| 61 |
num_errors = num_errors + 1 |
| 62 |
print("Error.") |
| 63 |
sys.exit(1) |
| 64 |
|
| 65 |
print("Tested files: " + str(num_tested)) |
| 66 |
print("Errors: " + str(num_errors)) |