[Cmake-commits] [cmake-commits] david.cole committed CMakeLists.txt 1.20 1.21 EndStuffTest.cmake.in NONE 1.1 EndStuffTestScript.cmake NONE 1.1 ExecuteScriptTests.cmake 1.1 1.2

cmake-commits at cmake.org cmake-commits at cmake.org
Tue Oct 6 14:45:22 EDT 2009


Update of /cvsroot/CMake/CMake/Tests/CMakeTests
In directory public:/mounts/ram/cvs-serv15532/Tests/CMakeTests

Modified Files:
	CMakeLists.txt ExecuteScriptTests.cmake 
Added Files:
	EndStuffTest.cmake.in EndStuffTestScript.cmake 
Log Message:
Increase coverage. Intentionally trigger error conditions. Call all the else*/end* functions without proper opening or containing code structure: else, elseif, endforeach, endfunction, endif, endmacro, endwhile.


Index: CMakeLists.txt
===================================================================
RCS file: /cvsroot/CMake/CMake/Tests/CMakeTests/CMakeLists.txt,v
retrieving revision 1.20
retrieving revision 1.21
diff -C 2 -d -r1.20 -r1.21
*** CMakeLists.txt	5 Oct 2009 20:50:21 -0000	1.20
--- CMakeLists.txt	6 Oct 2009 18:45:19 -0000	1.21
***************
*** 27,30 ****
--- 27,35 ----
  AddCMakeTest(CMakeMinimumRequired "")
  
+ SET(EndStuff_PreArgs
+   "-Ddir:STRING=${CMAKE_CURRENT_BINARY_DIR}/EndStuffTest"
+   )
+ AddCMakeTest(EndStuff "${EndStuff_PreArgs}")
+ 
  SET(GetPrerequisites_PreArgs
    "-DCTEST_CONFIGURATION_TYPE:STRING=\\\${CTEST_CONFIGURATION_TYPE}"

Index: ExecuteScriptTests.cmake
===================================================================
RCS file: /cvsroot/CMake/CMake/Tests/CMakeTests/ExecuteScriptTests.cmake,v
retrieving revision 1.1
retrieving revision 1.2
diff -C 2 -d -r1.1 -r1.2
*** ExecuteScriptTests.cmake	3 Oct 2009 16:01:06 -0000	1.1
--- ExecuteScriptTests.cmake	6 Oct 2009 18:45:19 -0000	1.2
***************
*** 7,10 ****
--- 7,11 ----
    execute_process(
      COMMAND ${CMAKE_COMMAND}
+       -D "dir:STRING=${dir}"
        -D "testname:STRING=${testname}"
        -P "${scriptname}"

--- NEW FILE: EndStuffTestScript.cmake ---
message(STATUS "testname='${testname}'")

if(testname STREQUAL bad_else) # fail
  file(WRITE "${dir}/${testname}.cmake"
"else()
")
  execute_process(COMMAND ${CMAKE_COMMAND} -P "${dir}/${testname}.cmake"
    RESULT_VARIABLE rv)
  if(NOT rv EQUAL 0)
    message(FATAL_ERROR "${testname} failed")
  endif()

elseif(testname STREQUAL bad_elseif) # fail
  file(WRITE "${dir}/${testname}.cmake"
"elseif()
")
  execute_process(COMMAND ${CMAKE_COMMAND} -P "${dir}/${testname}.cmake"
    RESULT_VARIABLE rv)
  if(NOT rv EQUAL 0)
    message(FATAL_ERROR "${testname} failed")
  endif()

elseif(testname STREQUAL bad_endforeach) # fail
  endforeach()

elseif(testname STREQUAL bad_endfunction) # fail
  endfunction()

elseif(testname STREQUAL bad_endif) # fail
  file(WRITE "${dir}/${testname}.cmake"
"cmake_minimum_required(VERSION 2.8)
endif()
")
  execute_process(COMMAND ${CMAKE_COMMAND} -P "${dir}/${testname}.cmake"
    RESULT_VARIABLE rv)
  if(NOT rv EQUAL 0)
    message(FATAL_ERROR "${testname} failed")
  endif()

elseif(testname STREQUAL endif_low_min_version) # pass
  file(WRITE "${dir}/${testname}.cmake"
"cmake_minimum_required(VERSION 1.2)
endif()
")
  execute_process(COMMAND ${CMAKE_COMMAND} -P "${dir}/${testname}.cmake"
    RESULT_VARIABLE rv)
  if(NOT rv EQUAL 0)
    message(FATAL_ERROR "${testname} failed")
  endif()

elseif(testname STREQUAL endif_no_min_version) # pass
  file(WRITE "${dir}/${testname}.cmake"
"endif()
")
  execute_process(COMMAND ${CMAKE_COMMAND} -P "${dir}/${testname}.cmake"
    RESULT_VARIABLE rv)
  if(NOT rv EQUAL 0)
    message(FATAL_ERROR "${testname} failed")
  endif()

elseif(testname STREQUAL bad_endmacro) # fail
  endmacro()

elseif(testname STREQUAL bad_endwhile) # fail
  endwhile()

else() # fail
  message(FATAL_ERROR "testname='${testname}' - error: no such test in '${CMAKE_CURRENT_LIST_FILE}'")

endif()

--- NEW FILE: EndStuffTest.cmake.in ---
# Execute each test listed in:
#
set(scriptname "@CMAKE_CURRENT_SOURCE_DIR@/EndStuffTestScript.cmake")
set(number_of_tests_expected 9)

include("@CMAKE_CURRENT_SOURCE_DIR@/ExecuteScriptTests.cmake")
execute_all_script_tests(${scriptname} number_of_tests_executed)

# And verify that number_of_tests_executed is at least as many as we know
# about as of this writing...
#
message(STATUS "scriptname='${scriptname}'")
message(STATUS "number_of_tests_executed='${number_of_tests_executed}'")
message(STATUS "number_of_tests_expected='${number_of_tests_expected}'")

if(number_of_tests_executed LESS number_of_tests_expected)
  message(FATAL_ERROR "error: some test cases were skipped")
endif()



More information about the Cmake-commits mailing list