CMake: add resources to tests

Some tests -- notably the keyboard module -- need to have the
QRC for the module loaded as well (e.g. because of data in the
QRC). Add a RESOURCES parameter to calamares_add_test()
like calamares_add_plugin() already has, to build the
resources into the test.

Keyboard test now passes, since it was missing the data for
lookups before.
This commit is contained in:
Adriaan de Groot 2020-09-09 11:58:56 +02:00
parent 2aece7ff1b
commit aeffbac9cd
2 changed files with 9 additions and 2 deletions

View File

@ -14,6 +14,7 @@
# calamares_add_test( # calamares_add_test(
# <NAME> # <NAME>
# [GUI] # [GUI]
# [RESOURCES FILE]
# SOURCES <FILE..> # SOURCES <FILE..>
# ) # )
@ -24,13 +25,14 @@ function( calamares_add_test )
# parse arguments (name needs to be saved before passing ARGN into the macro) # parse arguments (name needs to be saved before passing ARGN into the macro)
set( NAME ${ARGV0} ) set( NAME ${ARGV0} )
set( options GUI ) set( options GUI )
set( oneValueArgs NAME RESOURCES )
set( multiValueArgs SOURCES LIBRARIES DEFINITIONS ) set( multiValueArgs SOURCES LIBRARIES DEFINITIONS )
cmake_parse_arguments( TEST "${options}" "" "${multiValueArgs}" ${ARGN} ) cmake_parse_arguments( TEST "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
set( TEST_NAME ${NAME} ) set( TEST_NAME ${NAME} )
if( ECM_FOUND AND BUILD_TESTING ) if( ECM_FOUND AND BUILD_TESTING )
ecm_add_test( ecm_add_test(
${TEST_SOURCES} ${TEST_SOURCES} ${TEST_RESOURCES}
TEST_NAME TEST_NAME
${TEST_NAME} ${TEST_NAME}
LINK_LIBRARIES LINK_LIBRARIES
@ -44,5 +46,8 @@ function( calamares_add_test )
if( TEST_GUI ) if( TEST_GUI )
target_link_libraries( ${TEST_NAME} calamaresui Qt5::Gui ) target_link_libraries( ${TEST_NAME} calamaresui Qt5::Gui )
endif() endif()
if( TEST_RESOURCES )
calamares_autorcc( ${TEST_NAME} ${TEST_RESOURCES} )
endif()
endif() endif()
endfunction() endfunction()

View File

@ -27,4 +27,6 @@ calamares_add_test(
SOURCES SOURCES
Tests.cpp Tests.cpp
SetKeyboardLayoutJob.cpp SetKeyboardLayoutJob.cpp
RESOURCES
keyboard.qrc
) )