Extend unit testing support in Trinity - #79
Draft
filipppavlov wants to merge 9 commits into
Draft
Conversation
…that require a metal compiler on Windows - it is not available on agents
There was a problem hiding this comment.
🟡 Changes recommended
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR aims to enable existing GoogleTest-based tests to run in TC builds by turning on CTest at the top level and registering test executables via gtest_discover_tests, while also skipping Metal-dependent shadercompiler tests when the Metal toolchain isn’t available.
Changes:
- Enable CTest (
enable_testing()) when building as the top-level project. - Register test executables with CTest using
gtest_discover_tests(TrinityAL tests + ShaderCompiler tests). - Add a
g_metalCompilerAvailableflag and use it toGTEST_SKIP()Metal-dependent tests when the Metal compiler isn’t available (primarily on Windows).
File summaries
| File | Description |
|---|---|
CMakeLists.txt |
Enables testing when the project is top-level. |
trinityal/tests/CMakeLists.txt |
Registers TrinityAL DX11/DX12 tests via gtest_discover_tests. |
shadercompiler/CMakeLists.txt |
Registers ShaderCompiler tests via gtest_discover_tests. |
shadercompiler/tests/TesingUtils.h |
Exposes g_metalCompilerAvailable for test files. |
shadercompiler/tests/ShaderCompilerTest.cpp |
Implements Windows-side Metal compiler availability detection. |
shadercompiler/tests/RayTracingTest.cpp |
Skips Metal-compiler-dependent typed tests when unavailable. |
shadercompiler/tests/MetalConversionTest.cpp |
Skips Metal conversion tests when the Metal compiler is unavailable. |
shadercompiler/EffectCompilerMetal.cpp |
Minor Windows command string construction fix for Metal tool path. |
Review details
Suppressed comments (1)
trinityal/tests/CMakeLists.txt:261
gtest_discover_tests()requires CMake'sGoogleTestmodule (include(GoogleTest)). Without it, configuration fails with "Unknown CMake command "gtest_discover_tests"" when BUILD_DX11 is off but BUILD_DX12 is on.
#GTest
set_target_properties(TrinityALTest_dx12 PROPERTIES FOLDER "Tests")
gtest_discover_tests(TrinityALTest_dx12)
- Files reviewed: 8/8 changed files
- Comments generated: 3
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…cies doesn't seem to work for Ninja
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Improve the usage of unit tests for Trinity.
Existing C++ tests
Unify
BUILD_TESTINGoption handling (enabled when Trinity is built as a top-level project). Make TrinityAL and ShaderCompiler tests discoverable by CTest. As the result, these tests will be run on TeamCity when building Trinity.Because of the current hardware configuration of TC agents, any TrinityAL tests for HW ray tracing are marked as "skipped" if the device does not support ray tracing.
ShaderCompiler tests requiring Metal toolchain on Windows are also skipped if the toolchain is not found (that's the case for TC agents).
Python tests
This PR adds support for Trinity tests written in Python. Test sources are supposed to live in
trinity/tests/Python/testsdirectory. Just like existing C++ tests, they are discovered and run on TC.Because the majority of the team is using Visual Studio with generated solutions for development, it was important to make these tests compatible with Visual Studio Test Explorer. The Explorer does not support CTest tests when working with solutions. To work around it, Python tests are wrapped in a Google Test -like C++ application that simply launcher exefile Python interpreter to discover/run the tests; see
GTestAdapter.cppfile. This launcher executesgtest_reporter.pyfile (AI-generated) that usesstandard Python ' unittest ' module to discover and run tests while mimicking the Google Test interface.With this hack, we are able to interact with Python tests from Visual Studio Test Explorer to run these tests.