Tests: Add NEEDS_GUI flag to add platform argument

Tests that create a QApplication need to be started with
"-platform minimal" so that they won't fail on build servers
without Display.

This also keeps them from distracting you if you run them while working.

Change-Id: I05df258b2204a3abd3cdea446d6a52f3e57a4a62
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Marcus Tillmanns
2023-08-10 11:28:41 +02:00
parent 2732b6e939
commit 973f74bad3
9 changed files with 14 additions and 2 deletions

View File

@@ -811,7 +811,7 @@ function(extend_qtc_executable name)
endfunction() endfunction()
function(add_qtc_test name) function(add_qtc_test name)
cmake_parse_arguments(_arg "GTEST;MANUALTEST;EXCLUDE_FROM_PRECHECK" "TIMEOUT" cmake_parse_arguments(_arg "GTEST;MANUALTEST;EXCLUDE_FROM_PRECHECK;NEEDS_GUI" "TIMEOUT"
"DEFINES;DEPENDS;INCLUDES;SOURCES;EXPLICIT_MOC;SKIP_AUTOMOC;SKIP_PCH;CONDITION;PROPERTIES" ${ARGN}) "DEFINES;DEPENDS;INCLUDES;SOURCES;EXPLICIT_MOC;SKIP_AUTOMOC;SKIP_PCH;CONDITION;PROPERTIES" ${ARGN})
if (${_arg_UNPARSED_ARGUMENTS}) if (${_arg_UNPARSED_ARGUMENTS})
@@ -878,8 +878,12 @@ function(add_qtc_test name)
enable_pch(${name}) enable_pch(${name})
endif() endif()
if (_arg_NEEDS_GUI)
set(EXTRA_ARGUMENTS "-platform" "minimal")
endif()
if (NOT _arg_GTEST AND NOT _arg_MANUALTEST) if (NOT _arg_GTEST AND NOT _arg_MANUALTEST)
add_test(NAME ${name} COMMAND ${name}) add_test(NAME ${name} COMMAND ${name} ${EXTRA_ARGUMENTS})
if (_arg_EXCLUDE_FROM_PRECHECK) if (_arg_EXCLUDE_FROM_PRECHECK)
set_tests_properties(${name} PROPERTIES LABELS exclude_from_precheck) set_tests_properties(${name} PROPERTIES LABELS exclude_from_precheck)
endif() endif()

View File

@@ -1,4 +1,5 @@
add_qtc_test(tst_qml_testcore add_qtc_test(tst_qml_testcore
NEEDS_GUI
EXCLUDE_FROM_PRECHECK EXCLUDE_FROM_PRECHECK
CONDITION TARGET QmlProjectManager CONDITION TARGET QmlProjectManager
DEPENDS DEPENDS

View File

@@ -1,4 +1,5 @@
add_qtc_test(tst_highlighter add_qtc_test(tst_highlighter
NEEDS_GUI
DEPENDS TextEditor Utils Qt::Widgets DEPENDS TextEditor Utils Qt::Widgets
SOURCES tst_highlighter.cpp SOURCES tst_highlighter.cpp
) )

View File

@@ -4,6 +4,7 @@ set(TSTFLAMEGRAPHVIEW_CPP_SOURCES
) )
add_qtc_test(tst_tracing_flamegraphview add_qtc_test(tst_tracing_flamegraphview
NEEDS_GUI
EXCLUDE_FROM_PRECHECK EXCLUDE_FROM_PRECHECK
DEPENDS Tracing Qt::QuickWidgets Qt::Quick Utils DEPENDS Tracing Qt::QuickWidgets Qt::Quick Utils
) )

View File

@@ -1,4 +1,5 @@
add_qtc_test(tst_tracing_timelineitemsrenderpass add_qtc_test(tst_tracing_timelineitemsrenderpass
NEEDS_GUI
DEPENDS Tracing Qt::Quick DEPENDS Tracing Qt::Quick
SOURCES tst_timelineitemsrenderpass.cpp SOURCES tst_timelineitemsrenderpass.cpp
) )

View File

@@ -1,4 +1,5 @@
add_qtc_test(tst_tracing_timelinenotesrenderpass add_qtc_test(tst_tracing_timelinenotesrenderpass
NEEDS_GUI
DEPENDS Tracing Qt::Quick DEPENDS Tracing Qt::Quick
SOURCES tst_timelinenotesrenderpass.cpp SOURCES tst_timelinenotesrenderpass.cpp
) )

View File

@@ -1,4 +1,5 @@
add_qtc_test(tst_tracing_timelineselectionrenderpass add_qtc_test(tst_tracing_timelineselectionrenderpass
NEEDS_GUI
DEPENDS Tracing Qt::Quick DEPENDS Tracing Qt::Quick
SOURCES tst_timelineselectionrenderpass.cpp SOURCES tst_timelineselectionrenderpass.cpp
) )

View File

@@ -1,4 +1,5 @@
add_qtc_test(tst_treeviewfind add_qtc_test(tst_treeviewfind
NEEDS_GUI
DEPENDS Core DEPENDS Core
SOURCES tst_treeviewfind.cpp SOURCES tst_treeviewfind.cpp
) )

View File

@@ -1,4 +1,5 @@
add_qtc_test(tst_utils_multicursor add_qtc_test(tst_utils_multicursor
NEEDS_GUI
DEPENDS Utils DEPENDS Utils
SOURCES tst_multicursor.cpp SOURCES tst_multicursor.cpp
) )