1 #========================================================================= 3 # This software is distributed WITHOUT ANY WARRANTY; without even 4 # the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 5 # PURPOSE. See the above copyright notice for more information. 7 #========================================================================= 9 # paraview_contract_test( 10 # TEST_FILE_URL <test_file> 11 # [EXTRA_CMAKE_ARGUMENTS <cmake_arg>...] 14 # add a test that builds and tests a suite of contract tests as described in the test 16 # note: This is derived from https://gitlab.kitware.com/cmb/smtk/-/blob/master/CMake/SMTKPluginTestingMacros.cmake 18 cmake_parse_arguments(PARSE_ARGV 0 _paraview_contract_test
21 "EXTRA_CMAKE_ARGUMENTS")
23 if (_paraview_contract_test_UNPARSED_ARGUMENTS)
25 "Unrecognized arguments for paraview_contract_test: " 26 "${_paraview_contract_test_UNPARSED_ARGUMENTS}.")
29 if (NOT DEFINED _paraview_contract_test_TEST_FILE_URL)
31 "The `TEST_FILE_URL` argument is required.")
33 set(test_file_url "${_paraview_contract_test_TEST_FILE_URL}
") 35 # Create a testing directory for the contract test based off of its hashed 37 string(MD5 hashed_test_dir "${test_file_url}
") 38 string(SUBSTRING "${hashed_test_dir}
" 0 8 hashed_test_dir) 39 set(test_dir "${CMAKE_BINARY_DIR}/ContractTests/${hashed_test_dir}
") 41 # Set up a source directory for the contract test 42 set(src_dir "${test_dir}/src
") 43 file(MAKE_DIRECTORY "${src_dir}
") 45 # Set up a build directory for the contract test 46 set(build_dir "${test_dir}/build
") 47 file(MAKE_DIRECTORY "${build_dir}
") 49 # Download the contract file into the source directory. 50 file(DOWNLOAD "${test_file_url}
" "${src_dir}/CMakeLists.txt
") 52 # Check result for success 53 if (NOT EXISTS "${src_dir}/CMakeLists.txt
") 54 message(WARNING "Cannot download contract test file <${test_file_url}>.
") 58 # Derive a test name from the contract file name. 59 get_filename_component(test_name ${test_file_url} NAME_WE) 60 set(test_name "contract-${test_name}
") 63 if (CMAKE_MAKE_PROGRAM) 64 list(APPEND ctest_extra_args 65 --build-makeprogram "${CMAKE_MAKE_PROGRAM}
") 68 if (CMAKE_GENERATOR_PLATFORM) 69 list(APPEND ctest_extra_args 70 --build-generator-platform "${CMAKE_GENERATOR_PLATFORM}
") 73 if (CMAKE_GENERATOR_TOOLSET) 74 list(APPEND ctest_extra_args 75 --build-generator-toolset "${CMAKE_GENERATOR_TOOLSET}
") 79 if(_paraview_contract_test_EXTRA_CMAKE_ARGUMENTS) 80 list(APPEND cmake_extra_args 81 ${_paraview_contract_test_EXTRA_CMAKE_ARGUMENTS}) 84 # Add a test that builds and tests the plugin, but does not install it. 85 add_test(NAME "${test_name}
" 86 COMMAND "${CMAKE_CTEST_COMMAND}
" 87 --build-and-test "${src_dir}
" "${build_dir}
" 88 --build-generator "${CMAKE_GENERATOR}
" 91 -DBUILD_SHARED_LIBS:BOOL=${BUILD_SHARED_LIBS} 93 -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} 94 "-Dcatalyst_DIR=${catalyst_DIR}
" 95 "-DParaViewCatalyst_DIR=${ParaView_BINARY_DIR}/${paraview_catalyst_directory}
" 99 # Contract tests require compiling code, which can take up a lot of memory. 100 # Running them serially may prevent memory-related issues (c++: fatal error: 101 # Killed signal terminated program cc1plus) that sporadically appear on our 104 # Ideally, `ctest --build-and-test` would support setting load-level 105 # parallelism so that tests can cooperatively work, but that still leaves 106 # testing to take up a lot of resources. Best to leave as serial for now. 107 set_property(TEST "${test_name}
" 111 set_property(TEST "${test_name}
" APPEND 113 ENVIRONMENT "CTEST_OUTPUT_ON_FAILURE=1
") 115 set_tests_properties(${test_name} PROPERTIES LABELS "ParaViewContract
") function paraview_contract_test()