From a65b1cc3b0d842c7a55fb046aece9808f262d3cf Mon Sep 17 00:00:00 2001 From: David Cole Date: Fri, 16 Oct 2009 15:07:41 -0400 Subject: Add more testing coverage of the FILE command. --- Tests/CMakeTests/FileTest.cmake.in | 19 +++++++ Tests/CMakeTests/FileTestScript.cmake | 97 +++++++++++++++++++++++++++++++++++ 2 files changed, 116 insertions(+) create mode 100644 Tests/CMakeTests/FileTestScript.cmake diff --git a/Tests/CMakeTests/FileTest.cmake.in b/Tests/CMakeTests/FileTest.cmake.in index b19ad0a..0652ab2 100644 --- a/Tests/CMakeTests/FileTest.cmake.in +++ b/Tests/CMakeTests/FileTest.cmake.in @@ -23,3 +23,22 @@ check_cmake_test(File Copy-NoDest Copy-NoFile ) + +# Also execute each test listed in FileTestScript.cmake: +# +set(scriptname "@CMAKE_CURRENT_SOURCE_DIR@/FileTestScript.cmake") +set(number_of_tests_expected 27) + +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() diff --git a/Tests/CMakeTests/FileTestScript.cmake b/Tests/CMakeTests/FileTestScript.cmake new file mode 100644 index 0000000..b540f8d --- /dev/null +++ b/Tests/CMakeTests/FileTestScript.cmake @@ -0,0 +1,97 @@ +message(STATUS "testname='${testname}'") + +if(testname STREQUAL empty) # fail + file() + +elseif(testname STREQUAL bogus) # fail + file(BOGUS ffff) + +elseif(testname STREQUAL different_not_enough_args) # fail + file(DIFFERENT ffff) + +elseif(testname STREQUAL download_not_enough_args) # fail + file(DOWNLOAD ffff) + +elseif(testname STREQUAL read_not_enough_args) # fail + file(READ ffff) + +elseif(testname STREQUAL rpath_check_not_enough_args) # fail + file(RPATH_CHECK ffff) + +elseif(testname STREQUAL rpath_remove_not_enough_args) # fail + file(RPATH_REMOVE ffff) + +elseif(testname STREQUAL strings_not_enough_args) # fail + file(STRINGS ffff) + +#elseif(testname STREQUAL to_native_path_not_enough_args) # fail +# file(TO_NATIVE_PATH ffff) + +elseif(testname STREQUAL read_with_offset) # pass + file(READ ${CMAKE_CURRENT_LIST_FILE} v OFFSET 42 LIMIT 30) + message("v='${v}'") + +elseif(testname STREQUAL strings_bad_length_minimum) # fail + file(STRINGS ${CMAKE_CURRENT_LIST_FILE} v LENGTH_MINIMUM bogus) + +elseif(testname STREQUAL strings_bad_length_maximum) # fail + file(STRINGS ${CMAKE_CURRENT_LIST_FILE} v LENGTH_MAXIMUM bogus) + +elseif(testname STREQUAL strings_bad_limit_count) # fail + file(STRINGS ${CMAKE_CURRENT_LIST_FILE} v LIMIT_COUNT bogus) + +elseif(testname STREQUAL strings_bad_limit_input) # fail + file(STRINGS ${CMAKE_CURRENT_LIST_FILE} v LIMIT_INPUT bogus) + +elseif(testname STREQUAL strings_bad_limit_output) # fail + file(STRINGS ${CMAKE_CURRENT_LIST_FILE} v LIMIT_OUTPUT bogus) + +elseif(testname STREQUAL strings_bad_regex) # fail + file(STRINGS ${CMAKE_CURRENT_LIST_FILE} v REGEX "(") + +elseif(testname STREQUAL strings_unknown_arg) # fail + file(STRINGS ${CMAKE_CURRENT_LIST_FILE} v BOGUS) + +elseif(testname STREQUAL strings_bad_filename) # fail + file(STRINGS ffff v LIMIT_COUNT 10) + +elseif(testname STREQUAL strings_use_limit_count) # pass + file(STRINGS ${CMAKE_CURRENT_LIST_FILE} v LIMIT_COUNT 10) + message("v='${v}'") + +elseif(testname STREQUAL strings_use_no_hex_conversion) # pass + file(STRINGS ${CMAKE_CURRENT_LIST_FILE} v NO_HEX_CONVERSION) + message("v='${v}'") + +elseif(testname STREQUAL glob_recurse_follow_symlinks_no_expression) # fail + file(GLOB_RECURSE v FOLLOW_SYMLINKS) + +elseif(testname STREQUAL glob_recurse_relative_no_directory) # fail + file(GLOB_RECURSE v RELATIVE) + +elseif(testname STREQUAL glob_recurse_relative_no_expression) # fail + file(GLOB_RECURSE v RELATIVE dddd) + +elseif(testname STREQUAL glob_non_full_path) # pass + file(GLOB_RECURSE v ffff*.*) + message("v='${v}'") + +elseif(testname STREQUAL different_no_variable) # fail + file(DIFFERENT FILES) + +elseif(testname STREQUAL different_no_files) # fail + file(DIFFERENT v FILES) + +elseif(testname STREQUAL different_different) # pass + file(DIFFERENT v FILES ffffLHS ffffRHS) + message("v='${v}'") + +elseif(testname STREQUAL different_same) # pass + file(DIFFERENT v FILES + ${CMAKE_CURRENT_LIST_FILE} ${CMAKE_CURRENT_LIST_FILE}) + message("v='${v}'") + +else() # fail + message(FATAL_ERROR "testname='${testname}' - error: no such test in '${CMAKE_CURRENT_LIST_FILE}'") + +endif() -- cgit v0.12