summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
Diffstat (limited to 'Tests')
-rw-r--r--Tests/CMakeLists.txt3
-rw-r--r--Tests/FindJsonCpp/CMakeLists.txt10
-rw-r--r--Tests/FindJsonCpp/Test/CMakeLists.txt14
-rw-r--r--Tests/FindJsonCpp/Test/main.cxx8
-rw-r--r--Tests/RunCMake/CMakeLists.txt1
-rw-r--r--Tests/RunCMake/CTestSubmit/BadArg-result.txt1
-rw-r--r--Tests/RunCMake/CTestSubmit/BadArg-stderr.txt2
-rw-r--r--Tests/RunCMake/CTestSubmit/BadFILES-result.txt1
-rw-r--r--Tests/RunCMake/CTestSubmit/BadFILES-stderr.txt2
-rw-r--r--Tests/RunCMake/CTestSubmit/BadPARTS-result.txt1
-rw-r--r--Tests/RunCMake/CTestSubmit/BadPARTS-stderr.txt2
-rw-r--r--Tests/RunCMake/CTestSubmit/CMakeLists.txt.in4
-rw-r--r--Tests/RunCMake/CTestSubmit/CTestConfig.cmake.in5
-rw-r--r--Tests/RunCMake/CTestSubmit/RepeatRETURN_VALUE-result.txt1
-rw-r--r--Tests/RunCMake/CTestSubmit/RepeatRETURN_VALUE-stderr.txt2
-rw-r--r--Tests/RunCMake/CTestSubmit/RunCMakeTest.cmake43
-rw-r--r--Tests/RunCMake/CTestSubmit/test.cmake.in16
17 files changed, 116 insertions, 0 deletions
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index dea30e4..3aecd9b 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -1247,6 +1247,9 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
if(CMake_TEST_FindGSL)
add_subdirectory(FindGSL)
endif()
+ if(CMake_TEST_FindJsonCpp)
+ add_subdirectory(FindJsonCpp)
+ endif()
find_package(GTK2 QUIET)
if(GTK2_FOUND)
diff --git a/Tests/FindJsonCpp/CMakeLists.txt b/Tests/FindJsonCpp/CMakeLists.txt
new file mode 100644
index 0000000..9a1fa38
--- /dev/null
+++ b/Tests/FindJsonCpp/CMakeLists.txt
@@ -0,0 +1,10 @@
+add_test(NAME FindJsonCpp.Test COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindJsonCpp/Test"
+ "${CMake_BINARY_DIR}/Tests/FindJsonCpp/Test"
+ ${build_generator_args}
+ --build-project TestFindJsonCpp
+ --build-options ${build_options}
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
diff --git a/Tests/FindJsonCpp/Test/CMakeLists.txt b/Tests/FindJsonCpp/Test/CMakeLists.txt
new file mode 100644
index 0000000..4e1e271
--- /dev/null
+++ b/Tests/FindJsonCpp/Test/CMakeLists.txt
@@ -0,0 +1,14 @@
+cmake_minimum_required(VERSION 3.1)
+project(TestFindJsonCpp CXX)
+include(CTest)
+
+find_package(JsonCpp REQUIRED)
+
+add_executable(test_jsoncpp_tgt main.cxx)
+target_link_libraries(test_jsoncpp_tgt JsonCpp::JsonCpp)
+add_test(NAME test_jsoncpp_tgt COMMAND test_jsoncpp_tgt)
+
+add_executable(test_jsoncpp_var main.cxx)
+target_include_directories(test_jsoncpp_var PRIVATE ${JsonCpp_INCLUDE_DIRS})
+target_link_libraries(test_jsoncpp_var PRIVATE ${JsonCpp_LIBRARIES})
+add_test(NAME test_jsoncpp_var COMMAND test_jsoncpp_var)
diff --git a/Tests/FindJsonCpp/Test/main.cxx b/Tests/FindJsonCpp/Test/main.cxx
new file mode 100644
index 0000000..0fefe32
--- /dev/null
+++ b/Tests/FindJsonCpp/Test/main.cxx
@@ -0,0 +1,8 @@
+#include <json/json.h>
+
+int main()
+{
+ int zero = 0;
+ Json::Value value(zero);
+ return value.asInt();
+}
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index 1697025..3a61751 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -52,6 +52,7 @@ add_RunCMake_test(CMP0053)
add_RunCMake_test(CMP0054)
add_RunCMake_test(CMP0055)
add_RunCMake_test(CTest)
+add_RunCMake_test(CTestSubmit)
if(NOT CMake_TEST_EXTERNAL_CMAKE)
add_RunCMake_test(CTestMemcheck
diff --git a/Tests/RunCMake/CTestSubmit/BadArg-result.txt b/Tests/RunCMake/CTestSubmit/BadArg-result.txt
new file mode 100644
index 0000000..b57e2de
--- /dev/null
+++ b/Tests/RunCMake/CTestSubmit/BadArg-result.txt
@@ -0,0 +1 @@
+(-1|255)
diff --git a/Tests/RunCMake/CTestSubmit/BadArg-stderr.txt b/Tests/RunCMake/CTestSubmit/BadArg-stderr.txt
new file mode 100644
index 0000000..68812ab
--- /dev/null
+++ b/Tests/RunCMake/CTestSubmit/BadArg-stderr.txt
@@ -0,0 +1,2 @@
+CMake Error at .*/Tests/RunCMake/CTestSubmit/BadArg/test.cmake:[0-9]+ \(ctest_submit\):
+ ctest_submit called with unknown argument "bad-arg".
diff --git a/Tests/RunCMake/CTestSubmit/BadFILES-result.txt b/Tests/RunCMake/CTestSubmit/BadFILES-result.txt
new file mode 100644
index 0000000..b57e2de
--- /dev/null
+++ b/Tests/RunCMake/CTestSubmit/BadFILES-result.txt
@@ -0,0 +1 @@
+(-1|255)
diff --git a/Tests/RunCMake/CTestSubmit/BadFILES-stderr.txt b/Tests/RunCMake/CTestSubmit/BadFILES-stderr.txt
new file mode 100644
index 0000000..703224b
--- /dev/null
+++ b/Tests/RunCMake/CTestSubmit/BadFILES-stderr.txt
@@ -0,0 +1,2 @@
+CMake Error at .*/Tests/RunCMake/CTestSubmit/BadFILES/test.cmake:[0-9]+ \(ctest_submit\):
+ File "bad-file" does not exist. Cannot submit a non-existent file.
diff --git a/Tests/RunCMake/CTestSubmit/BadPARTS-result.txt b/Tests/RunCMake/CTestSubmit/BadPARTS-result.txt
new file mode 100644
index 0000000..b57e2de
--- /dev/null
+++ b/Tests/RunCMake/CTestSubmit/BadPARTS-result.txt
@@ -0,0 +1 @@
+(-1|255)
diff --git a/Tests/RunCMake/CTestSubmit/BadPARTS-stderr.txt b/Tests/RunCMake/CTestSubmit/BadPARTS-stderr.txt
new file mode 100644
index 0000000..4e491a9
--- /dev/null
+++ b/Tests/RunCMake/CTestSubmit/BadPARTS-stderr.txt
@@ -0,0 +1,2 @@
+CMake Error at .*/Tests/RunCMake/CTestSubmit/BadPARTS/test.cmake:[0-9]+ \(ctest_submit\):
+ Part name "bad-part" is invalid.
diff --git a/Tests/RunCMake/CTestSubmit/CMakeLists.txt.in b/Tests/RunCMake/CTestSubmit/CMakeLists.txt.in
new file mode 100644
index 0000000..96e6c13
--- /dev/null
+++ b/Tests/RunCMake/CTestSubmit/CMakeLists.txt.in
@@ -0,0 +1,4 @@
+cmake_minimum_required(VERSION 3.1)
+project(CTestSubmit@CASE_NAME@ NONE)
+include(CTest)
+add_test(NAME RunCMakeVersion COMMAND "${CMAKE_COMMAND}" --version)
diff --git a/Tests/RunCMake/CTestSubmit/CTestConfig.cmake.in b/Tests/RunCMake/CTestSubmit/CTestConfig.cmake.in
new file mode 100644
index 0000000..f0e1653
--- /dev/null
+++ b/Tests/RunCMake/CTestSubmit/CTestConfig.cmake.in
@@ -0,0 +1,5 @@
+set(CTEST_PROJECT_NAME "CTestSubmit@CASE_NAME@")
+
+# Intentionally leave out other upload-related CTestConfig.cmake settings
+# so that any ctest_submit calls fail with an error message.
+set(CTEST_DROP_METHOD "@CASE_DROP_METHOD@")
diff --git a/Tests/RunCMake/CTestSubmit/RepeatRETURN_VALUE-result.txt b/Tests/RunCMake/CTestSubmit/RepeatRETURN_VALUE-result.txt
new file mode 100644
index 0000000..b57e2de
--- /dev/null
+++ b/Tests/RunCMake/CTestSubmit/RepeatRETURN_VALUE-result.txt
@@ -0,0 +1 @@
+(-1|255)
diff --git a/Tests/RunCMake/CTestSubmit/RepeatRETURN_VALUE-stderr.txt b/Tests/RunCMake/CTestSubmit/RepeatRETURN_VALUE-stderr.txt
new file mode 100644
index 0000000..d56793e
--- /dev/null
+++ b/Tests/RunCMake/CTestSubmit/RepeatRETURN_VALUE-stderr.txt
@@ -0,0 +1,2 @@
+CMake Error at .*/Tests/RunCMake/CTestSubmit/RepeatRETURN_VALUE/test.cmake:[0-9]+ \(ctest_submit\):
+ Called with more than one value for RETURN_VALUE
diff --git a/Tests/RunCMake/CTestSubmit/RunCMakeTest.cmake b/Tests/RunCMake/CTestSubmit/RunCMakeTest.cmake
new file mode 100644
index 0000000..6f18563
--- /dev/null
+++ b/Tests/RunCMake/CTestSubmit/RunCMakeTest.cmake
@@ -0,0 +1,43 @@
+include(RunCMake)
+
+# Default case parameters.
+set(CASE_DROP_METHOD "http")
+set(CASE_CTEST_SUBMIT_ARGS "")
+
+function(run_ctest CASE_NAME)
+ configure_file(${RunCMake_SOURCE_DIR}/test.cmake.in
+ ${RunCMake_BINARY_DIR}/${CASE_NAME}/test.cmake @ONLY)
+ configure_file(${RunCMake_SOURCE_DIR}/CTestConfig.cmake.in
+ ${RunCMake_BINARY_DIR}/${CASE_NAME}/CTestConfig.cmake @ONLY)
+ configure_file(${RunCMake_SOURCE_DIR}/CMakeLists.txt.in
+ ${RunCMake_BINARY_DIR}/${CASE_NAME}/CMakeLists.txt @ONLY)
+ run_cmake_command(${CASE_NAME} ${CMAKE_CTEST_COMMAND}
+ -C Debug
+ -S ${RunCMake_BINARY_DIR}/${CASE_NAME}/test.cmake
+ -V
+ --output-log ${RunCMake_BINARY_DIR}/${CASE_NAME}-build/testOutput.log
+ ${ARGN}
+ )
+endfunction()
+
+#-----------------------------------------------------------------------------
+# Test bad argument combinations.
+
+function(run_ctest_submit CASE_NAME)
+ set(CASE_CTEST_SUBMIT_ARGS "${ARGN}")
+ run_ctest(${CASE_NAME})
+endfunction()
+
+run_ctest_submit(BadArg bad-arg)
+run_ctest_submit(BadPARTS PARTS bad-part)
+run_ctest_submit(BadFILES FILES bad-file)
+run_ctest_submit(RepeatRETURN_VALUE RETURN_VALUE res RETURN_VALUE res)
+
+#-----------------------------------------------------------------------------
+# Test failed drops by various protocols
+
+function(run_ctest_submit_FailDrop CASE_DROP_METHOD)
+ run_ctest(FailDrop-${CASE_DROP_METHOD})
+endfunction()
+
+# TODO: call run_ctest_submit_FailDrop() for each submission protocol
diff --git a/Tests/RunCMake/CTestSubmit/test.cmake.in b/Tests/RunCMake/CTestSubmit/test.cmake.in
new file mode 100644
index 0000000..ba826f1
--- /dev/null
+++ b/Tests/RunCMake/CTestSubmit/test.cmake.in
@@ -0,0 +1,16 @@
+cmake_minimum_required(VERSION 3.1)
+
+set(CTEST_SITE "test-site")
+set(CTEST_BUILD_NAME "test-build-name")
+set(CTEST_SOURCE_DIRECTORY "@RunCMake_BINARY_DIR@/@CASE_NAME@")
+set(CTEST_BINARY_DIRECTORY "@RunCMake_BINARY_DIR@/@CASE_NAME@-build")
+set(CTEST_CMAKE_GENERATOR "@RunCMake_GENERATOR@")
+set(CTEST_CMAKE_GENERATOR_PLATFORM "@RunCMake_GENERATOR_PLATFORM@")
+set(CTEST_CMAKE_GENERATOR_TOOLSET "@RunCMake_GENERATOR_TOOLSET@")
+set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}")
+
+ctest_start(Experimental)
+ctest_configure()
+
+set(ctest_submit_args "@CASE_CTEST_SUBMIT_ARGS@")
+ctest_submit(${ctest_submit_args})