diff options
author | Brad King <brad.king@kitware.com> | 2019-03-19 12:53:24 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2019-03-19 12:53:35 (GMT) |
commit | 146b95949194ccf9aff3cfbe2243bde9727e16d5 (patch) | |
tree | a59867fc19ad68bd97892feb2babc35f7da93751 /Tests | |
parent | a9a4f3b1936c8e9b659b7b59166d1e73dc6d2397 (diff) | |
parent | dfea916d3c1e09d7a008a27029540b5ec77adb5d (diff) | |
download | CMake-146b95949194ccf9aff3cfbe2243bde9727e16d5.zip CMake-146b95949194ccf9aff3cfbe2243bde9727e16d5.tar.gz CMake-146b95949194ccf9aff3cfbe2243bde9727e16d5.tar.bz2 |
Merge topic 'environment-modules'
dfea916d3c FindEnvModules: Provide a CMake interface to environment modules
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3076
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/CMakeLists.txt | 4 | ||||
-rw-r--r-- | Tests/FindEnvModules/CMakeLists.txt | 3 | ||||
-rw-r--r-- | Tests/FindEnvModules/EnvModules.cmake | 35 |
3 files changed, 42 insertions, 0 deletions
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 74da394..d793adf 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -1421,6 +1421,10 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release add_subdirectory(FindDoxygen) endif() + if(CMake_TEST_FindEnvModules) + add_subdirectory(FindEnvModules) + endif() + if(CMake_TEST_FindEXPAT) add_subdirectory(FindEXPAT) endif() diff --git a/Tests/FindEnvModules/CMakeLists.txt b/Tests/FindEnvModules/CMakeLists.txt new file mode 100644 index 0000000..95b7d1d --- /dev/null +++ b/Tests/FindEnvModules/CMakeLists.txt @@ -0,0 +1,3 @@ +add_test(FindEnvModules.Test ${CMAKE_CMAKE_COMMAND} + -P ${CMAKE_CURRENT_LIST_DIR}/EnvModules.cmake +) diff --git a/Tests/FindEnvModules/EnvModules.cmake b/Tests/FindEnvModules/EnvModules.cmake new file mode 100644 index 0000000..0c81bf2 --- /dev/null +++ b/Tests/FindEnvModules/EnvModules.cmake @@ -0,0 +1,35 @@ +find_package(EnvModules REQUIRED) +message("module purge") +env_module(COMMAND purge RESULT_VARIABLE ret_var) +if(NOT ret_var EQUAL 0) + message(FATAL_ERROR "module(purge) returned ${ret_var}") +endif() + +message("module avail") +env_module_avail(avail_mods) +foreach(mod IN LISTS avail_mods) + message(" ${mod}") +endforeach() + +if(avail_mods) + list(GET avail_mods 0 mod0) + message("module load ${mod0}") + env_module(load ${mod0}) + + message("module list") + env_module_list(loaded_mods) + foreach(mod IN LISTS loaded_mods) + message(" ${mod}") + endforeach() + + list(LENGTH loaded_mods num_loaded_mods) + message("Number of modules loaded: ${num_loaded_mods}") + if(NOT num_loaded_mods EQUAL 1) + message(FATAL_ERROR "Exactly 1 module should be loaded. Found ${num_loaded_mods}") + endif() + + list(GET loaded_mods 0 mod0_actual) + if(NOT (mod0_actual MATCHES "^${mod0}")) + message(FATAL_ERROR "Loaded module does not match ${mod0}. Actual: ${mod0_actual}") + endif() +endif() |