refactor: move run_tests.py to tests/ and fix integration test GT.ppm paths

This commit is contained in:
2026-03-22 20:37:13 +08:00
parent 74adeb74a0
commit 50b50d06a0
3 changed files with 35 additions and 34 deletions

View File

@@ -29,12 +29,6 @@ target_link_libraries(D3D12_Minimal PRIVATE
XCEngine
)
add_custom_command(TARGET D3D12_Minimal POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_CURRENT_SOURCE_DIR}/Res
$<TARGET_FILE_DIR:D3D12_Minimal>/Res
)
add_custom_command(TARGET D3D12_Minimal POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_SOURCE_DIR}/tests/RHI/D3D12/integration/compare_ppm.py

View File

@@ -38,15 +38,7 @@ target_include_directories(d3d12_engine_tests PRIVATE
${PROJECT_ROOT_DIR}/engine/src
)
target_compile_definitions(d3d12_engine_tests PRIVATE
TEST_RESOURCES_DIR="${PROJECT_ROOT_DIR}/tests/RHI/D3D12/integration/minimal/Res"
)
add_custom_command(TARGET d3d12_engine_tests POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${PROJECT_ROOT_DIR}/tests/RHI/D3D12/integration/minimal/Res
$<TARGET_FILE_DIR:d3d12_engine_tests>/Res
)
enable_testing()
add_test(NAME D3D12EngineTests COMMAND d3d12_engine_tests)

View File

@@ -261,8 +261,9 @@ class TestRunner:
}
def run_integration_tests(self) -> bool:
integration_dir = (
self.build_dir / "tests" / "RHI" / "D3D12" / "integration" / "Debug"
integration_dir = self.build_dir / "tests" / "RHI" / "D3D12" / "integration"
integration_src_dir = (
self.source_dir / "tests" / "RHI" / "D3D12" / "integration"
)
if not integration_dir.exists():
@@ -273,14 +274,26 @@ class TestRunner:
self._log_header("Running Integration Tests")
minimal_exe = integration_dir / "D3D12_Minimal.exe"
gt_minimal = (
self.source_dir / "tests" / "RHI" / "D3D12" / "integration" / "GT.ppm"
)
integration_tests = [
("D3D12_Minimal_Integration", "minimal", "minimal.ppm"),
("D3D12_Sphere_Integration", "sphere", "sphere.ppm"),
("D3D12_Triangle_Integration", "triangle", "triangle.ppm"),
("D3D12_Quad_Integration", "quad", "quad.ppm"),
]
if minimal_exe.exists() and gt_minimal.exists():
all_passed = True
for test_name, test_folder, output_ppm in integration_tests:
exe_path = (
integration_dir
/ test_folder
/ "Debug"
/ f"D3D12_{test_folder.title()}.exe"
)
gt_ppm = integration_src_dir / test_folder / "GT.ppm"
if exe_path.exists() and gt_ppm.exists():
result = self._run_integration_test(
"D3D12_Minimal_Integration", minimal_exe, "minimal.ppm", gt_minimal, 5
test_name, exe_path, output_ppm, gt_ppm, 0
)
self.results.append(result)
@@ -288,13 +301,15 @@ class TestRunner:
self._log_error(f"Failed: {result['name']}")
if self.verbose:
self._log_info(result.get("output", ""))
return False
all_passed = False
else:
self._log_success(f"Passed: {result['name']} ({result['time']:.2f}s)")
return True
self._log_success(
f"Passed: {result['name']} ({result['time']:.2f}s)"
)
else:
self._log_warning("D3D12_Minimal.exe not found, skipping integration test")
return True
self._log_warning(f"{test_name} not found, skipping")
return all_passed
def _summarize_results(self):
self._log_header("Test Summary")