[Test] (CMake, CI): enable top-level testing and label tests (unit/benchmark/integration) so ctest runs from the build root

This commit is contained in:
2026-07-18 11:37:56 -04:00
parent 1d947d934b
commit 626c7f26fd
15 changed files with 32 additions and 20 deletions
+6 -5
View File
@@ -107,6 +107,7 @@ jobs:
--exclude='build.ninja' \
--exclude='cmake_install.cmake' \
-czf ci-artifacts/mobilegl-linux-runtime.tgz \
"${BUILD_DIR}/CTestTestfile.cmake" \
"${BUILD_DIR}/MobileGL/MG_Test" \
"${BUILD_DIR}/MobileGL/MG_Benchmark" \
"${SHARED_LIBS[@]}"
@@ -156,12 +157,12 @@ jobs:
PY
- name: Test
working-directory: build-linux/MobileGL/MG_Test
working-directory: build-linux
run: |
if [ "${{ secrets.ACTIONS_STEP_DEBUG }}" = "true" ]; then
ctest -V
ctest -V -L unit --no-tests=error
else
ctest --output-on-failure
ctest --output-on-failure -L unit --no-tests=error
fi
benchmark:
@@ -202,8 +203,8 @@ jobs:
PY
- name: Benchmark
working-directory: build-linux/MobileGL/MG_Benchmark
run: ctest -V -C Release
working-directory: build-linux
run: ctest -V -C Release -L benchmark --no-tests=error
build-retrace:
runs-on: ubuntu-latest
+9 -1
View File
@@ -476,6 +476,15 @@ if (NOT ANDROID AND NOT MOBILEGL_IOS)
endif ()
if (NOT ANDROID)
# Enable testing in the top-level scope so a CTestTestfile.cmake is emitted
# at the build-tree root. This lets `ctest` be invoked from the top-level
# build directory (IDE "run all tests", CI) and discover every test in the
# subdirectories below, instead of having to descend into each
# MG_Test/MG_Benchmark subdirectory. Tests are tagged with CTest labels
# (unit / benchmark / integration), so e.g. `ctest -L unit` selects just
# the unit suite.
enable_testing()
if (MOBILEGL_BUILD_TEST)
add_subdirectory(MobileGL/MG_Test)
endif()
@@ -485,7 +494,6 @@ if (NOT ANDROID)
endif()
if (MOBILEGL_BUILD_TRACE_REPLAY)
enable_testing()
add_subdirectory(tools/trace_replay)
endif()
endif()
+2 -1
View File
@@ -16,4 +16,5 @@ target_link_libraries(
${LINK_LIBRARIES}
)
add_test(NAME BufferBench COMMAND BufferBench --benchmark_counters_tabular=true)
add_test(NAME BufferBench COMMAND BufferBench --benchmark_counters_tabular=true)
set_tests_properties(BufferBench PROPERTIES LABELS benchmark)
+1
View File
@@ -38,6 +38,7 @@ target_link_libraries(
)
add_test(NAME SanityBench COMMAND SanityBench --benchmark_counters_tabular=true)
set_tests_properties(SanityBench PROPERTIES LABELS benchmark)
add_subdirectory(Program)
add_subdirectory(Buffer)
+2 -1
View File
@@ -16,4 +16,5 @@ target_link_libraries(
${LINK_LIBRARIES}
)
add_test(NAME ProgramBench COMMAND ProgramBench --benchmark_counters_tabular=true)
add_test(NAME ProgramBench COMMAND ProgramBench --benchmark_counters_tabular=true)
set_tests_properties(ProgramBench PROPERTIES LABELS benchmark)
@@ -49,7 +49,7 @@ endif()
target_compile_definitions(DirectVulkanSanityTest PRIVATE -DNOMINMAX)
include(GoogleTest)
gtest_discover_tests(DirectVulkanSanityTest DISCOVERY_TIMEOUT 30)
gtest_discover_tests(DirectVulkanSanityTest DISCOVERY_TIMEOUT 30 PROPERTIES LABELS integration)
add_executable(
DirectVulkanTestExec
@@ -17,4 +17,4 @@ target_link_libraries(
)
include(GoogleTest)
gtest_discover_tests(BackendLoaderTest DISCOVERY_TIMEOUT 30)
gtest_discover_tests(BackendLoaderTest DISCOVERY_TIMEOUT 30 PROPERTIES LABELS unit)
+1 -1
View File
@@ -24,4 +24,4 @@ if (MSVC)
endif()
include(GoogleTest)
gtest_discover_tests(BufferTest DISCOVERY_TIMEOUT 30)
gtest_discover_tests(BufferTest DISCOVERY_TIMEOUT 30 PROPERTIES LABELS unit)
+1 -1
View File
@@ -62,7 +62,7 @@ set(LINK_LIBRARIES
)
include(GoogleTest)
gtest_discover_tests(SanityTest DISCOVERY_TIMEOUT 30)
gtest_discover_tests(SanityTest DISCOVERY_TIMEOUT 30 PROPERTIES LABELS unit)
add_subdirectory(BackendLoader)
add_subdirectory(Buffer)
+1 -1
View File
@@ -17,4 +17,4 @@ target_link_libraries(
)
include(GoogleTest)
gtest_discover_tests(EGLStateTest DISCOVERY_TIMEOUT 30)
gtest_discover_tests(EGLStateTest DISCOVERY_TIMEOUT 30 PROPERTIES LABELS unit)
+1 -1
View File
@@ -17,4 +17,4 @@ target_link_libraries(
)
include(GoogleTest)
gtest_discover_tests(FramebufferTest DISCOVERY_TIMEOUT 30)
gtest_discover_tests(FramebufferTest DISCOVERY_TIMEOUT 30 PROPERTIES LABELS unit)
+2 -2
View File
@@ -39,5 +39,5 @@ target_link_libraries(
)
include(GoogleTest)
gtest_discover_tests(ProgramUtilTest DISCOVERY_TIMEOUT 30)
gtest_discover_tests(ProgramTest DISCOVERY_TIMEOUT 30)
gtest_discover_tests(ProgramUtilTest DISCOVERY_TIMEOUT 30 PROPERTIES LABELS unit)
gtest_discover_tests(ProgramTest DISCOVERY_TIMEOUT 30 PROPERTIES LABELS unit)
+1 -1
View File
@@ -17,4 +17,4 @@ target_link_libraries(
)
include(GoogleTest)
gtest_discover_tests(QueryTest DISCOVERY_TIMEOUT 30)
gtest_discover_tests(QueryTest DISCOVERY_TIMEOUT 30 PROPERTIES LABELS unit)
+2 -2
View File
@@ -17,7 +17,7 @@ target_link_libraries(
)
include(GoogleTest)
gtest_discover_tests(TextureTest DISCOVERY_TIMEOUT 30)
gtest_discover_tests(TextureTest DISCOVERY_TIMEOUT 30 PROPERTIES LABELS unit)
add_executable(
VkClearManagerTest
@@ -35,4 +35,4 @@ target_link_libraries(
${LINK_LIBRARIES}
)
gtest_discover_tests(VkClearManagerTest DISCOVERY_TIMEOUT 30)
gtest_discover_tests(VkClearManagerTest DISCOVERY_TIMEOUT 30 PROPERTIES LABELS unit)
+1 -1
View File
@@ -17,4 +17,4 @@ target_link_libraries(
)
include(GoogleTest)
gtest_discover_tests(VertexArrayTest DISCOVERY_TIMEOUT 30)
gtest_discover_tests(VertexArrayTest DISCOVERY_TIMEOUT 30 PROPERTIES LABELS unit)