summaryrefslogtreecommitdiffstats
path: root/Tests/FindPython
diff options
context:
space:
mode:
Diffstat (limited to 'Tests/FindPython')
-rw-r--r--Tests/FindPython/CMakeLists.txt14
-rw-r--r--Tests/FindPython/CustomFailureMessage/CMakeLists.txt79
-rw-r--r--Tests/FindPython/CustomFailureMessage/Check/CMakeLists.txt5
3 files changed, 98 insertions, 0 deletions
diff --git a/Tests/FindPython/CMakeLists.txt b/Tests/FindPython/CMakeLists.txt
index 868cfe0..10c98c5 100644
--- a/Tests/FindPython/CMakeLists.txt
+++ b/Tests/FindPython/CMakeLists.txt
@@ -134,6 +134,20 @@ if(CMake_TEST_FindPython)
--test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
)
+ add_test(NAME FindPython.CustomFailureMessage COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindPython/CustomFailureMessage"
+ "${CMake_BINARY_DIR}/Tests/FindPython/CustomFailureMessage"
+ ${build_generator_args}
+ --build-project TestCustomFailureMessage
+ --build-options ${build_options} "-Dbuild_generator_args=${build_generator_args}"
+ "-DCMake_SOURCE_DIR=${CMake_SOURCE_DIR}"
+ "-DCMake_BINARY_DIR=${CMake_BINARY_DIR}"
+ "-DCMake_TEST_FindPython_NumPy=${CMake_TEST_FindPython_NumPy}"
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
+
endif()
if(CMake_TEST_FindPython_NumPy)
diff --git a/Tests/FindPython/CustomFailureMessage/CMakeLists.txt b/Tests/FindPython/CustomFailureMessage/CMakeLists.txt
new file mode 100644
index 0000000..a0d8eb2
--- /dev/null
+++ b/Tests/FindPython/CustomFailureMessage/CMakeLists.txt
@@ -0,0 +1,79 @@
+cmake_minimum_required(VERSION 3.1)
+
+project(TestCustomFailureMessage LANGUAGES NONE)
+
+include(CTest)
+
+add_test(NAME FindPython.CustomFailureMessage.Interpreter COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindPython/CustomFailureMessage/Check"
+ "${CMake_BINARY_DIR}/Tests/FindPython/CustomFailureMessage/Interpreter"
+ ${build_generator_args}
+ --build-project TestCustomFailureMessage.Check
+ --build-options "-DCHECK_COMPONENTS=Interpreter"
+ "-DPython3_EXECUTABLE=/not/found/interpreter"
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
+set_tests_properties(FindPython.CustomFailureMessage.Interpreter PROPERTIES
+ PASS_REGULAR_EXPRESSION "Reason given by package:.+Interpreter: Cannot run the interpreter")
+
+add_test(NAME FindPython.CustomFailureMessage.Library COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindPython/CustomFailureMessage/Check"
+ "${CMake_BINARY_DIR}/Tests/FindPython/CustomFailureMessage/Library"
+ ${build_generator_args}
+ --build-project TestCustomFailureMessage.Check
+ --build-options "-DCHECK_COMPONENTS=Development"
+ "-DPython3_LIBRARY=/not/found/library"
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
+set_tests_properties(FindPython.CustomFailureMessage.Library PROPERTIES
+ PASS_REGULAR_EXPRESSION "Reason given by package:.+Development: Cannot find the library")
+
+add_test(NAME FindPython.CustomFailureMessage.Include COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindPython/CustomFailureMessage/Check"
+ "${CMake_BINARY_DIR}/Tests/FindPython/CustomFailureMessage/Include"
+ ${build_generator_args}
+ --build-project TestCustomFailureMessage.Check
+ --build-options "-DCHECK_COMPONENTS=Development"
+ "-DPython3_INCLUDE_DIR=/not/found/include"
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
+set_tests_properties(FindPython.CustomFailureMessage.Include PROPERTIES
+ PASS_REGULAR_EXPRESSION "Reason given by package:.+Development: Cannot find the directory")
+
+add_test(NAME FindPython.CustomFailureMessage.Multiple COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindPython/CustomFailureMessage/Check"
+ "${CMake_BINARY_DIR}/Tests/FindPython/CustomFailureMessage/Multiple"
+ ${build_generator_args}
+ --build-project TestCustomFailureMessage.Check
+ --build-options "-DCHECK_COMPONENTS=Interpreter;Development"
+ "-DPython3_EXECUTABLE=/not/found/interpreter"
+ "-DPython3_LIBRARY=/not/found/library"
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
+set_tests_properties(FindPython.CustomFailureMessage.Multiple PROPERTIES
+ PASS_REGULAR_EXPRESSION "Reason given by package:.+Interpreter: Cannot run the interpreter.+Development: Cannot find the library")
+
+
+if (CMake_TEST_FindPython_NumPy)
+ add_test(NAME FindPython.CustomFailureMessage.NumPy COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindPython/CustomFailureMessage/Check"
+ "${CMake_BINARY_DIR}/Tests/FindPython/CustomFailureMessage/NumPy"
+ ${build_generator_args}
+ --build-project TestCustomFailureMessage.Check
+ --build-options "-DCHECK_COMPONENTS=Interpreter;Development;NumPy"
+ "-DPython3_NumPy_INCLUDE_DIR=/not/found/numpy/include"
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
+ set_tests_properties(FindPython.CustomFailureMessage.NumPy PROPERTIES
+ PASS_REGULAR_EXPRESSION "Reason given by package:.+NumPy: Cannot find the directory")
+endif()
diff --git a/Tests/FindPython/CustomFailureMessage/Check/CMakeLists.txt b/Tests/FindPython/CustomFailureMessage/Check/CMakeLists.txt
new file mode 100644
index 0000000..fed963e
--- /dev/null
+++ b/Tests/FindPython/CustomFailureMessage/Check/CMakeLists.txt
@@ -0,0 +1,5 @@
+cmake_minimum_required(VERSION 3.1)
+
+project(TestCustomFailureMessage.Check LANGUAGES C)
+
+find_package (Python3 REQUIRED COMPONENTS ${CHECK_COMPONENTS})