CMake: Allow extra libraries in calamares_add_test

- Extra libraries specified via LIBRARIES part of CMake function
 - Convert all the other module tests
This commit is contained in:
Adriaan de Groot 2020-02-17 14:36:52 +01:00
parent 637a57d534
commit 4495a4c739
11 changed files with 86 additions and 143 deletions

View File

@ -34,7 +34,7 @@ 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( multiValueArgs SOURCES ) set( multiValueArgs SOURCES LIBRARIES )
cmake_parse_arguments( TEST "${options}" "" "${multiValueArgs}" ${ARGN} ) cmake_parse_arguments( TEST "${options}" "" "${multiValueArgs}" ${ARGN} )
set( TEST_NAME ${NAME} ) set( TEST_NAME ${NAME} )
@ -45,13 +45,14 @@ function( calamares_add_test )
${TEST_NAME} ${TEST_NAME}
LINK_LIBRARIES LINK_LIBRARIES
calamares calamares
${TEST_LIBRARIES}
Qt5::Core Qt5::Core
Qt5::Test Qt5::Test
) )
calamares_automoc( ${TEST_NAME} ) calamares_automoc( ${TEST_NAME} )
target_compile_definitions( ${TEST_NAME} PRIVATE -DBUILD_AS_TEST ) target_compile_definitions( ${TEST_NAME} PRIVATE -DBUILD_AS_TEST )
if( TEST_GUI ) if( TEST_GUI )
target_link_libraries( ${TEST_NAME} PRIVATE calamaresui Qt5::Gui ) target_link_libraries( ${TEST_NAME} calamaresui Qt5::Gui )
endif() endif()
endif() endif()
endfunction() endfunction()

View File

@ -8,18 +8,12 @@ calamares_add_plugin( contextualprocess
SHARED_LIB SHARED_LIB
) )
if( ECM_FOUND AND BUILD_TESTING ) calamares_add_test(
ecm_add_test( contextualprocesstest
Tests.cpp GUI # It's not
ContextualProcessJob.cpp # Builds it a second time SOURCES
TEST_NAME Tests.cpp
contextualprocesstest ContextualProcessJob.cpp # Builds it a second time
LINK_LIBRARIES LIBRARIES
${CALAMARES_LIBRARIES} ${YAMLCPP_LIBRARY}
calamaresui )
${YAMLCPP_LIBRARY}
Qt5::Core
Qt5::Test
)
calamares_automoc( contextualprocesstest )
endif()

View File

@ -30,21 +30,15 @@ if ( KPMcore_FOUND AND Qt5DBus_FOUND AND KF5CoreAddons_FOUND AND KF5Config_FOUND
SHARED_LIB SHARED_LIB
) )
if( ECM_FOUND AND BUILD_TESTING ) calamares_add_test(
ecm_add_test( fsresizertest
Tests.cpp SOURCES
TEST_NAME Tests.cpp
fsresizertest LIBRARIES
LINK_LIBRARIES calamares_job_fsresizer # From above
${CALAMARES_LIBRARIES} ${YAMLCPP_LIBRARY}
calamares )
calamares_job_fsresizer # From above if( TARGET fsresizertest )
${YAMLCPP_LIBRARY}
Qt5::Core
Qt5::Test
)
set_target_properties( fsresizertest PROPERTIES AUTOMOC TRUE )
target_include_directories( fsresizertest PRIVATE /usr/local/include )
target_compile_definitions( fsresizertest PRIVATE ${_partition_defs} ) target_compile_definitions( fsresizertest PRIVATE ${_partition_defs} )
endif() endif()
else() else()

View File

@ -32,18 +32,12 @@ if ( KF5CoreAddons_FOUND AND KF5CoreAddons_VERSION VERSION_GREATER_EQUAL 5.58 )
target_compile_definitions( calamares_job_hostinfo PRIVATE WITH_KOSRelease ) target_compile_definitions( calamares_job_hostinfo PRIVATE WITH_KOSRelease )
endif() endif()
if( ECM_FOUND AND BUILD_TESTING ) calamares_add_test(
ecm_add_test( hostinfotest
Tests.cpp GUI # It's not
HostInfoJob.cpp # Builds it a second time SOURCES
TEST_NAME Tests.cpp
hostinfotest HostInfoJob.cpp
LINK_LIBRARIES LIBRARIES
${CALAMARES_LIBRARIES} ${YAMLCPP_LIBRARY}
calamaresui )
${YAMLCPP_LIBRARY}
Qt5::Core
Qt5::Test
)
calamares_automoc( hostinfotest )
endif()

View File

@ -8,18 +8,12 @@ calamares_add_plugin( initcpio
SHARED_LIB SHARED_LIB
) )
if( ECM_FOUND AND BUILD_TESTING ) calamares_add_test(
ecm_add_test( initcpiotest
Tests.cpp GUI # It's not
TEST_NAME SOURCES
initcpiotest Tests.cpp
LINK_LIBRARIES LIBRARIES
${CALAMARES_LIBRARIES} calamares_job_initcpio # From above
calamares ${YAMLCPP_LIBRARY}
calamares_job_initcpio # From above )
${YAMLCPP_LIBRARY}
Qt5::Core
Qt5::Test
)
calamares_automoc( initcpiotest )
endif()

View File

@ -8,18 +8,12 @@ calamares_add_plugin( initramfs
SHARED_LIB SHARED_LIB
) )
if( ECM_FOUND AND BUILD_TESTING ) calamares_add_test(
ecm_add_test( initramfstest
Tests.cpp GUI # It's not
TEST_NAME SOURCES
initramfstest Tests.cpp
LINK_LIBRARIES LIBRARIES
${CALAMARES_LIBRARIES} calamares_job_initramfs # From above
calamares ${YAMLCPP_LIBRARY}
calamares_job_initramfs # From above )
${YAMLCPP_LIBRARY}
Qt5::Core
Qt5::Test
)
calamares_automoc( initramfstest )
endif()

View File

@ -31,15 +31,9 @@ calamares_add_plugin( locale
SHARED_LIB SHARED_LIB
) )
if( ECM_FOUND AND BUILD_TESTING ) calamares_add_test(
ecm_add_test( localetest
Tests.cpp SOURCES
LocaleConfiguration.cpp Tests.cpp
TEST_NAME LocaleConfiguration.cpp
localetest )
LINK_LIBRARIES
calamares
Qt5::Test
)
calamares_automoc( localetest )
endif()

View File

@ -53,18 +53,12 @@ calamares_add_plugin( packagechooser
SHARED_LIB SHARED_LIB
) )
if( ECM_FOUND AND BUILD_TESTING ) calamares_add_test(
ecm_add_test( packagechoosertest
Tests.cpp GUI
TEST_NAME SOURCES
packagechoosertest Tests.cpp
LINK_LIBRARIES LIBRARIES
${CALAMARES_LIBRARIES} calamares_viewmodule_packagechooser
calamares_viewmodule_packagechooser ${_extra_libraries}
Qt5::Core )
Qt5::Test
Qt5::Gui
${_extra_libraries}
)
calamares_automoc( packagechoosertest)
endif()

View File

@ -21,16 +21,12 @@ include_directories(
${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}
) )
if( ECM_FOUND AND BUILD_TESTING ) calamares_add_test(
ecm_add_test( ${partitionjobtests_SRCS} partitionjobtests
TEST_NAME partitionjobtests SOURCES ${partitionjobtests_SRCS}
LINK_LIBRARIES LIBRARIES
${CALAMARES_LIBRARIES} kpmcore
kpmcore )
Qt5::Core if( TARGET partitionjobtests )
Qt5::Test
)
set_target_properties( partitionjobtests PROPERTIES AUTOMOC TRUE )
target_compile_definitions( partitionjobtests PRIVATE ${_partition_defs} ) target_compile_definitions( partitionjobtests PRIVATE ${_partition_defs} )
endif() endif()

View File

@ -8,17 +8,11 @@ calamares_add_plugin( shellprocess
SHARED_LIB SHARED_LIB
) )
if( ECM_FOUND AND BUILD_TESTING ) calamares_add_test(
ecm_add_test( shellprocesstest
Tests.cpp GUI # It's not
TEST_NAME SOURCES
shellprocesstest Tests.cpp
LINK_LIBRARIES LIBRARIES
${CALAMARES_LIBRARIES} ${YAMLCPP_LIBRARY}
calamaresui )
${YAMLCPP_LIBRARY}
Qt5::Core
Qt5::Test
)
calamares_automoc( shellprocesstest )
endif()

View File

@ -39,17 +39,11 @@ calamares_add_plugin( users
SHARED_LIB SHARED_LIB
) )
if( ECM_FOUND AND BUILD_TESTING ) calamares_add_test(
ecm_add_test( passwordtest
PasswordTests.cpp SOURCES
SetPasswordJob.cpp PasswordTests.cpp
TEST_NAME SetPasswordJob.cpp
passwordtest LIBRARIES
LINK_LIBRARIES ${CRYPT_LIBRARIES}
${CALAMARES_LIBRARIES} )
Qt5::Core
Qt5::Test
${CRYPT_LIBRARIES}
)
calamares_automoc( passwordtest )
endif()