CMake: allow fine-tuning tests
- The Python configuration tests sometimes need extra setup, so do that through a CMakeTests.txt file in the test directory. - Patch up existing tests: - grubcfg needs /tmp/calamares/etc/default to exist - rawfs won't work on FreeBSD because of differences in /proc
This commit is contained in:
parent
fe069bdb23
commit
c3d8112187
2
CHANGES
2
CHANGES
@ -16,6 +16,8 @@ This release contains contributions from (alphabetically by first name):
|
||||
QML-based modules -- with a single `-DWITH_QML=OFF` at CMake time.
|
||||
This removes QML from Calamares' dependency footprint (but only saves
|
||||
200kB in Calamares itself).
|
||||
- Tests have been extended and now support a tests/CMakeTests.txt file
|
||||
for fine-tuning tests for Python modules.
|
||||
|
||||
## Modules ##
|
||||
- No module changes yet
|
||||
|
@ -126,10 +126,10 @@ function( calamares_add_module_subdirectory )
|
||||
endif()
|
||||
message( "" )
|
||||
# We copy over the lang directory, if any
|
||||
if( IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY}/lang" )
|
||||
if( IS_DIRECTORY "${_mod_dir}/lang" )
|
||||
install_calamares_gettext_translations(
|
||||
${SUBDIRECTORY}
|
||||
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY}/lang"
|
||||
SOURCE_DIR "${_mod_dir}/lang"
|
||||
FILENAME ${SUBDIRECTORY}.mo
|
||||
RENAME calamares-${SUBDIRECTORY}.mo
|
||||
)
|
||||
@ -162,6 +162,16 @@ function( calamares_add_module_subdirectory )
|
||||
# may try to do things to the running system. Needs work to make that a
|
||||
# safe thing to do.
|
||||
#
|
||||
# If the module has a tests/ subdirectory with *.global and *.job
|
||||
# files (YAML files holding global and job-configurations for
|
||||
# testing purposes) then those files are used to drive additional
|
||||
# tests. The files must be numbered (starting from 1) for this to work;
|
||||
# 1.global and 1.job together make the configuration for test 1.
|
||||
#
|
||||
# If the module has a tests/CMakeLists.txt while it doesn't have its
|
||||
# own CMakeLists.txt (e.g. a Python module), then the subdirectory
|
||||
# for tests/ is added on its own.
|
||||
#
|
||||
if ( BUILD_TESTING AND _mod_enabled AND _mod_testing )
|
||||
add_test(
|
||||
NAME load-${SUBDIRECTORY}
|
||||
@ -170,7 +180,7 @@ function( calamares_add_module_subdirectory )
|
||||
)
|
||||
# Try it with the tests/ configurations shipped with the module
|
||||
set( _count 1 )
|
||||
set( _testdir ${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY}/tests )
|
||||
set( _testdir ${_mod_dir}/tests )
|
||||
while ( EXISTS "${_testdir}/${_count}.global" OR EXISTS "${_testdir}/${_count}.job" )
|
||||
set( _dash_g "" )
|
||||
set( _dash_j "" )
|
||||
@ -187,5 +197,8 @@ function( calamares_add_module_subdirectory )
|
||||
)
|
||||
math( EXPR _count "${_count} + 1" )
|
||||
endwhile()
|
||||
if ( EXISTS ${_testdir}/CMakeTests.txt AND NOT EXISTS ${_mod_dir}/CMakeLists.txt )
|
||||
include( ${_testdir}/CMakeTests.txt )
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
|
12
src/modules/grubcfg/tests/CMakeTests.txt
Normal file
12
src/modules/grubcfg/tests/CMakeTests.txt
Normal file
@ -0,0 +1,12 @@
|
||||
# Special cases for grubcfg configuration tests:
|
||||
# - 2.global specifies /tmp/calamares as the rootMountPath,
|
||||
# so we end up editing files there. Create the directory
|
||||
# beforehand, so the test doesn't blow up.
|
||||
set(_grub_root /tmp/calamares/etc/default)
|
||||
set(_grub_file ${_grub_root}/bogus)
|
||||
|
||||
add_test(
|
||||
NAME make-grubcfg-dirs
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${_grub_root}
|
||||
)
|
||||
set_tests_properties(load-grubcfg-2 PROPERTIES DEPENDS make-grubcfg-dirs)
|
8
src/modules/rawfs/tests/CMakeTests.txt
Normal file
8
src/modules/rawfs/tests/CMakeTests.txt
Normal file
@ -0,0 +1,8 @@
|
||||
# Special cases for rawfs tests
|
||||
#
|
||||
# - On FreeBSD, /proc/mounts doesn't exist (/proc is only about processes,
|
||||
# and is rarely used). Expect the test to fail.
|
||||
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
|
||||
set_tests_properties(load-rawfs-1 PROPERTIES WILL_FAIL TRUE)
|
||||
endif()
|
Loading…
Reference in New Issue
Block a user