test_glsl_builder.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import json
  2. import pytest
  3. from glsl_builders import RAWHeaderStruct, RDHeaderStruct, build_raw_header, build_rd_header
  4. @pytest.mark.parametrize(
  5. [
  6. "shader_files",
  7. "builder",
  8. "header_struct",
  9. ],
  10. [
  11. ("glsl/vertex_fragment", build_raw_header, RAWHeaderStruct),
  12. ("glsl/compute", build_raw_header, RAWHeaderStruct),
  13. ("rd_glsl/vertex_fragment", build_rd_header, RDHeaderStruct),
  14. ("rd_glsl/compute", build_rd_header, RDHeaderStruct),
  15. ],
  16. indirect=["shader_files"],
  17. )
  18. def test_glsl_builder(shader_files, builder, header_struct):
  19. header = header_struct()
  20. builder(shader_files["path_input"], header_data=header)
  21. with open(shader_files["path_expected_parts"], "r", encoding="utf-8") as f:
  22. expected_parts = json.load(f)
  23. assert expected_parts == header.__dict__
  24. with open(shader_files["path_output"], "r", encoding="utf-8") as f:
  25. actual_output = f.read()
  26. assert actual_output
  27. with open(shader_files["path_expected_full"], "r", encoding="utf-8") as f:
  28. expected_output = f.read()
  29. assert actual_output == expected_output