summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2019-09-30 14:22:13 (GMT)
committerKitware Robot <kwrobot@kitware.com>2019-09-30 14:22:35 (GMT)
commitc2d1ea58bfbee75fe509e0c9745a66cb1e924b77 (patch)
tree6a0dadd2439caa4d6641c12be5c6ec4b04800433 /Tests
parent45507eeb6aa9e9caf01cc4852a6fcb06b73cc207 (diff)
parent60473cc660cc37c922b0ff93112deeb34d51f2ca (diff)
downloadCMake-c2d1ea58bfbee75fe509e0c9745a66cb1e924b77.zip
CMake-c2d1ea58bfbee75fe509e0c9745a66cb1e924b77.tar.gz
CMake-c2d1ea58bfbee75fe509e0c9745a66cb1e924b77.tar.bz2
Merge topic 'FPHSA-reason-failure-message'
60473cc660 FPHSA: add capability to specify message explaining reason of failure Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !3866
Diffstat (limited to 'Tests')
-rw-r--r--Tests/RunCMake/FPHSA/CustomMessageConfig.cmake1
-rw-r--r--Tests/RunCMake/FPHSA/CustomMessageConfigVersion.cmake4
-rw-r--r--Tests/RunCMake/FPHSA/FindCustomMessage.cmake17
-rw-r--r--Tests/RunCMake/FPHSA/RunCMakeTest.cmake7
-rw-r--r--Tests/RunCMake/FPHSA/custom_message_1-result.txt1
-rw-r--r--Tests/RunCMake/FPHSA/custom_message_1-stderr.txt7
-rw-r--r--Tests/RunCMake/FPHSA/custom_message_1.cmake4
-rw-r--r--Tests/RunCMake/FPHSA/custom_message_2-result.txt1
-rw-r--r--Tests/RunCMake/FPHSA/custom_message_2-stderr.txt8
-rw-r--r--Tests/RunCMake/FPHSA/custom_message_2.cmake5
-rw-r--r--Tests/RunCMake/FPHSA/custom_message_3-result.txt1
-rw-r--r--Tests/RunCMake/FPHSA/custom_message_3-stderr.txt9
-rw-r--r--Tests/RunCMake/FPHSA/custom_message_3.cmake5
13 files changed, 70 insertions, 0 deletions
diff --git a/Tests/RunCMake/FPHSA/CustomMessageConfig.cmake b/Tests/RunCMake/FPHSA/CustomMessageConfig.cmake
new file mode 100644
index 0000000..e25db1a
--- /dev/null
+++ b/Tests/RunCMake/FPHSA/CustomMessageConfig.cmake
@@ -0,0 +1 @@
+# pseudo config module
diff --git a/Tests/RunCMake/FPHSA/CustomMessageConfigVersion.cmake b/Tests/RunCMake/FPHSA/CustomMessageConfigVersion.cmake
new file mode 100644
index 0000000..b7c9e18
--- /dev/null
+++ b/Tests/RunCMake/FPHSA/CustomMessageConfigVersion.cmake
@@ -0,0 +1,4 @@
+# pseudo find_module
+
+set (PACKAGE_VERSION 2)
+set (PACKAGE_VERSION_UNSUITABLE TRUE)
diff --git a/Tests/RunCMake/FPHSA/FindCustomMessage.cmake b/Tests/RunCMake/FPHSA/FindCustomMessage.cmake
new file mode 100644
index 0000000..4d67db8
--- /dev/null
+++ b/Tests/RunCMake/FPHSA/FindCustomMessage.cmake
@@ -0,0 +1,17 @@
+# pseudo find_module
+
+if (REASON_FAILURE_MESSAGE)
+ list (PREPEND REASON_FAILURE_MESSAGE "REASON_FAILURE_MESSAGE")
+endif()
+
+include(FindPackageHandleStandardArgs)
+
+if (CONFIG_MODE)
+ find_package (CustomMessage QUIET CONFIG HINTS "${CMAKE_MODULE_PATH}")
+ find_package_handle_standard_args(CustomMessage CONFIG_MODE
+ ${REASON_FAILURE_MESSAGE})
+else()
+ find_package_handle_standard_args(CustomMessage REQUIRED_VARS FOOBAR
+ VERSION_VAR CustomMessage_VERSION
+ ${REASON_FAILURE_MESSAGE})
+endif()
diff --git a/Tests/RunCMake/FPHSA/RunCMakeTest.cmake b/Tests/RunCMake/FPHSA/RunCMakeTest.cmake
index dd73cd4..f3e6c3e 100644
--- a/Tests/RunCMake/FPHSA/RunCMakeTest.cmake
+++ b/Tests/RunCMake/FPHSA/RunCMakeTest.cmake
@@ -39,3 +39,10 @@ unset(RunCMake_DEFAULT_stderr)
# check if searching for a version 0 works
list(APPEND RunCMake_TEST_OPTIONS "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" "-DPseudo_VERSION=0")
run_cmake(exact_0_matching)
+
+# check custom error message
+set(RunCMake_TEST_OPTIONS "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" "-DCustomMessage_VERSION=1.2.3.4")
+run_cmake(custom_message_1)
+set(RunCMake_TEST_OPTIONS "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" "-DCONFIG_MODE=TRUE")
+run_cmake(custom_message_2)
+run_cmake(custom_message_3)
diff --git a/Tests/RunCMake/FPHSA/custom_message_1-result.txt b/Tests/RunCMake/FPHSA/custom_message_1-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/FPHSA/custom_message_1-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/FPHSA/custom_message_1-stderr.txt b/Tests/RunCMake/FPHSA/custom_message_1-stderr.txt
new file mode 100644
index 0000000..992fe39
--- /dev/null
+++ b/Tests/RunCMake/FPHSA/custom_message_1-stderr.txt
@@ -0,0 +1,7 @@
+^CMake Error at .+/Modules/FindPackageHandleStandardArgs.cmake:[0-9]+ \(message\):
+ Could NOT find CustomMessage \(missing: FOOBAR\) \(found suitable version
+ "1\.2\.3\.4", minimum required is "1\.2"\)
+
+ Reason given by package: Reason Failure
+
+Call Stack \(most recent call first\):
diff --git a/Tests/RunCMake/FPHSA/custom_message_1.cmake b/Tests/RunCMake/FPHSA/custom_message_1.cmake
new file mode 100644
index 0000000..330de50
--- /dev/null
+++ b/Tests/RunCMake/FPHSA/custom_message_1.cmake
@@ -0,0 +1,4 @@
+
+set (REASON_FAILURE_MESSAGE "Reason Failure")
+
+find_package(CustomMessage 1.2 REQUIRED)
diff --git a/Tests/RunCMake/FPHSA/custom_message_2-result.txt b/Tests/RunCMake/FPHSA/custom_message_2-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/FPHSA/custom_message_2-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/FPHSA/custom_message_2-stderr.txt b/Tests/RunCMake/FPHSA/custom_message_2-stderr.txt
new file mode 100644
index 0000000..4940752
--- /dev/null
+++ b/Tests/RunCMake/FPHSA/custom_message_2-stderr.txt
@@ -0,0 +1,8 @@
+^CMake Error at .+/Modules/FindPackageHandleStandardArgs.cmake:[0-9]+ \(message\):
+ Could NOT find CustomMessage \(Required is at least version "1\.2"\), checked
+ the following files:
+
+ .+/Tests/RunCMake/FPHSA/CustomMessageConfig.cmake \(version 2\)
+ Reason given by package: Not Found Message
+
+Call Stack \(most recent call first\):
diff --git a/Tests/RunCMake/FPHSA/custom_message_2.cmake b/Tests/RunCMake/FPHSA/custom_message_2.cmake
new file mode 100644
index 0000000..a3f2d96
--- /dev/null
+++ b/Tests/RunCMake/FPHSA/custom_message_2.cmake
@@ -0,0 +1,5 @@
+
+unset (REASON_FAILURE_MESSAGE)
+set (CustomMessage_NOT_FOUND_MESSAGE "Not Found Message")
+
+find_package(CustomMessage 1.2 REQUIRED)
diff --git a/Tests/RunCMake/FPHSA/custom_message_3-result.txt b/Tests/RunCMake/FPHSA/custom_message_3-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/FPHSA/custom_message_3-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/FPHSA/custom_message_3-stderr.txt b/Tests/RunCMake/FPHSA/custom_message_3-stderr.txt
new file mode 100644
index 0000000..dc55843
--- /dev/null
+++ b/Tests/RunCMake/FPHSA/custom_message_3-stderr.txt
@@ -0,0 +1,9 @@
+^CMake Error at .+/Modules/FindPackageHandleStandardArgs.cmake:[0-9]+ \(message\):
+ Could NOT find CustomMessage \(Required is at least version "1\.2"\), checked
+ the following files:
+
+ .+/Tests/RunCMake/FPHSA/CustomMessageConfig.cmake \(version 2\)
+ Reason given by package: Not Found Message
+ Reason Failure
+
+Call Stack \(most recent call first\):
diff --git a/Tests/RunCMake/FPHSA/custom_message_3.cmake b/Tests/RunCMake/FPHSA/custom_message_3.cmake
new file mode 100644
index 0000000..203e012
--- /dev/null
+++ b/Tests/RunCMake/FPHSA/custom_message_3.cmake
@@ -0,0 +1,5 @@
+
+set (REASON_FAILURE_MESSAGE "Reason Failure")
+set (CustomMessage_NOT_FOUND_MESSAGE "Not Found Message")
+
+find_package(CustomMessage 1.2 REQUIRED)