summaryrefslogtreecommitdiff
path: root/projects/SelfTest/WarnAboutNoTests.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'projects/SelfTest/WarnAboutNoTests.cmake')
-rw-r--r--projects/SelfTest/WarnAboutNoTests.cmake19
1 files changed, 19 insertions, 0 deletions
diff --git a/projects/SelfTest/WarnAboutNoTests.cmake b/projects/SelfTest/WarnAboutNoTests.cmake
new file mode 100644
index 00000000..4637e3f3
--- /dev/null
+++ b/projects/SelfTest/WarnAboutNoTests.cmake
@@ -0,0 +1,19 @@
+# Workaround for a peculiarity where CTest disregards the return code from a
+# test command if a PASS_REGULAR_EXPRESSION is also set
+execute_process(
+ COMMAND ${CMAKE_ARGV3} -w NoTests "___nonexistent_test___"
+ RESULT_VARIABLE ret
+ OUTPUT_VARIABLE out
+)
+
+message("${out}")
+
+if(NOT ${ret} MATCHES "^[0-9]+$")
+ message(FATAL_ERROR "${ret}")
+endif()
+
+if(${ret} EQUAL 0)
+ message(FATAL_ERROR "Expected nonzero return code")
+elseif(${out} MATCHES "Helper failed with")
+ message(FATAL_ERROR "Helper failed")
+endif()