Merge topic 'move-command-line-tests'

4e039a9a Tests: Move more command line tests into RunCMake.CommandLine
This commit is contained in:
Brad King 2015-04-13 09:05:14 -04:00 committed by CMake Topic Stage
commit 341b8953b1
40 changed files with 108 additions and 94 deletions

View File

@ -1095,21 +1095,6 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
"${CMake_BINARY_DIR}/Tests/CMakeTestAllGenerators")
endif()
if(NOT DEFINED CTEST_RUN_CMakeTestBadCommandLines)
set(CTEST_RUN_CMakeTestBadCommandLines ON)
endif()
if(CTEST_RUN_CMakeTestBadCommandLines)
add_test(CMakeTestBadCommandLines ${CMAKE_CMAKE_COMMAND}
-D dir=${CMake_BINARY_DIR}/Tests/CMakeTestBadCommandLines
-D gen=${CMAKE_GENERATOR}
-D CMake_SOURCE_DIR=${CMake_SOURCE_DIR}
-P ${CMake_SOURCE_DIR}/Tests/CMakeTestBadCommandLines/RunCMake.cmake
)
list(APPEND TEST_BUILD_DIRS
"${CMake_BINARY_DIR}/Tests/CMakeTestBadCommandLines")
endif()
if(NOT DEFINED CTEST_RUN_CMakeTestMultipleConfigures)
set(CTEST_RUN_CMakeTestMultipleConfigures ON)
endif()

View File

@ -1,79 +0,0 @@
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)")
# First setup a source tree to run CMake on.
#
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMake_SOURCE_DIR}/Tests/CTestTest/SmallAndFast
${dir}/Source
)
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory
${dir}/Build
)
function(RunCMakeWithArgs)
message(STATUS "info: running cmake with ARGN='${ARGN}'")
execute_process(COMMAND ${CMAKE_COMMAND} ${ARGN}
RESULT_VARIABLE result
OUTPUT_VARIABLE stdout
ERROR_VARIABLE stderr
WORKING_DIRECTORY ${dir}/Build
)
message(STATUS "result='${result}'")
message(STATUS "stdout='${stdout}'")
message(STATUS "stderr='${stderr}'")
message(STATUS "")
endfunction()
# Run cmake once with no errors to get a good build tree:
#
RunCMakeWithArgs(-G ${gen} ../Source)
# Run cmake with args that produce some sort of problem to cover the error
# cases in cmake.cxx...
#
# (These are not good examples of cmake command lines. Do not copy and
# paste them elsewhere and expect them to work... See the cmake
# documentation or other real examples of usage instead.)
#
RunCMakeWithArgs()
RunCMakeWithArgs(-C)
RunCMakeWithArgs(-C nosuchcachefile.txt)
RunCMakeWithArgs(--check-stamp-file nostampfile)
RunCMakeWithArgs(--check-stamp-list nostamplist)
RunCMakeWithArgs(nosuchsubdir/CMakeCache.txt)
RunCMakeWithArgs(nosuchsubdir/CMakeLists.txt)
RunCMakeWithArgs(-D)
RunCMakeWithArgs(--debug-output .)
RunCMakeWithArgs(--debug-trycompile .)
RunCMakeWithArgs(-E)
RunCMakeWithArgs(-E create_symlink)
RunCMakeWithArgs(-E echo_append)
RunCMakeWithArgs(-E rename)
RunCMakeWithArgs(-E touch_nocreate)
RunCMakeWithArgs(-G)
RunCMakeWithArgs(--graphviz= ../Source)
RunCMakeWithArgs(--graphviz=g.dot .)
RunCMakeWithArgs(-P)
RunCMakeWithArgs(-P nosuchscriptfile.cmake)
RunCMakeWithArgs(--trace .)
RunCMakeWithArgs(-U)
RunCMakeWithArgs(-U nosuchvariable .)
RunCMakeWithArgs(-V)
RunCMakeWithArgs(-V .)
RunCMakeWithArgs(-Wno-dev .)
RunCMakeWithArgs(-Wdev .)

View File

@ -0,0 +1 @@
1

View File

@ -0,0 +1,2 @@
^CMake Error: -C must be followed by a file name.
CMake Error: Problem processing arguments. Aborting.$

View File

@ -0,0 +1 @@
1

View File

@ -0,0 +1,3 @@
^CMake Error: Error processing file: nosuchcachefile.txt
CMake Error: The source directory ".*/Tests/RunCMake/CommandLine/C-no-file-build/nosuchcachefile.txt" does not exist.
Specify --help for usage, or press the help button on the CMake GUI.$

View File

@ -0,0 +1 @@
1

View File

@ -0,0 +1,2 @@
^CMake Error: -D must be followed with VAR=VALUE.
CMake Error: Problem processing arguments. Aborting.$

View File

@ -0,0 +1 @@
1

View File

@ -0,0 +1,3 @@
^CMake Error: cmake version .*
Usage: .* -E \[command\] \[arguments ...\]
Available commands:

View File

@ -0,0 +1 @@
1

View File

@ -0,0 +1,3 @@
^CMake Error: cmake version .*
Usage: .* -E \[command\] \[arguments ...\]
Available commands:

View File

@ -0,0 +1 @@
1

View File

@ -0,0 +1,3 @@
^CMake Error: cmake version .*
Usage: .* -E \[command\] \[arguments ...\]
Available commands:

View File

@ -0,0 +1 @@
1

View File

@ -0,0 +1,3 @@
^CMake Error: cmake version .*
Usage: .* -E \[command\] \[arguments ...\]
Available commands:

View File

@ -0,0 +1 @@
1

View File

@ -0,0 +1 @@
^CMake Error: Could not create named generator NoSuchGenerator$

View File

@ -0,0 +1 @@
1

View File

@ -0,0 +1 @@
^CMake Error: No generator specified for -G$

View File

@ -0,0 +1,10 @@
^Usage
cmake \[options\] <path-to-source>
cmake \[options\] <path-to-existing-build>
Specify a source directory to \(re-\)generate a build system for it in the
current working directory. Specify an existing build directory to
re-generate its build system.
Run 'cmake --help' for more information.$

View File

@ -0,0 +1 @@
1

View File

@ -0,0 +1 @@
^CMake Error: No script specified for argument -P$

View File

@ -0,0 +1 @@
1

View File

@ -0,0 +1 @@
^CMake Error: Error processing file: nosuchscriptfile.cmake$

View File

@ -1,5 +1,22 @@
include(RunCMake)
run_cmake_command(NoArgs ${CMAKE_COMMAND})
run_cmake_command(C-no-arg ${CMAKE_COMMAND} -C)
run_cmake_command(C-no-file ${CMAKE_COMMAND} -C nosuchcachefile.txt)
run_cmake_command(cache-no-file ${CMAKE_COMMAND} nosuchsubdir/CMakeCache.txt)
run_cmake_command(lists-no-file ${CMAKE_COMMAND} nosuchsubdir/CMakeLists.txt)
run_cmake_command(D-no-arg ${CMAKE_COMMAND} -D)
run_cmake_command(U-no-arg ${CMAKE_COMMAND} -U)
run_cmake_command(E-no-arg ${CMAKE_COMMAND} -E)
run_cmake_command(E_echo_append ${CMAKE_COMMAND} -E echo_append)
run_cmake_command(E_rename-no-arg ${CMAKE_COMMAND} -E rename)
run_cmake_command(E_touch_nocreate-no-arg ${CMAKE_COMMAND} -E touch_nocreate)
run_cmake_command(G_no-arg ${CMAKE_COMMAND} -G)
run_cmake_command(G_bad-arg ${CMAKE_COMMAND} -G NoSuchGenerator)
run_cmake_command(P_no-arg ${CMAKE_COMMAND} -P)
run_cmake_command(P_no-file ${CMAKE_COMMAND} -P nosuchscriptfile.cmake)
run_cmake_command(build-no-cache
${CMAKE_COMMAND} --build ${RunCMake_SOURCE_DIR})
run_cmake_command(build-no-generator
@ -24,6 +41,9 @@ if(RunCMake_GENERATOR STREQUAL "Ninja")
endif()
if(UNIX)
run_cmake_command(E_create_symlink-no-arg
${CMAKE_COMMAND} -E create_symlink
)
run_cmake_command(E_create_symlink-missing-dir
${CMAKE_COMMAND} -E create_symlink T missing-dir/L
)
@ -70,6 +90,26 @@ set(RunCMake_TEST_OPTIONS
"-DFOO:STRING=-DBAR:BOOL=BAZ")
run_cmake(D_typed_nested_cache)
set(RunCMake_TEST_OPTIONS -Wno-dev)
run_cmake(Wno-dev)
unset(RunCMake_TEST_OPTIONS)
set(RunCMake_TEST_OPTIONS -Wno-dev -Wdev)
run_cmake(Wdev)
unset(RunCMake_TEST_OPTIONS)
set(RunCMake_TEST_OPTIONS --debug-output)
run_cmake(debug-output)
unset(RunCMake_TEST_OPTIONS)
set(RunCMake_TEST_OPTIONS --trace)
run_cmake(trace)
unset(RunCMake_TEST_OPTIONS)
set(RunCMake_TEST_OPTIONS --debug-trycompile)
run_cmake(debug-trycompile)
unset(RunCMake_TEST_OPTIONS)
function(run_cmake_depends)
set(RunCMake_TEST_SOURCE_DIR "${RunCMake_SOURCE_DIR}/cmake_depends")
set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/cmake_depends-build")

View File

@ -0,0 +1 @@
1

View File

@ -0,0 +1,2 @@
^CMake Error: -U must be followed with VAR.
CMake Error: Problem processing arguments. Aborting.$

View File

@ -0,0 +1,5 @@
^CMake Warning \(dev\) at Wdev.cmake:1 \(message\):
Some Author Warning
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
This warning is for project developers. Use -Wno-dev to suppress it.$

View File

@ -0,0 +1 @@
message(AUTHOR_WARNING "Some Author Warning")

View File

@ -0,0 +1 @@
message(AUTHOR_WARNING "Some Author Warning")

View File

@ -0,0 +1 @@
1

View File

@ -0,0 +1,2 @@
^CMake Error: The source directory ".*/Tests/RunCMake/CommandLine/cache-no-file-build/nosuchsubdir" does not exist.
Specify --help for usage, or press the help button on the CMake GUI.$

View File

@ -0,0 +1 @@
Running with debug output on.

View File

@ -0,0 +1,5 @@
enable_language(C)
# Look for a source tree left by enable_language internal checks.
if(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/CMakeTmp/CMakeLists.txt)
message(FATAL_ERROR "--debug-trycompile should leave the source behind")
endif()

View File

@ -0,0 +1 @@
1

View File

@ -0,0 +1,2 @@
^CMake Error: The source directory ".*/Tests/RunCMake/CommandLine/lists-no-file-build/nosuchsubdir" does not exist.
Specify --help for usage, or press the help button on the CMake GUI.$

View File

@ -0,0 +1,2 @@
^.*/Tests/RunCMake/CommandLine/CMakeLists.txt\(1\): cmake_minimum_required\(VERSION 3.0 \)
.*/Tests/RunCMake/CommandLine/CMakeLists.txt\(2\): project\(\${RunCMake_TEST} NONE \)

View File