diff options
author | Brad King <brad.king@kitware.com> | 2020-03-18 13:09:13 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2020-03-18 13:09:18 (GMT) |
commit | 863b0fa2aca3ece98d177f2dbafcad56f7037c8a (patch) | |
tree | bd969dd2c1f77b23e88bf52a9f43acf51ebb1163 /Tests | |
parent | d9ad00119d9d412f6ab245a11f72209704c74c81 (diff) | |
parent | 46064c819357ca6f83ed24d08f2762cac8c12157 (diff) | |
download | CMake-863b0fa2aca3ece98d177f2dbafcad56f7037c8a.zip CMake-863b0fa2aca3ece98d177f2dbafcad56f7037c8a.tar.gz CMake-863b0fa2aca3ece98d177f2dbafcad56f7037c8a.tar.bz2 |
Merge topic 'FindRuby-updates'
46064c8193 FindRuby: Add support for versions up to 2.7
675eaf3bd0 FindRuby: Update MSVC runtime library selection
b970e25d98 FindRuby: Remove extra whitespace
ecdace4d61 FindRuby: Include FPHSA closer to where it is used
f52f496138 FindRuby: Provide Ruby_LIBRARIES result variable
b00d736a0b FindRuby: Add dedicated tests
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4481
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/CMakeLists.txt | 4 | ||||
-rw-r--r-- | Tests/FindRuby/CMakeLists.txt | 44 | ||||
-rw-r--r-- | Tests/FindRuby/Fail/CMakeLists.txt | 5 | ||||
-rw-r--r-- | Tests/FindRuby/FailExact/CMakeLists.txt | 8 | ||||
-rw-r--r-- | Tests/FindRuby/Test/CMakeLists.txt | 14 | ||||
-rw-r--r-- | Tests/FindRuby/Test/ruby_version.c | 7 |
6 files changed, 82 insertions, 0 deletions
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 6f86a5f..6428235 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -1478,6 +1478,10 @@ ${CMake_SOURCE_DIR}/Utilities/Release/push.bash --dir dev -- '${CMake_BUILD_NIGH add_subdirectory(UseSWIG) endif() + if(CMake_TEST_FindRuby) + add_subdirectory(FindRuby) + endif() + add_subdirectory(FindThreads) # Matlab module diff --git a/Tests/FindRuby/CMakeLists.txt b/Tests/FindRuby/CMakeLists.txt new file mode 100644 index 0000000..193cb4f --- /dev/null +++ b/Tests/FindRuby/CMakeLists.txt @@ -0,0 +1,44 @@ +if(CMake_TEST_FindRuby) + + # Looks for ruby >=1.9.9, which is true on any Ubuntu (that installs it) or macOS (> 10.9) + add_test(NAME FindRuby.Test COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindRuby/Test" + "${CMake_BINARY_DIR}/Tests/FindRuby/Test" + ${build_generator_args} + --build-project TestRuby + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) + + # Looks for ruby >= 50.1.0, which should logically fail + add_test(NAME FindRuby.Fail COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindRuby/Fail" + "${CMake_BINARY_DIR}/Tests/FindRuby/Fail" + ${build_generator_args} + --build-project TestRubyFail + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) + set_tests_properties(FindRuby.Fail PROPERTIES + PASS_REGULAR_EXPRESSION "Could NOT find Ruby: Found unsuitable version \".*\", but required is.*least \"[0-9]+\\.[0-9]+\\.[0-9]+\" \\(found .*\\)") + + # Looks for 1.9.9 EXACTLY, which unlike the "FindRuby" test above will fail on every machine + # since this version doesn't exist (ruby goes from 1.9.3 to 2.0.0) + add_test(NAME FindRuby.FailExact COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindRuby/FailExact" + "${CMake_BINARY_DIR}/Tests/FindRuby/FailExact" + ${build_generator_args} + --build-project TestRubyFailExact + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) + set_tests_properties(FindRuby.FailExact PROPERTIES + PASS_REGULAR_EXPRESSION "Could NOT find Ruby: Found unsuitable version \".*\", but required is.*exact version \"[0-9]+\\.[0-9]+\\.[0-9]+\" \\(found .*\\)") + +endif() diff --git a/Tests/FindRuby/Fail/CMakeLists.txt b/Tests/FindRuby/Fail/CMakeLists.txt new file mode 100644 index 0000000..9185ba5 --- /dev/null +++ b/Tests/FindRuby/Fail/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 3.17) +project(TestRubyFail LANGUAGES NONE) + +# Should always fail since there is NO ruby 50.1.0 yet. +find_package(Ruby 50.1.0 REQUIRED) diff --git a/Tests/FindRuby/FailExact/CMakeLists.txt b/Tests/FindRuby/FailExact/CMakeLists.txt new file mode 100644 index 0000000..1ebc0ae --- /dev/null +++ b/Tests/FindRuby/FailExact/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.17) +project(TestRubyFailExact LANGUAGES NONE) + +# Should always fail since there is NO ruby 1.9.9 (goes from 1.9.3 to 2.0.0) +find_package(Ruby 1.9.9 EXACT REQUIRED) +if (NOT Ruby_FOUND) + message (FATAL_ERROR "Failed to find Ruby 1.9.9") +endif() diff --git a/Tests/FindRuby/Test/CMakeLists.txt b/Tests/FindRuby/Test/CMakeLists.txt new file mode 100644 index 0000000..dcf3ec3 --- /dev/null +++ b/Tests/FindRuby/Test/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.17) +project(TestRuby LANGUAGES C) +include(CTest) + +find_package(Ruby 1.9.9 REQUIRED) +if (NOT Ruby_FOUND) + message (FATAL_ERROR "Failed to find Ruby >=1.9.9") +endif() + +add_executable(ruby_version ruby_version.c) +target_include_directories(ruby_version PRIVATE ${Ruby_INCLUDE_DIRS}) +target_link_libraries(ruby_version PRIVATE ${Ruby_LIBRARIES}) + +add_test(NAME ruby_version COMMAND ruby_version) diff --git a/Tests/FindRuby/Test/ruby_version.c b/Tests/FindRuby/Test/ruby_version.c new file mode 100644 index 0000000..8800436 --- /dev/null +++ b/Tests/FindRuby/Test/ruby_version.c @@ -0,0 +1,7 @@ +#include "ruby.h" + +int main(void) +{ + ruby_show_version(); + return 0; +} |