diff options
author | David Cole <david.cole@kitware.com> | 2009-12-04 17:09:01 (GMT) |
---|---|---|
committer | David Cole <david.cole@kitware.com> | 2009-12-04 17:09:01 (GMT) |
commit | 0b38bb4c535ae972d7f973e3e69945a6d0c14d75 (patch) | |
tree | ac80395b194b2a8ed2bcf6b1f997b62c21d151be /Tests/CMakeCommands | |
parent | af14f1f2c3750ba3cf9b9cc1a809a88b1878a5c3 (diff) | |
download | CMake-0b38bb4c535ae972d7f973e3e69945a6d0c14d75.zip CMake-0b38bb4c535ae972d7f973e3e69945a6d0c14d75.tar.gz CMake-0b38bb4c535ae972d7f973e3e69945a6d0c14d75.tar.bz2 |
Fix issue #2336 - honor the -C arg to ctest. Honor it for all stages of running -D dashboards from the command line and running ctest_configure, ctest_build and ctest_test commands in -S scripts. Also, allow a script to change it by setting the CTEST_CONFIGURATION_TYPE variable: allows for multiple configuration build/test cycles within one script. Add a new signature for the cmake command build_command that accepts CONFIGURATION as one argument. The original build_command signature is still there, but now marked as deprecated in the documentation. Of course... also add CTestConfig tests to verify that -C is honored for -D dashboards and -S scripts.
Diffstat (limited to 'Tests/CMakeCommands')
-rw-r--r-- | Tests/CMakeCommands/build_command/CMakeLists.txt | 58 | ||||
-rw-r--r-- | Tests/CMakeCommands/build_command/RunCMake.cmake | 86 |
2 files changed, 144 insertions, 0 deletions
diff --git a/Tests/CMakeCommands/build_command/CMakeLists.txt b/Tests/CMakeCommands/build_command/CMakeLists.txt new file mode 100644 index 0000000..990ac90 --- /dev/null +++ b/Tests/CMakeCommands/build_command/CMakeLists.txt @@ -0,0 +1,58 @@ +# 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. +# +cmake_minimum_required(VERSION 2.8) +project(test_build_command) + +set(cmd "initial") + +message("CTEST_FULL_OUTPUT") +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/CMakeCommands/build_command/RunCMake.cmake b/Tests/CMakeCommands/build_command/RunCMake.cmake new file mode 100644 index 0000000..55d9359 --- /dev/null +++ b/Tests/CMakeCommands/build_command/RunCMake.cmake @@ -0,0 +1,86 @@ +if(NOT DEFINED CMake_SOURCE_DIR) + message(FATAL_ERROR "CMake_SOURCE_DIR not defined") +endif() + +if(NOT DEFINED dir) + message(FATAL_ERROR "dir not defined") +endif() + +if(NOT DEFINED gen) + message(FATAL_ERROR "gen not defined") +endif() + +message(STATUS "CTEST_FULL_OUTPUT (Avoid ctest truncation of output)") + +# Run cmake: +# +function(run_cmake build_dir extra_args expected_result expected_output expected_error) + message(STATUS "run_cmake build_dir='${build_dir}' extra_args='${extra_args}'") + + # Ensure build_dir exists: + # + execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${build_dir}) + + # Run cmake: + # + execute_process(COMMAND ${CMAKE_COMMAND} + ${extra_args} + -G ${gen} ${CMake_SOURCE_DIR}/Tests/CMakeCommands/build_command + RESULT_VARIABLE result + OUTPUT_VARIABLE stdout + ERROR_VARIABLE stderr + WORKING_DIRECTORY ${build_dir} + ) + + message(STATUS "result='${result}'") + message(STATUS "stdout='${stdout}'") + message(STATUS "stderr='${stderr}'") + message(STATUS "") + + # Verify result and output match expectations: + # + if("0" STREQUAL "${expected_result}") + if(NOT "${result}" STREQUAL "0") + message(FATAL_ERROR + "error: result='${result}' is non-zero and different than expected_result='${expected_result}'") + endif() + else() + if("${result}" STREQUAL "0") + message(FATAL_ERROR + "error: result='${result}' is zero and different than expected_result='${expected_result}'") + endif() + endif() + + foreach(e ${expected_output}) + if(NOT stdout MATCHES "${e}") + message(FATAL_ERROR + "error: stdout does not match expected_output item e='${e}'") + else() + message(STATUS "info: stdout matches '${e}'") + endif() + endforeach() + + foreach(e ${expected_error}) + if(NOT stderr MATCHES "${e}") + message(FATAL_ERROR + "error: stderr does not match expected_error item e='${e}'") + else() + message(STATUS "info: stderr matches '${e}'") + endif() + endforeach() + + message(STATUS "result, stdout and stderr match all expectations: test passes") + message(STATUS "") +endfunction() + + +# Expect this case to succeed: +run_cmake("${dir}/b1" "" 0 + "Build files have been written to:" + "skipping cases 1, 2 and 3 because TEST_ERROR_CONDITIONS is OFF") + + +# Expect this one to fail: +run_cmake("${dir}/b2" "-DTEST_ERROR_CONDITIONS:BOOL=ON" 1 + "Configuring incomplete, errors occurred!" + "build_command requires at least one argument naming a CMake variable;build_command unknown argument ") |