From 361696ae2073b537545755e8ef765d080490d244 Mon Sep 17 00:00:00 2001
From: David Cole <david.cole@kitware.com>
Date: Mon, 25 Jun 2012 08:25:51 -0400
Subject: CTest: Add test to verify -D variable definitions work

---
 Tests/CMakeLists.txt                   | 13 +++++++++++++
 Tests/CTestConfig/ScriptWithArgs.cmake | 16 ++++++++++++++++
 2 files changed, 29 insertions(+)
 create mode 100644 Tests/CTestConfig/ScriptWithArgs.cmake

diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index 9deb8ac..300ab09 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -1822,6 +1822,19 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/
   add_config_tests(Release)
   add_config_tests(RelWithDebInfo)
 
+  # Test -S script with some -D variable definition args to ctest:
+  add_test(CTestConfig.ScriptWithArgs ${CMAKE_CTEST_COMMAND}
+    -C "Release"
+    -D arg1=this
+    -D arg2=that
+    -D "arg3=the other"
+    "-Darg4=this is the fourth"
+    -Darg5=the_fifth
+    -Darg6:STRING=value-with-type
+    -S "${CMake_SOURCE_DIR}/Tests/CTestConfig/ScriptWithArgs.cmake" -VV
+    --output-log "${CMake_BINARY_DIR}/Tests/CTestConfig/ScriptWithArgs.log"
+    )
+
   ADD_TEST_MACRO(CMakeCommands.target_link_libraries target_link_libraries)
 
   CONFIGURE_FILE(
diff --git a/Tests/CTestConfig/ScriptWithArgs.cmake b/Tests/CTestConfig/ScriptWithArgs.cmake
new file mode 100644
index 0000000..79896a7
--- /dev/null
+++ b/Tests/CTestConfig/ScriptWithArgs.cmake
@@ -0,0 +1,16 @@
+set(CTEST_RUN_CURRENT_SCRIPT 0)
+
+macro(check_arg name expected_value)
+  message("${name}='${${name}}'")
+  if(NOT "${${name}}" STREQUAL "${expected_value}")
+    message(FATAL_ERROR "unexpected ${name} value '${${name}}', expected '${expected_value}'")
+  endif()
+endmacro()
+
+check_arg(arg1 "this")
+check_arg(arg2 "that")
+check_arg(arg3 "the other")
+check_arg(arg4 "this is the fourth")
+check_arg(arg5 "the_fifth")
+check_arg(arg6 "value-with-type")
+check_arg(arg7 "")
-- 
cgit v0.12