Browse Source

Tests: Move more command line tests into RunCMake.CommandLine

Port most CMakeTestBadCommandLines test cases to RunCMake.CommandLine
and drop the former test.  Add validation of expected results, which was
not done by the old test.
Brad King 10 years ago
parent
commit
4e039a9a98
40 changed files with 108 additions and 94 deletions
  1. 0 15
      Tests/CMakeLists.txt
  2. 0 79
      Tests/CMakeTestBadCommandLines/RunCMake.cmake
  3. 1 0
      Tests/RunCMake/CommandLine/C-no-arg-result.txt
  4. 2 0
      Tests/RunCMake/CommandLine/C-no-arg-stderr.txt
  5. 1 0
      Tests/RunCMake/CommandLine/C-no-file-result.txt
  6. 3 0
      Tests/RunCMake/CommandLine/C-no-file-stderr.txt
  7. 1 0
      Tests/RunCMake/CommandLine/D-no-arg-result.txt
  8. 2 0
      Tests/RunCMake/CommandLine/D-no-arg-stderr.txt
  9. 1 0
      Tests/RunCMake/CommandLine/E-no-arg-result.txt
  10. 3 0
      Tests/RunCMake/CommandLine/E-no-arg-stderr.txt
  11. 1 0
      Tests/RunCMake/CommandLine/E_create_symlink-no-arg-result.txt
  12. 3 0
      Tests/RunCMake/CommandLine/E_create_symlink-no-arg-stderr.txt
  13. 1 0
      Tests/RunCMake/CommandLine/E_rename-no-arg-result.txt
  14. 3 0
      Tests/RunCMake/CommandLine/E_rename-no-arg-stderr.txt
  15. 1 0
      Tests/RunCMake/CommandLine/E_touch_nocreate-no-arg-result.txt
  16. 3 0
      Tests/RunCMake/CommandLine/E_touch_nocreate-no-arg-stderr.txt
  17. 1 0
      Tests/RunCMake/CommandLine/G_bad-arg-result.txt
  18. 1 0
      Tests/RunCMake/CommandLine/G_bad-arg-stderr.txt
  19. 1 0
      Tests/RunCMake/CommandLine/G_no-arg-result.txt
  20. 1 0
      Tests/RunCMake/CommandLine/G_no-arg-stderr.txt
  21. 10 0
      Tests/RunCMake/CommandLine/NoArgs-stdout.txt
  22. 1 0
      Tests/RunCMake/CommandLine/P_no-arg-result.txt
  23. 1 0
      Tests/RunCMake/CommandLine/P_no-arg-stderr.txt
  24. 1 0
      Tests/RunCMake/CommandLine/P_no-file-result.txt
  25. 1 0
      Tests/RunCMake/CommandLine/P_no-file-stderr.txt
  26. 40 0
      Tests/RunCMake/CommandLine/RunCMakeTest.cmake
  27. 1 0
      Tests/RunCMake/CommandLine/U-no-arg-result.txt
  28. 2 0
      Tests/RunCMake/CommandLine/U-no-arg-stderr.txt
  29. 5 0
      Tests/RunCMake/CommandLine/Wdev-stderr.txt
  30. 1 0
      Tests/RunCMake/CommandLine/Wdev.cmake
  31. 1 0
      Tests/RunCMake/CommandLine/Wno-dev.cmake
  32. 1 0
      Tests/RunCMake/CommandLine/cache-no-file-result.txt
  33. 2 0
      Tests/RunCMake/CommandLine/cache-no-file-stderr.txt
  34. 1 0
      Tests/RunCMake/CommandLine/debug-output-stdout.txt
  35. 0 0
      Tests/RunCMake/CommandLine/debug-output.cmake
  36. 5 0
      Tests/RunCMake/CommandLine/debug-trycompile.cmake
  37. 1 0
      Tests/RunCMake/CommandLine/lists-no-file-result.txt
  38. 2 0
      Tests/RunCMake/CommandLine/lists-no-file-stderr.txt
  39. 2 0
      Tests/RunCMake/CommandLine/trace-stderr.txt
  40. 0 0
      Tests/RunCMake/CommandLine/trace.cmake

+ 0 - 15
Tests/CMakeLists.txt

@@ -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()

+ 0 - 79
Tests/CMakeTestBadCommandLines/RunCMake.cmake

@@ -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 .)

+ 1 - 0
Tests/RunCMake/CommandLine/C-no-arg-result.txt

@@ -0,0 +1 @@
+1

+ 2 - 0
Tests/RunCMake/CommandLine/C-no-arg-stderr.txt

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

+ 1 - 0
Tests/RunCMake/CommandLine/C-no-file-result.txt

@@ -0,0 +1 @@
+1

+ 3 - 0
Tests/RunCMake/CommandLine/C-no-file-stderr.txt

@@ -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.$

+ 1 - 0
Tests/RunCMake/CommandLine/D-no-arg-result.txt

@@ -0,0 +1 @@
+1

+ 2 - 0
Tests/RunCMake/CommandLine/D-no-arg-stderr.txt

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

+ 1 - 0
Tests/RunCMake/CommandLine/E-no-arg-result.txt

@@ -0,0 +1 @@
+1

+ 3 - 0
Tests/RunCMake/CommandLine/E-no-arg-stderr.txt

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

+ 1 - 0
Tests/RunCMake/CommandLine/E_create_symlink-no-arg-result.txt

@@ -0,0 +1 @@
+1

+ 3 - 0
Tests/RunCMake/CommandLine/E_create_symlink-no-arg-stderr.txt

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

+ 1 - 0
Tests/RunCMake/CommandLine/E_rename-no-arg-result.txt

@@ -0,0 +1 @@
+1

+ 3 - 0
Tests/RunCMake/CommandLine/E_rename-no-arg-stderr.txt

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

+ 1 - 0
Tests/RunCMake/CommandLine/E_touch_nocreate-no-arg-result.txt

@@ -0,0 +1 @@
+1

+ 3 - 0
Tests/RunCMake/CommandLine/E_touch_nocreate-no-arg-stderr.txt

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

+ 1 - 0
Tests/RunCMake/CommandLine/G_bad-arg-result.txt

@@ -0,0 +1 @@
+1

+ 1 - 0
Tests/RunCMake/CommandLine/G_bad-arg-stderr.txt

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

+ 1 - 0
Tests/RunCMake/CommandLine/G_no-arg-result.txt

@@ -0,0 +1 @@
+1

+ 1 - 0
Tests/RunCMake/CommandLine/G_no-arg-stderr.txt

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

+ 10 - 0
Tests/RunCMake/CommandLine/NoArgs-stdout.txt

@@ -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.$

+ 1 - 0
Tests/RunCMake/CommandLine/P_no-arg-result.txt

@@ -0,0 +1 @@
+1

+ 1 - 0
Tests/RunCMake/CommandLine/P_no-arg-stderr.txt

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

+ 1 - 0
Tests/RunCMake/CommandLine/P_no-file-result.txt

@@ -0,0 +1 @@
+1

+ 1 - 0
Tests/RunCMake/CommandLine/P_no-file-stderr.txt

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

+ 40 - 0
Tests/RunCMake/CommandLine/RunCMakeTest.cmake

@@ -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")

+ 1 - 0
Tests/RunCMake/CommandLine/U-no-arg-result.txt

@@ -0,0 +1 @@
+1

+ 2 - 0
Tests/RunCMake/CommandLine/U-no-arg-stderr.txt

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

+ 5 - 0
Tests/RunCMake/CommandLine/Wdev-stderr.txt

@@ -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.$

+ 1 - 0
Tests/RunCMake/CommandLine/Wdev.cmake

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

+ 1 - 0
Tests/RunCMake/CommandLine/Wno-dev.cmake

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

+ 1 - 0
Tests/RunCMake/CommandLine/cache-no-file-result.txt

@@ -0,0 +1 @@
+1

+ 2 - 0
Tests/RunCMake/CommandLine/cache-no-file-stderr.txt

@@ -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.$

+ 1 - 0
Tests/RunCMake/CommandLine/debug-output-stdout.txt

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

+ 0 - 0
Tests/RunCMake/CommandLine/debug-output.cmake


+ 5 - 0
Tests/RunCMake/CommandLine/debug-trycompile.cmake

@@ -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()

+ 1 - 0
Tests/RunCMake/CommandLine/lists-no-file-result.txt

@@ -0,0 +1 @@
+1

+ 2 - 0
Tests/RunCMake/CommandLine/lists-no-file-stderr.txt

@@ -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.$

+ 2 - 0
Tests/RunCMake/CommandLine/trace-stderr.txt

@@ -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 \)

+ 0 - 0
Tests/RunCMake/CommandLine/trace.cmake