Skip to content

fix: Use QT_QPA_PLATFORM=offscreen in tests #992

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions examples/qml_features/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,15 @@ if(BUILD_TESTING)
NAME ${APP_TEST_NAME}
COMMAND ${TEST_CMD}
)
# Unfortunately due to the static linking in our CI on macOS we can't load the
# offscreen plugin, so just leave it at the default.
if (NOT APPLE)
set_tests_properties(${APP_TEST_NAME} PROPERTIES ENVIRONMENT "QT_QPA_PLATFORM=offscreen")
endif()
# RUNTIME_ENV comes from the CMakeLists.txt at the root of this repository.
set_tests_properties(
${APP_TEST_NAME} PROPERTIES ENVIRONMENT_MODIFICATION "${RUNTIME_ENV}"
)

if (COMMAND add_valgrind_test)
add_valgrind_test(
Expand All @@ -85,9 +94,4 @@ if(BUILD_TESTING)
else()
MESSAGE(STATUS "add_valgrind_test is defined in the top level of CXX-Qt. It will not executed")
endif()

# RUNTIME_ENV comes from the CMakeLists.txt at the root of this repository.
set_tests_properties(
${APP_TEST_NAME} PROPERTIES ENVIRONMENT_MODIFICATION "${RUNTIME_ENV}"
)
endif()
12 changes: 9 additions & 3 deletions examples/qml_minimal/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,18 @@ if(BUILD_TESTING)
NAME ${APP_TEST_NAME}
COMMAND ${TEST_CMD}
)

# Unfortunately due to the static linking in our CI on macOS we can't load the
# offscreen plugin, so just leave it at the default.
if (NOT APPLE)
set_tests_properties(${APP_TEST_NAME} PROPERTIES ENVIRONMENT "QT_QPA_PLATFORM=offscreen")
endif()
# RUNTIME_ENV comes from the CMakeLists.txt at the root of this repository.
set_tests_properties(
${APP_NAME}_${TEST_NAME}_test PROPERTIES ENVIRONMENT_MODIFICATION
"${RUNTIME_ENV}"
${APP_NAME}_${TEST_NAME}_test
PROPERTIES
ENVIRONMENT_MODIFICATION "${RUNTIME_ENV}"
)

if (COMMAND add_valgrind_test)
add_valgrind_test(
${APP_TEST_NAME} "${TEST_CMD}" ${CMAKE_CURRENT_BINARY_DIR}
Expand Down
13 changes: 12 additions & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,19 @@ function(add_acceptance_tests TEST_NAME)
set(CPP_TEST_NAME ${NAME_WITH_PREFIX}_cpp_tests)
add_test(NAME ${CPP_TEST_NAME} COMMAND $<TARGET_FILE:${TARGET_NAME}>)

# Unfortunately due to the static linking in our CI we can't load the
# offscreen plugin, so just leave it at the default.
if (NOT APPLE)
set_tests_properties(
${CPP_TEST_NAME}
PROPERTIES
ENVIRONMENT "QT_QPA_PLATFORM=offscreen"
)
endif()
set_tests_properties(
${CPP_TEST_NAME} PROPERTIES ENVIRONMENT_MODIFICATION "${RUNTIME_ENV}"
${CPP_TEST_NAME}
PROPERTIES
ENVIRONMENT_MODIFICATION "${RUNTIME_ENV}"
)

if (NOT WIN32)
Expand Down
Loading