diff options
author | David Cole <david.cole@kitware.com> | 2011-02-23 18:53:53 (GMT) |
---|---|---|
committer | David Cole <david.cole@kitware.com> | 2011-02-25 22:26:34 (GMT) |
commit | 963bebcc174411e1087af31cc5054422b0080e76 (patch) | |
tree | ea03e151378a797ccb757674ac6625782a83234c /Tests/CMakeTests | |
parent | 62f816adde5312eb97724796efa8e4dff9534f54 (diff) | |
download | CMake-963bebcc174411e1087af31cc5054422b0080e76.zip CMake-963bebcc174411e1087af31cc5054422b0080e76.tar.gz CMake-963bebcc174411e1087af31cc5054422b0080e76.tar.bz2 |
Implement file(UPLOAD (#11286)
Including documentation and testing, of course.
Diffstat (limited to 'Tests/CMakeTests')
-rw-r--r-- | Tests/CMakeTests/CMakeLists.txt | 2 | ||||
-rw-r--r-- | Tests/CMakeTests/FileTest.cmake.in | 2 | ||||
-rw-r--r-- | Tests/CMakeTests/FileTestScript.cmake | 20 | ||||
-rw-r--r-- | Tests/CMakeTests/FileUploadTest.cmake.in | 49 |
4 files changed, 72 insertions, 1 deletions
diff --git a/Tests/CMakeTests/CMakeLists.txt b/Tests/CMakeTests/CMakeLists.txt index 8fd52df..cceef3b 100644 --- a/Tests/CMakeTests/CMakeLists.txt +++ b/Tests/CMakeTests/CMakeLists.txt @@ -33,6 +33,8 @@ set_property(TEST CMake.FileDownload PROPERTY PASS_REGULAR_EXPRESSION "file already exists with expected MD5 sum" ) +AddCMakeTest(FileUpload "") + if(HAVE_ELF_H) AddCMakeTest(ELF "") endif() diff --git a/Tests/CMakeTests/FileTest.cmake.in b/Tests/CMakeTests/FileTest.cmake.in index 721f311..b6dcaa6 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 56) +set(number_of_tests_expected 62) 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 c4e27bd..9a43569 100644 --- a/Tests/CMakeTests/FileTestScript.cmake +++ b/Tests/CMakeTests/FileTestScript.cmake @@ -201,6 +201,26 @@ elseif(testname STREQUAL download_with_bogus_protocol) # pass message("l='${l}'") message("s='${s}'") +elseif(testname STREQUAL upload_wrong_number_of_args) # fail + file(UPLOAD ./ffff) + +elseif(testname STREQUAL upload_missing_time) # fail + file(UPLOAD ./ffff zzzz://bogus/ffff TIMEOUT) + +elseif(testname STREQUAL upload_missing_log_var) # fail + file(UPLOAD ./ffff zzzz://bogus/ffff TIMEOUT 2 LOG) + +elseif(testname STREQUAL upload_missing_status_var) # fail + file(UPLOAD ./ffff zzzz://bogus/ffff TIMEOUT 2 LOG l STATUS) + +elseif(testname STREQUAL upload_file_that_doesnt_exist) # fail + file(UPLOAD ./ffff zzzz://bogus/ffff) + +elseif(testname STREQUAL upload_with_bogus_protocol) # pass + file(UPLOAD ${CMAKE_CURRENT_LIST_FILE} zzzz://bogus/ffff TIMEOUT 2 LOG l STATUS s) + message("l='${l}'") + message("s='${s}'") + else() # fail message(FATAL_ERROR "testname='${testname}' - error: no such test in '${CMAKE_CURRENT_LIST_FILE}'") diff --git a/Tests/CMakeTests/FileUploadTest.cmake.in b/Tests/CMakeTests/FileUploadTest.cmake.in new file mode 100644 index 0000000..8577aef --- /dev/null +++ b/Tests/CMakeTests/FileUploadTest.cmake.in @@ -0,0 +1,49 @@ +file(REMOVE_RECURSE "@CMAKE_CURRENT_BINARY_DIR@/uploads") + +if(EXISTS "@CMAKE_CURRENT_BINARY_DIR@/uploads/file1.png") + message(FATAL_ERROR "error: file1.png exists - should have been deleted") +endif() +if(EXISTS "@CMAKE_CURRENT_BINARY_DIR@/uploads/file2.png") + message(FATAL_ERROR "error: file2.png exists - should have been deleted") +endif() + +file(MAKE_DIRECTORY "@CMAKE_CURRENT_BINARY_DIR@/uploads") + +set(filename "@CMAKE_CURRENT_SOURCE_DIR@/FileDownloadInput.png") +set(urlbase "file://@CMAKE_CURRENT_BINARY_DIR@/uploads") + +message(STATUS "FileUpload:1") +file(UPLOAD + ${filename} + ${urlbase}/file1.png + TIMEOUT 2 + ) + +message(STATUS "FileUpload:2") +file(UPLOAD + ${filename} + ${urlbase}/file2.png + STATUS status + LOG log + SHOW_PROGRESS + ) + +execute_process(COMMAND ${CMAKE_COMMAND} -E md5sum + "@CMAKE_CURRENT_BINARY_DIR@/uploads/file1.png" + OUTPUT_VARIABLE sum1 + OUTPUT_STRIP_TRAILING_WHITESPACE) +if(NOT sum1 MATCHES "^d16778650db435bda3a8c3435c3ff5d1 .*/uploads/file1.png$") + message(FATAL_ERROR "file1.png did not upload correctly (sum1='${sum1}')") +endif() + +execute_process(COMMAND ${CMAKE_COMMAND} -E md5sum + "@CMAKE_CURRENT_BINARY_DIR@/uploads/file2.png" + OUTPUT_VARIABLE sum2 + OUTPUT_STRIP_TRAILING_WHITESPACE) +if(NOT sum2 MATCHES "^d16778650db435bda3a8c3435c3ff5d1 .*/uploads/file2.png$") + message(FATAL_ERROR "file2.png did not upload correctly (sum2='${sum2}')") +endif() + +message(STATUS "log='${log}'") +message(STATUS "status='${status}'") +message(STATUS "DONE") |