Skip to content

Extend unit testing support in Trinity - #79

Draft
filipppavlov wants to merge 9 commits into
mainfrom
tests
Draft

Extend unit testing support in Trinity#79
filipppavlov wants to merge 9 commits into
mainfrom
tests

Conversation

@filipppavlov

@filipppavlov filipppavlov commented Aug 31, 2026

Copy link
Copy Markdown

Improve the usage of unit tests for Trinity.

  • Add test discovery to CMake to allow unit tests to be executed during build time on TeamCity
  • Add support for Python tests against Trinity

Existing C++ tests

Unify BUILD_TESTING option 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/tests directory. 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.cpp file. This launcher executes gtest_reporter.py file (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.

…that require a metal compiler on Windows - it is not available on agents
Copilot AI lite review requested due to automatic review settings August 31, 2026 14:23

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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_metalCompilerAvailable flag and use it to GTEST_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's GoogleTest module (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.

Comment thread shadercompiler/tests/ShaderCompilerTest.cpp
Comment thread trinityal/tests/CMakeLists.txt Outdated
Comment thread shadercompiler/CMakeLists.txt Outdated
@filipppavlov filipppavlov changed the title Add tests to trinity Extend unit testing support in Trinity Sep 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants