summaryrefslogtreecommitdiffstats
path: root/Tests/FindRuby
diff options
context:
space:
mode:
Diffstat (limited to 'Tests/FindRuby')
-rw-r--r--Tests/FindRuby/CMakeLists.txt44
-rw-r--r--Tests/FindRuby/Fail/CMakeLists.txt5
-rw-r--r--Tests/FindRuby/FailExact/CMakeLists.txt8
-rw-r--r--Tests/FindRuby/Test/CMakeLists.txt14
-rw-r--r--Tests/FindRuby/Test/ruby_version.c7
5 files changed, 78 insertions, 0 deletions
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..be8c67f
--- /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_LIBRARY})
+
+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;
+}