summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2012-03-09 21:47:19 (GMT)
committerBrad King <brad.king@kitware.com>2012-03-12 13:33:21 (GMT)
commit55b2aa884cdb3df9a32152ee1df60e708d2c5ec9 (patch)
tree554b0b84015293df70ab77720ec3adf033c2e9ec /Tests/RunCMake
parenteb33000d75e0e41a2412db9a75597dbee6bfdad6 (diff)
downloadCMake-55b2aa884cdb3df9a32152ee1df60e708d2c5ec9.zip
CMake-55b2aa884cdb3df9a32152ee1df60e708d2c5ec9.tar.gz
CMake-55b2aa884cdb3df9a32152ee1df60e708d2c5ec9.tar.bz2
Use generalized RunCMake test infrastrucure for build_command test
The CMakeCommands.build_command test performs output/error checking so move it over to RunCMake to re-use the generalized infrastrucure. This is the only test left using Tests/CMakeCommands/CMakeLists.txt so remove it.
Diffstat (limited to 'Tests/RunCMake')
-rw-r--r--Tests/RunCMake/CMakeLists.txt1
-rw-r--r--Tests/RunCMake/build_command/CMakeLists.txt59
-rw-r--r--Tests/RunCMake/build_command/ErrorsOFF-stderr.txt1
-rw-r--r--Tests/RunCMake/build_command/ErrorsOFF-stdout.txt1
-rw-r--r--Tests/RunCMake/build_command/ErrorsOFF.cmake1
-rw-r--r--Tests/RunCMake/build_command/ErrorsON-result.txt1
-rw-r--r--Tests/RunCMake/build_command/ErrorsON-stderr.txt12
-rw-r--r--Tests/RunCMake/build_command/ErrorsON-stdout.txt1
-rw-r--r--Tests/RunCMake/build_command/ErrorsON.cmake1
-rw-r--r--Tests/RunCMake/build_command/RunCMakeTest.cmake4
10 files changed, 82 insertions, 0 deletions
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index 2dbb08e..63fc9f8 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -40,4 +40,5 @@ macro(add_RunCMake_test test)
)
endmacro()
+add_RunCMake_test(build_command)
add_RunCMake_test(find_package)
diff --git a/Tests/RunCMake/build_command/CMakeLists.txt b/Tests/RunCMake/build_command/CMakeLists.txt
new file mode 100644
index 0000000..0fbb948
--- /dev/null
+++ b/Tests/RunCMake/build_command/CMakeLists.txt
@@ -0,0 +1,59 @@
+cmake_minimum_required(VERSION 2.8)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
+
+# This CMakeLists file is *sometimes expected* to result in a configure error.
+#
+# expect this to succeed:
+# ../bin/Release/cmake -G Xcode
+# ../../CMake/Tests/CMakeCommands/build_command
+#
+# expect this to fail:
+# ../bin/Release/cmake -DTEST_ERROR_CONDITIONS:BOOL=ON -G Xcode
+# ../../CMake/Tests/CMakeCommands/build_command
+#
+# This project exists merely to test the CMake command 'build_command'...
+# ...even purposefully calling it with known-bad argument lists to cover
+# error handling code.
+#
+
+set(cmd "initial")
+
+message("0. begin")
+
+if(TEST_ERROR_CONDITIONS)
+ # Test with no arguments (an error):
+ build_command()
+ message("1. cmd='${cmd}'")
+
+ # Test with unknown arguments (also an error):
+ build_command(cmd BOGUS STUFF)
+ message("2. cmd='${cmd}'")
+
+ build_command(cmd STUFF BOGUS)
+ message("3. cmd='${cmd}'")
+else()
+ message("(skipping cases 1, 2 and 3 because TEST_ERROR_CONDITIONS is OFF)")
+endif()
+
+# Test the one arg signature with none of the optional KEYWORD arguments:
+build_command(cmd)
+message("4. cmd='${cmd}'")
+
+# Test the two-arg legacy signature:
+build_command(legacy_cmd ${CMAKE_BUILD_TOOL})
+message("5. legacy_cmd='${legacy_cmd}'")
+message(" CMAKE_BUILD_TOOL='${CMAKE_BUILD_TOOL}'")
+
+# Test the optional KEYWORDs:
+build_command(cmd CONFIGURATION hoohaaConfig)
+message("6. cmd='${cmd}'")
+
+build_command(cmd PROJECT_NAME hoohaaProject)
+message("7. cmd='${cmd}'")
+
+build_command(cmd TARGET hoohaaTarget)
+message("8. cmd='${cmd}'")
+
+set(cmd "final")
+message("9. cmd='${cmd}'")
diff --git a/Tests/RunCMake/build_command/ErrorsOFF-stderr.txt b/Tests/RunCMake/build_command/ErrorsOFF-stderr.txt
new file mode 100644
index 0000000..331885b
--- /dev/null
+++ b/Tests/RunCMake/build_command/ErrorsOFF-stderr.txt
@@ -0,0 +1 @@
+skipping cases 1, 2 and 3 because TEST_ERROR_CONDITIONS is OFF
diff --git a/Tests/RunCMake/build_command/ErrorsOFF-stdout.txt b/Tests/RunCMake/build_command/ErrorsOFF-stdout.txt
new file mode 100644
index 0000000..cf66a9d
--- /dev/null
+++ b/Tests/RunCMake/build_command/ErrorsOFF-stdout.txt
@@ -0,0 +1 @@
+Build files have been written to:
diff --git a/Tests/RunCMake/build_command/ErrorsOFF.cmake b/Tests/RunCMake/build_command/ErrorsOFF.cmake
new file mode 100644
index 0000000..a243fab
--- /dev/null
+++ b/Tests/RunCMake/build_command/ErrorsOFF.cmake
@@ -0,0 +1 @@
+set(TEST_ERROR_CONDITIONS OFF)
diff --git a/Tests/RunCMake/build_command/ErrorsON-result.txt b/Tests/RunCMake/build_command/ErrorsON-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/build_command/ErrorsON-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/build_command/ErrorsON-stderr.txt b/Tests/RunCMake/build_command/ErrorsON-stderr.txt
new file mode 100644
index 0000000..0be7475
--- /dev/null
+++ b/Tests/RunCMake/build_command/ErrorsON-stderr.txt
@@ -0,0 +1,12 @@
+CMake Error at CMakeLists.txt:[0-9]+ \(build_command\):
+ build_command requires at least one argument naming a CMake variable
+
++
+1. cmd='initial'
+CMake Error at CMakeLists.txt:[0-9]+ \(build_command\):
+ build_command unknown argument "BOGUS"
+
++
+2. cmd='initial'
+CMake Error at CMakeLists.txt:[0-9]+ \(build_command\):
+ build_command unknown argument "STUFF"
diff --git a/Tests/RunCMake/build_command/ErrorsON-stdout.txt b/Tests/RunCMake/build_command/ErrorsON-stdout.txt
new file mode 100644
index 0000000..841dd0d
--- /dev/null
+++ b/Tests/RunCMake/build_command/ErrorsON-stdout.txt
@@ -0,0 +1 @@
+Configuring incomplete, errors occurred!
diff --git a/Tests/RunCMake/build_command/ErrorsON.cmake b/Tests/RunCMake/build_command/ErrorsON.cmake
new file mode 100644
index 0000000..27814bf
--- /dev/null
+++ b/Tests/RunCMake/build_command/ErrorsON.cmake
@@ -0,0 +1 @@
+set(TEST_ERROR_CONDITIONS ON)
diff --git a/Tests/RunCMake/build_command/RunCMakeTest.cmake b/Tests/RunCMake/build_command/RunCMakeTest.cmake
new file mode 100644
index 0000000..4525c57
--- /dev/null
+++ b/Tests/RunCMake/build_command/RunCMakeTest.cmake
@@ -0,0 +1,4 @@
+include(RunCMake)
+
+run_cmake(ErrorsOFF)
+run_cmake(ErrorsON)