diff options
author | David Cole <david.cole@kitware.com> | 2009-10-17 15:43:15 (GMT) |
---|---|---|
committer | David Cole <david.cole@kitware.com> | 2009-10-17 15:43:15 (GMT) |
commit | 16d995d728a73b07751458333c401de5dbec2fc3 (patch) | |
tree | 614c7cff990775e3881c2cad425f0be201cfc22e | |
parent | 772253ecc640a3e1eb423271b323ef68b2a04c6f (diff) | |
download | CMake-16d995d728a73b07751458333c401de5dbec2fc3.zip CMake-16d995d728a73b07751458333c401de5dbec2fc3.tar.gz CMake-16d995d728a73b07751458333c401de5dbec2fc3.tar.bz2 |
Fixed issues with message text in FILE command error situations. Added many new test cases to increase the coverage of the FILE command even further.
-rw-r--r-- | Source/cmFileCommand.cxx | 17 | ||||
-rw-r--r-- | Tests/CMakeTests/FileTest.cmake.in | 2 | ||||
-rw-r--r-- | Tests/CMakeTests/FileTestScript.cmake | 114 |
3 files changed, 122 insertions, 11 deletions
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index abe6bc9..396ce05 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -2290,7 +2290,7 @@ bool cmFileCommand::HandleRelativePathCommand( { if(args.size() != 4 ) { - this->SetError("called with incorrect number of arguments"); + this->SetError("RELATIVE_PATH called with incorrect number of arguments"); return false; } @@ -2301,7 +2301,7 @@ bool cmFileCommand::HandleRelativePathCommand( if(!cmSystemTools::FileIsFullPath(directoryName.c_str())) { std::string errstring = - "RelativePath must be passed a full path to the directory: " + "RELATIVE_PATH must be passed a full path to the directory: " + directoryName; this->SetError(errstring.c_str()); return false; @@ -2309,7 +2309,7 @@ bool cmFileCommand::HandleRelativePathCommand( if(!cmSystemTools::FileIsFullPath(fileName.c_str())) { std::string errstring = - "RelativePath must be passed a full path to the file: " + "RELATIVE_PATH must be passed a full path to the file: " + fileName; this->SetError(errstring.c_str()); return false; @@ -2328,7 +2328,7 @@ bool cmFileCommand::HandleRename(std::vector<std::string> const& args) { if(args.size() != 3) { - this->SetError("given incorrect number of arguments."); + this->SetError("RENAME given incorrect number of arguments."); return false; } @@ -2400,8 +2400,8 @@ bool cmFileCommand::HandleCMakePathCommand(std::vector<std::string> std::vector<std::string>::const_iterator i = args.begin(); if(args.size() != 3) { - this->SetError("FILE(SYSTEM_PATH ENV result) must be called with " - "only three arguments."); + this->SetError("FILE([TO_CMAKE_PATH|TO_NATIVE_PATH] path result) must be " + "called with exactly three arguments."); return false; } i++; // Get rid of subcommand @@ -2539,8 +2539,9 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> if(!cmSystemTools::FileExists(dir.c_str()) && !cmSystemTools::MakeDirectory(dir.c_str())) { - std::string errstring = "FILE(DOWNLOAD ) error; cannot create directory: " - + dir + ". Maybe need administrative privileges."; + std::string errstring = "DOWNLOAD error: cannot create directory '" + + dir + "' - Specify file by full path name and verify that you " + "have directory creation and file write privileges."; this->SetError(errstring.c_str()); return false; } diff --git a/Tests/CMakeTests/FileTest.cmake.in b/Tests/CMakeTests/FileTest.cmake.in index 0652ab2..7a1d4c1 100644 --- a/Tests/CMakeTests/FileTest.cmake.in +++ b/Tests/CMakeTests/FileTest.cmake.in @@ -27,7 +27,7 @@ check_cmake_test(File # Also execute each test listed in FileTestScript.cmake: # set(scriptname "@CMAKE_CURRENT_SOURCE_DIR@/FileTestScript.cmake") -set(number_of_tests_expected 27) +set(number_of_tests_expected 57) include("@CMAKE_CURRENT_SOURCE_DIR@/ExecuteScriptTests.cmake") execute_all_script_tests(${scriptname} number_of_tests_executed) diff --git a/Tests/CMakeTests/FileTestScript.cmake b/Tests/CMakeTests/FileTestScript.cmake index b540f8d..ab505bc 100644 --- a/Tests/CMakeTests/FileTestScript.cmake +++ b/Tests/CMakeTests/FileTestScript.cmake @@ -24,8 +24,8 @@ elseif(testname STREQUAL rpath_remove_not_enough_args) # fail 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 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) @@ -76,12 +76,25 @@ elseif(testname STREQUAL glob_non_full_path) # pass file(GLOB_RECURSE v ffff*.*) message("v='${v}'") +elseif(testname STREQUAL make_directory_non_full_path) # pass + file(MAKE_DIRECTORY FileTestScriptDDDD) + if(NOT EXISTS FileTestScriptDDDD) + message(FATAL_ERROR "error: non-full-path MAKE_DIRECTORY failed") + endif() + file(REMOVE_RECURSE FileTestScriptDDDD) + if(EXISTS FileTestScriptDDDD) + message(FATAL_ERROR "error: non-full-path REMOVE_RECURSE failed") + endif() + 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_unknown_arg) # fail + file(DIFFERENT v FILES ffffLHS ffffRHS BOGUS) + elseif(testname STREQUAL different_different) # pass file(DIFFERENT v FILES ffffLHS ffffRHS) message("v='${v}'") @@ -91,6 +104,103 @@ elseif(testname STREQUAL different_same) # pass ${CMAKE_CURRENT_LIST_FILE} ${CMAKE_CURRENT_LIST_FILE}) message("v='${v}'") +elseif(testname STREQUAL rpath_change_unknown_arg) # fail + file(RPATH_CHANGE BOGUS) + +elseif(testname STREQUAL rpath_change_bad_file) # fail + file(RPATH_CHANGE FILE) + +elseif(testname STREQUAL rpath_change_bad_old_rpath) # fail + file(RPATH_CHANGE FILE ffff OLD_RPATH) + +elseif(testname STREQUAL rpath_change_bad_new_rpath) # fail + file(RPATH_CHANGE FILE ffff OLD_RPATH rrrr NEW_RPATH) + +elseif(testname STREQUAL rpath_change_file_does_not_exist) # fail + file(RPATH_CHANGE FILE ffff OLD_RPATH rrrr NEW_RPATH RRRR) + +elseif(testname STREQUAL rpath_change_file_is_not_executable) # fail + file(RPATH_CHANGE FILE ${CMAKE_CURRENT_LIST_FILE} + OLD_RPATH rrrr NEW_RPATH RRRR) + +elseif(testname STREQUAL rpath_remove_unknown_arg) # fail + file(RPATH_REMOVE BOGUS) + +elseif(testname STREQUAL rpath_remove_bad_file) # fail + file(RPATH_REMOVE FILE) + +elseif(testname STREQUAL rpath_remove_file_does_not_exist) # fail + file(RPATH_REMOVE FILE ffff) + +elseif(testname STREQUAL rpath_remove_file_is_not_executable) # fail + file(RPATH_REMOVE FILE ${CMAKE_CURRENT_LIST_FILE}) + +elseif(testname STREQUAL rpath_check_unknown_arg) # fail + file(RPATH_CHECK BOGUS) + +elseif(testname STREQUAL rpath_check_bad_file) # fail + file(RPATH_CHECK FILE) + +elseif(testname STREQUAL rpath_check_bad_rpath) # fail + file(RPATH_CHECK FILE ffff RPATH) + +elseif(testname STREQUAL rpath_check_file_does_not_exist) # pass + file(RPATH_CHECK FILE ffff RPATH rrrr) + +elseif(testname STREQUAL rpath_check_file_is_not_executable) # pass + file(WRITE ffff_rpath_check "") + + if(NOT EXISTS ffff_rpath_check) + message(FATAL_ERROR "error: non-full-path WRITE failed") + endif() + + file(RPATH_CHECK FILE ffff_rpath_check RPATH rrrr) + # careful: if the file does not have the given RPATH, it is deleted... + + if(EXISTS ffff_rpath_check) + message(FATAL_ERROR "error: non-full-path RPATH_CHECK failed") + endif() + +elseif(testname STREQUAL relative_path_wrong_number_of_args) # fail + file(RELATIVE_PATH v dir) + +elseif(testname STREQUAL relative_path_non_full_path_dir) # fail + file(RELATIVE_PATH v dir file) + +elseif(testname STREQUAL relative_path_non_full_path_file) # fail + file(RELATIVE_PATH v /dir file) + +elseif(testname STREQUAL rename_wrong_number_of_args) # fail + file(RENAME ffff) + +elseif(testname STREQUAL rename_input_file_does_not_exist) # fail + file(RENAME ffff FFFFGGGG) + +elseif(testname STREQUAL to_native_path) # pass + file(TO_NATIVE_PATH /a/b/c\;/d/e/f:/g/h/i v) + message("v='${v}'") + +elseif(testname STREQUAL download_wrong_number_of_args) # fail + file(DOWNLOAD zzzz://bogus/ffff) + +elseif(testname STREQUAL download_file_with_no_path) # fail + file(DOWNLOAD zzzz://bogus/ffff ffff) + +elseif(testname STREQUAL download_missing_time) # fail + file(DOWNLOAD zzzz://bogus/ffff ./ffff TIMEOUT) + +elseif(testname STREQUAL download_missing_log_var) # fail + file(DOWNLOAD zzzz://bogus/ffff ./ffff TIMEOUT 2 LOG) + +elseif(testname STREQUAL download_missing_status_var) # fail + file(DOWNLOAD zzzz://bogus/ffff ./ffff TIMEOUT 2 LOG l STATUS) + +elseif(testname STREQUAL download_with_bogus_protocol) # pass + file(DOWNLOAD zzzz://bogus/ffff ./ffff TIMEOUT 2 LOG l STATUS s) + file(REMOVE ./ffff) + message("l='${l}'") + message("s='${s}'") + else() # fail message(FATAL_ERROR "testname='${testname}' - error: no such test in '${CMAKE_CURRENT_LIST_FILE}'") |