renderdiff: add a filter option for local testing (#9257)

This option will allow for rendering and comparing a single
image or files that match a wildcard-style string.

README.md has been updated
This commit is contained in:
Powei Feng
2025-09-25 21:18:35 +00:00
committed by GitHub
parent a1b825b5b4
commit f233b20427
5 changed files with 137 additions and 95 deletions
+11 -2
View File
@@ -18,6 +18,8 @@ import json
import glob
import shutil
import concurrent.futures
import fnmatch
from utils import execute, ArgParseImpl, mkdir_p, mv_f, important_print
@@ -80,7 +82,8 @@ def _render_test_config(gltf_viewer,
output_dir,
local_only=False,
opengl_lib=None,
vk_icd=None):
vk_icd=None,
test_filter=None):
assert os.path.isdir(output_dir), f"output directory {output_dir} does not exist"
assert os.access(gltf_viewer, os.X_OK)
@@ -103,6 +106,10 @@ def _render_test_config(gltf_viewer,
if backend == 'vulkan':
assert vk_icd, "VK ICD must be specified when testing vulkan backend"
for model in test.models:
test_name = f'{test.name}.{backend}.{model}'
if test_filter and not fnmatch.fnmatch(test_name, test_filter):
print(f'Skipping {test_name} because it does not match filter')
continue
model_path = os.path.abspath(test_config.models[model])
futures.append(
executor.submit(_render_single_model, gltf_viewer_abs,
@@ -122,6 +129,7 @@ if __name__ == "__main__":
parser.add_argument('--output_dir', help='Output Directory', required=True)
parser.add_argument('--opengl_lib', help='Path to the folder containing OpenGL driver lib (for LD_LIBRARY_PATH)')
parser.add_argument('--vk_icd', help='Path to VK ICD file')
parser.add_argument('--test_filter', help='Filter for the tests to run')
args, _ = parser.parse_known_args(sys.argv[1:])
test = test_config.parse_from_path(args.test)
@@ -131,7 +139,8 @@ if __name__ == "__main__":
test,
args.output_dir,
opengl_lib=args.opengl_lib,
vk_icd=args.vk_icd)
vk_icd=args.vk_icd,
test_filter=args.test_filter)
with open(f'{output_dir}/render_results.json', 'w') as f:
f.write(json.dumps(results, indent=2))