Skip to content
0.2.0-dev Download ZIP
63 lines ·1.8 KB Raw
1#!/usr/bin/env python3
2
3if __name__ != "__main__":
4 raise ImportError(f"{__name__} should not be used as a module.")
5
6import os
7import sys
8from collections.abc import Callable
9from typing import Any
10
11sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), "../../"))
12
13from gles3_builders import build_gles3_header
14from glsl_builders import build_raw_header, build_rd_header
15
16FUNC_PATH_KWARGS: list[tuple[Callable[..., None], str, dict[str, Any]]] = [
17 (
18 build_gles3_header,
19 "tests/python_build/fixtures/gles3/vertex_fragment.out",
20 {"shader": "tests/python_build/fixtures/gles3/vertex_fragment.glsl"},
21 ),
22 (
23 build_raw_header,
24 "tests/python_build/fixtures/glsl/compute.out",
25 {"shader": "tests/python_build/fixtures/glsl/compute.glsl"},
26 ),
27 (
28 build_raw_header,
29 "tests/python_build/fixtures/glsl/vertex_fragment.out",
30 {"shader": "tests/python_build/fixtures/glsl/vertex_fragment.glsl"},
31 ),
32 (
33 build_rd_header,
34 "tests/python_build/fixtures/rd_glsl/compute.out",
35 {"shader": "tests/python_build/fixtures/rd_glsl/compute.glsl"},
36 ),
37 (
38 build_rd_header,
39 "tests/python_build/fixtures/rd_glsl/vertex_fragment.out",
40 {"shader": "tests/python_build/fixtures/rd_glsl/vertex_fragment.glsl"},
41 ),
42]
43
44
45def main() -> int:
46 ret = 0
47
48 for func, path, kwargs in FUNC_PATH_KWARGS:
49 if os.path.exists(out_path := os.path.abspath(path)):
50 with open(out_path, "rb") as file:
51 raw = file.read()
52 func(path, **kwargs)
53 with open(out_path, "rb") as file:
54 if raw != file.read():
55 ret += 1
56 else:
57 func(path, **kwargs)
58 ret += 1
59
60 return ret
61
62
63sys.exit(main())