Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rapids_test_install_relocatable tracks tests environment properties #390

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions rapids-cmake/test/install_relocatable.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,16 @@ function(rapids_test_install_relocatable)

foreach(test IN LISTS tests_to_run)
get_test_property(${test} INSTALL_COMMAND command)
get_test_property(${test} RESOURCE_GROUPS resources)
get_test_property(${test} LABELS labels)
string(APPEND content "add_test([=[${test}]=] ${command})\n")
if(resources)
string(APPEND content
"set_tests_properties([=[${test}]=] PROPERTIES RESOURCE_GROUPS ${resources})\n")
endif()
if(labels)
string(APPEND content "set_tests_properties([=[${test}]=] PROPERTIES LABELS ${labels})\n")
endif()

set(properties_to_record ENVIRONMENT ENVIRONMENT_MODIFICATION RESOURCE_GROUPS LABELS)
foreach(prop_name IN LISTS properties_to_record)
get_test_property(${test} ${prop_name} prop_value)
if(prop_value)
string(APPEND content
"set_tests_properties([=[${test}]=] PROPERTIES ${prop_name} ${prop_value})\n")
endif()
endforeach()
endforeach()

set(test_launcher_file
Expand Down
1 change: 1 addition & 0 deletions testing/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ add_cmake_config_test(init-simple.cmake)

set(wrong_component_message "No install component set [wrong_component] can be found")
add_cmake_build_test(install_relocatable-include-in-all.cmake)
add_cmake_build_test(install_relocatable-env-vars.cmake)
add_cmake_build_test(install_relocatable-labels.cmake)
add_cmake_config_test(install_relocatable-simple.cmake)
add_cmake_config_test(install_relocatable-wrong-component.cmake SHOULD_FAIL "${wrong_component_message}")
Expand Down
43 changes: 43 additions & 0 deletions testing/test/install_relocatable-env-vars.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#=============================================================================
# Copyright (c) 2022-2023, NVIDIA CORPORATION.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#=============================================================================
include(${rapids-cmake-dir}/test/init.cmake)
include(${rapids-cmake-dir}/test/add.cmake)
include(${rapids-cmake-dir}/test/install_relocatable.cmake)

enable_language(CUDA)
rapids_test_init()

rapids_test_add(NAME verify_env COMMAND env GPUS 1 INSTALL_COMPONENT_SET testing)
set_tests_properties(verify_env PROPERTIES ENVIRONMENT "MYVAR=my_value")
set_tests_properties(verify_env PROPERTIES ENVIRONMENT_MODIFICATION "PATH=path_list_append:/fake/path")

rapids_test_install_relocatable(INSTALL_COMPONENT_SET testing
DESTINATION bin/testing)

set(generated_testfile "${CMAKE_CURRENT_BINARY_DIR}/rapids-cmake/testing/CTestTestfile.cmake.to_install")
file(READ "${generated_testfile}" contents)

set(env_match_string [===[PROPERTIES ENVIRONMENT MYVAR=my_value]===])
string(FIND "${contents}" "${env_match_string}" is_found)
if(is_found EQUAL -1)
message(FATAL_ERROR "Failed to record the ENVIRONMENT property")
endif()

set(env_mod_match_string [===[PROPERTIES ENVIRONMENT_MODIFICATION PATH=path_list_append:/fake/path]===])
string(FIND "${contents}" "${env_mod_match_string}" is_found)
if(is_found EQUAL -1)
message(FATAL_ERROR "Failed to record the ENVIRONMENT_MODIFICATION property")
endif()