diff options
Diffstat (limited to 'Tests/RunCMake')
51 files changed, 375 insertions, 22 deletions
diff --git a/Tests/RunCMake/AndroidMK/AndroidMK-check.cmake b/Tests/RunCMake/AndroidMK/AndroidMK-check.cmake new file mode 100644 index 0000000..691e326 --- /dev/null +++ b/Tests/RunCMake/AndroidMK/AndroidMK-check.cmake @@ -0,0 +1,30 @@ +# This file does a regex file compare on the generated +# Android.mk files from the AndroidMK test + +macro(compare_file_to_expected file expected_file) + file(READ "${file}" ANDROID_MK) + # clean up new lines + string(REGEX REPLACE "\r\n" "\n" ANDROID_MK "${ANDROID_MK}") + string(REGEX REPLACE "\n+$" "" ANDROID_MK "${ANDROID_MK}") + # read in the expected regex file + file(READ "${expected_file}" expected) + # clean up new lines + string(REGEX REPLACE "\r\n" "\n" expected "${expected}") + string(REGEX REPLACE "\n+$" "" expected "${expected}") + # compare the file to the expected regex and if there is not a match + # put an error message in RunCMake_TEST_FAILED + if(NOT "${ANDROID_MK}" MATCHES "${expected}") + set(RunCMake_TEST_FAILED + "${file} does not match ${expected_file}: + +Android.mk contents = [\n${ANDROID_MK}\n] +Expected = [\n${expected}\n]") + endif() +endmacro() + +compare_file_to_expected( +"${RunCMake_BINARY_DIR}/AndroidMK-build/Android.mk" +"${RunCMake_TEST_SOURCE_DIR}/expectedBuildAndroidMK.txt") +compare_file_to_expected( +"${RunCMake_BINARY_DIR}/AndroidMK-build/CMakeFiles/Export/share/ndk-modules/Android.mk" +"${RunCMake_TEST_SOURCE_DIR}/expectedInstallAndroidMK.txt") diff --git a/Tests/RunCMake/AndroidMK/AndroidMK.cmake b/Tests/RunCMake/AndroidMK/AndroidMK.cmake new file mode 100644 index 0000000..ed21e58 --- /dev/null +++ b/Tests/RunCMake/AndroidMK/AndroidMK.cmake @@ -0,0 +1,11 @@ +project(build) +set(CMAKE_BUILD_TYPE Debug) +add_library(foo foo.cxx) +add_library(car foo.cxx) +add_library(bar foo.cxx) +add_library(dog foo.cxx) +target_link_libraries(foo car bar dog debug -lm) +export(TARGETS bar dog car foo ANDROID_MK + ${build_BINARY_DIR}/Android.mk) +install(TARGETS bar dog car foo DESTINATION lib EXPORT myexp) +install(EXPORT_ANDROID_MK myexp DESTINATION share/ndk-modules) diff --git a/Tests/RunCMake/AndroidMK/CMakeLists.txt b/Tests/RunCMake/AndroidMK/CMakeLists.txt new file mode 100644 index 0000000..576787a --- /dev/null +++ b/Tests/RunCMake/AndroidMK/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.5) +project(${RunCMake_TEST} NONE) # or languages needed +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/AndroidMK/RunCMakeTest.cmake b/Tests/RunCMake/AndroidMK/RunCMakeTest.cmake new file mode 100644 index 0000000..786d45b --- /dev/null +++ b/Tests/RunCMake/AndroidMK/RunCMakeTest.cmake @@ -0,0 +1,2 @@ +include(RunCMake) +run_cmake(AndroidMK) diff --git a/Tests/RunCMake/AndroidMK/expectedBuildAndroidMK.txt b/Tests/RunCMake/AndroidMK/expectedBuildAndroidMK.txt new file mode 100644 index 0000000..def8fcb --- /dev/null +++ b/Tests/RunCMake/AndroidMK/expectedBuildAndroidMK.txt @@ -0,0 +1,23 @@ +LOCAL_PATH.*call my-dir.* +include.*CLEAR_VARS.* +LOCAL_MODULE.*bar +LOCAL_SRC_FILES.*bar.* +include.*PREBUILT_STATIC_LIBRARY.* +.* +include.*CLEAR_VARS.* +LOCAL_MODULE.*dog +LOCAL_SRC_FILES.*.*dog.* +include.*PREBUILT_STATIC_LIBRARY.* +.* +include.*CLEAR_VARS.* +LOCAL_MODULE.*car +LOCAL_SRC_FILES.*.*car.* +include.*PREBUILT_STATIC_LIBRARY.* +.* +include.*CLEAR_VARS.* +LOCAL_MODULE.*foo +LOCAL_SRC_FILES.*.*foo.* +LOCAL_CPP_FEATURES.*rtti exceptions +LOCAL_STATIC_LIBRARIES.*car bar dog +LOCAL_EXPORT_LDLIBS := -lm +include.*PREBUILT_STATIC_LIBRARY.* diff --git a/Tests/RunCMake/AndroidMK/expectedInstallAndroidMK.txt b/Tests/RunCMake/AndroidMK/expectedInstallAndroidMK.txt new file mode 100644 index 0000000..1bdb308 --- /dev/null +++ b/Tests/RunCMake/AndroidMK/expectedInstallAndroidMK.txt @@ -0,0 +1,25 @@ +LOCAL_PATH.*call my-dir.* +_IMPORT_PREFIX.*LOCAL_PATH./../.. + +include.*CLEAR_VARS.* +LOCAL_MODULE.*bar +LOCAL_SRC_FILES.*_IMPORT_PREFIX./lib.*bar.* +include.*PREBUILT_STATIC_LIBRARY.* + +include.*CLEAR_VARS. +LOCAL_MODULE.*dog +LOCAL_SRC_FILES.*_IMPORT_PREFIX./lib.*dog.* +include.*PREBUILT_STATIC_LIBRARY.* + +include.*CLEAR_VARS.* +LOCAL_MODULE.*car +LOCAL_SRC_FILES.*_IMPORT_PREFIX./lib.*car.* +include.*PREBUILT_STATIC_LIBRARY.* + +include.*CLEAR_VARS.* +LOCAL_MODULE.*foo +LOCAL_SRC_FILES.*_IMPORT_PREFIX\)/lib.*foo.* +LOCAL_CPP_FEATURES.*rtti exceptions +LOCAL_STATIC_LIBRARIES.*car bar dog +LOCAL_EXPORT_LDLIBS := -lm +include.*PREBUILT_STATIC_LIBRARY.* diff --git a/Tests/RunCMake/AndroidMK/foo.cxx b/Tests/RunCMake/AndroidMK/foo.cxx new file mode 100644 index 0000000..3695dc9 --- /dev/null +++ b/Tests/RunCMake/AndroidMK/foo.cxx @@ -0,0 +1,3 @@ +void foo() +{ +} diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index ce475e0..a1f35d7 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -332,6 +332,8 @@ add_RunCMake_test_group(CPack "DEB;RPM;TGZ") # for MSVC compilers CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS property is used add_RunCMake_test(AutoExportDll) +add_RunCMake_test(AndroidMK) + if(CMake_TEST_ANDROID_NDK OR CMake_TEST_ANDROID_STANDALONE_TOOLCHAIN) if(NOT "${CMAKE_GENERATOR}" MATCHES "Make|Ninja") message(FATAL_ERROR "Android tests supported only by Makefile and Ninja generators") diff --git a/Tests/RunCMake/CPack/CMakeLists.txt b/Tests/RunCMake/CPack/CMakeLists.txt index 46f1367..e42e971 100644 --- a/Tests/RunCMake/CPack/CMakeLists.txt +++ b/Tests/RunCMake/CPack/CMakeLists.txt @@ -1,11 +1,11 @@ cmake_minimum_required(VERSION 3.1 FATAL_ERROR) project(${RunCMake_TEST} CXX) -include(${RunCMake_TEST}.cmake) +include(${RunCMake_TEST_FILE_PREFIX}.cmake) # include test generator specifics -if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${GENERATOR_TYPE}/${RunCMake_TEST}-specifics.cmake") - include("${GENERATOR_TYPE}/${RunCMake_TEST}-specifics.cmake") +if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${GENERATOR_TYPE}/${RunCMake_TEST_FILE_PREFIX}-specifics.cmake") + include("${GENERATOR_TYPE}/${RunCMake_TEST_FILE_PREFIX}-specifics.cmake") endif() set(CPACK_GENERATOR "${GENERATOR_TYPE}") diff --git a/Tests/RunCMake/CPack/CPackTestHelpers.cmake b/Tests/RunCMake/CPack/CPackTestHelpers.cmake index 7bf42f9..7e6b4b1 100644 --- a/Tests/RunCMake/CPack/CPackTestHelpers.cmake +++ b/Tests/RunCMake/CPack/CPackTestHelpers.cmake @@ -1,9 +1,15 @@ cmake_policy(SET CMP0057 NEW) -function(run_cpack_test TEST_NAME types build) +function(run_cpack_test_common_ TEST_NAME types build SUBTEST_SUFFIX source) if(TEST_TYPE IN_LIST types) set(RunCMake_TEST_NO_CLEAN TRUE) set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/${TEST_NAME}-build") + set(full_test_name_ "${TEST_NAME}") + + if(SUBTEST_SUFFIX) + set(RunCMake_TEST_BINARY_DIR "${RunCMake_TEST_BINARY_DIR}-${SUBTEST_SUFFIX}-subtest") + set(full_test_name_ "${full_test_name_}-${SUBTEST_SUFFIX}-subtest") + endif() # TODO this should be executed only once per ctest run (not per generator) file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") @@ -24,27 +30,48 @@ function(run_cpack_test TEST_NAME types build) endif() # execute cmake - set(RunCMake_TEST_OPTIONS "-DGENERATOR_TYPE=${TEST_TYPE}") - run_cmake(${TEST_NAME}) + set(RunCMake_TEST_OPTIONS "-DGENERATOR_TYPE=${TEST_TYPE}" + "-DRunCMake_TEST_FILE_PREFIX=${TEST_NAME}" + "-DRunCMake_SUBTEST_SUFFIX=${SUBTEST_SUFFIX}") + run_cmake(${full_test_name_}) # execute optional build step if(build) - run_cmake_command(${TEST_NAME}-Build "${CMAKE_COMMAND}" --build "${RunCMake_TEST_BINARY_DIR}") + run_cmake_command(${full_test_name_}-Build "${CMAKE_COMMAND}" --build "${RunCMake_TEST_BINARY_DIR}") + endif() + + if(source) + set(pack_params_ -G ${TEST_TYPE} --config ./CPackSourceConfig.cmake) + FILE(APPEND ${RunCMake_TEST_BINARY_DIR}/CPackSourceConfig.cmake + "\nset(CPACK_RPM_SOURCE_PKG_BUILD_PARAMS \"-DRunCMake_TEST:STRING=${full_test_name_}\ -DRunCMake_TEST_FILE_PREFIX:STRING=${TEST_NAME}\")") + else() + unset(pack_params_) endif() # execute cpack execute_process( - COMMAND "${CMAKE_CPACK_COMMAND}" + COMMAND ${CMAKE_CPACK_COMMAND} ${pack_params_} WORKING_DIRECTORY "${RunCMake_TEST_BINARY_DIR}" + RESULT_VARIABLE "result_" OUTPUT_FILE "${RunCMake_TEST_BINARY_DIR}/test_output.txt" ERROR_FILE "${RunCMake_TEST_BINARY_DIR}/test_error.txt" ) + foreach(o out err) + if(SUBTEST_SUFFIX AND EXISTS ${RunCMake_SOURCE_DIR}/${TEST_TYPE}/${TEST_NAME}-${SUBTEST_SUFFIX}-std${o}.txt) + set(RunCMake-std${o}-file "${TEST_TYPE}/${TEST_NAME}-${SUBTEST_SUFFIX}-std${o}.txt") + elseif(EXISTS ${RunCMake_SOURCE_DIR}/${TEST_TYPE}/${TEST_NAME}-std${o}.txt) + set(RunCMake-std${o}-file "${TEST_TYPE}/${TEST_NAME}-std${o}.txt") + endif() + endforeach() + # verify result run_cmake_command( - ${TEST_TYPE}/${TEST_NAME} + ${TEST_TYPE}/${full_test_name_} "${CMAKE_COMMAND}" - -DRunCMake_TEST=${TEST_NAME} + -DRunCMake_TEST=${full_test_name_} + -DRunCMake_TEST_FILE_PREFIX=${TEST_NAME} + -DRunCMake_SUBTEST_SUFFIX=${SUBTEST_SUFFIX} -DGENERATOR_TYPE=${TEST_TYPE} "-Dsrc_dir=${RunCMake_SOURCE_DIR}" "-Dbin_dir=${RunCMake_TEST_BINARY_DIR}" @@ -53,3 +80,17 @@ function(run_cpack_test TEST_NAME types build) ) endif() endfunction() + +function(run_cpack_test TEST_NAME types build) + run_cpack_test_common_("${TEST_NAME}" "${types}" "${build}" "" false) +endfunction() + +function(run_cpack_source_test TEST_NAME types build) + run_cpack_test_common_("${TEST_NAME}" "${types}" "${build}" "" true) +endfunction() + +function(run_cpack_test_subtests TEST_NAME SUBTEST_SUFFIXES types build) + foreach(suffix_ IN LISTS SUBTEST_SUFFIXES) + run_cpack_test_common_("${TEST_NAME}" "${types}" "${build}" "${suffix_}" false) + endforeach() +endfunction() diff --git a/Tests/RunCMake/CPack/PACKAGE_CHECKSUM.cmake b/Tests/RunCMake/CPack/PACKAGE_CHECKSUM.cmake new file mode 100644 index 0000000..5ca288c --- /dev/null +++ b/Tests/RunCMake/CPack/PACKAGE_CHECKSUM.cmake @@ -0,0 +1,4 @@ +install(FILES CMakeLists.txt DESTINATION foo) + +set(CPACK_PACKAGE_NAME "package_checksum") +set(CPACK_PACKAGE_CHECKSUM ${RunCMake_SUBTEST_SUFFIX}) diff --git a/Tests/RunCMake/CPack/RPM/SOURCE_PACKAGE-ExpectedFiles.cmake b/Tests/RunCMake/CPack/RPM/SOURCE_PACKAGE-ExpectedFiles.cmake new file mode 100644 index 0000000..d6811eb --- /dev/null +++ b/Tests/RunCMake/CPack/RPM/SOURCE_PACKAGE-ExpectedFiles.cmake @@ -0,0 +1,5 @@ +set(whitespaces_ "[\t\n\r ]*") + +set(EXPECTED_FILES_COUNT "1") +set(EXPECTED_FILE_1 "source_package*.src.rpm") +set(EXPECTED_FILE_CONTENT_1 "^source_package-0.1.1.tar.gz${whitespaces_}source_package.spec$") diff --git a/Tests/RunCMake/CPack/RPM/SOURCE_PACKAGE-VerifyResult.cmake b/Tests/RunCMake/CPack/RPM/SOURCE_PACKAGE-VerifyResult.cmake new file mode 100644 index 0000000..a84e296 --- /dev/null +++ b/Tests/RunCMake/CPack/RPM/SOURCE_PACKAGE-VerifyResult.cmake @@ -0,0 +1,63 @@ +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test_rpm") +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test_rpm/BUILD") +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test_rpm/BUILDROOT") +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test_rpm/RPMS") +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test_rpm/SOURCES") +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test_rpm/SPECS") +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test_rpm/SRPMS") + +# make sure that we are using the version of cmake and cpack that we are testing +get_filename_component(cpack_path_ "${CMAKE_CPACK_COMMAND}" DIRECTORY) +set(ENV{PATH} "${cpack_path_}:$ENV{PATH}") + +execute_process(COMMAND ${RPMBUILD_EXECUTABLE} --define "_topdir ${CMAKE_CURRENT_BINARY_DIR}/test_rpm" --rebuild ${FOUND_FILE_1} + RESULT_VARIABLE result_ + ERROR_VARIABLE error_ + OUTPUT_QUIET + ) + +set(output_error_message_ + "\n${RPMBUILD_EXECUTABLE} error: '${error_}';\nresult: '${result_}';\n${output_error_message}") + +set(EXPECTED_FILE_CONTENT_ "^/foo${whitespaces_}/foo/test_prog$") + +file(GLOB_RECURSE FOUND_FILE_ RELATIVE "${CMAKE_CURRENT_BINARY_DIR}/test_rpm/RPMS" "${CMAKE_CURRENT_BINARY_DIR}/test_rpm/RPMS/*.rpm") +list(APPEND foundFiles_ "${FOUND_FILE_}") +list(LENGTH FOUND_FILE_ foundFilesCount_) + +if(foundFilesCount_ EQUAL 1) + unset(PACKAGE_CONTENT) + getPackageContent("${CMAKE_CURRENT_BINARY_DIR}/test_rpm/RPMS/${FOUND_FILE_}" "PACKAGE_CONTENT") + + string(REGEX MATCH "${EXPECTED_FILE_CONTENT_}" + expected_content_list "${PACKAGE_CONTENT}") + + if(NOT expected_content_list) + message(FATAL_ERROR + "Unexpected file content!\n" + " Content: '${PACKAGE_CONTENT}'\n\n" + " Expected: '${EXPECTED_FILE_CONTENT_}'" + "${output_error_message_}") + endif() +else() + message(FATAL_ERROR + "Found more than one file!" + " Found files count '${foundFilesCount_}'." + " Files: '${FOUND_FILE_}'" + "${output_error_message_}") +endif() + +# check that there were no extra files generated +foreach(all_files_glob_ IN LISTS ALL_FILES_GLOB) + file(GLOB foundAll_ RELATIVE "${CMAKE_CURRENT_BINARY_DIR}/test_rpm/RPMS" "${all_files_glob_}") + list(APPEND allFoundFiles_ "${foundAll_}") +endforeach() + +list(LENGTH foundFiles_ foundFilesCount_) +list(LENGTH allFoundFiles_ allFoundFilesCount_) + +if(NOT foundFilesCount_ EQUAL allFoundFilesCount_) + message(FATAL_ERROR + "Found more files than expected! Found files: '${allFoundFiles_}'" + "${output_error_message_}") +endif() diff --git a/Tests/RunCMake/CPack/RunCMakeTest.cmake b/Tests/RunCMake/CPack/RunCMakeTest.cmake index a3029cf..60d42ac 100644 --- a/Tests/RunCMake/CPack/RunCMakeTest.cmake +++ b/Tests/RunCMake/CPack/RunCMakeTest.cmake @@ -5,6 +5,7 @@ include("${RunCMake_SOURCE_DIR}/CPackTestHelpers.cmake") # args: TEST_NAME "GENERATORS" RUN_CMAKE_BUILD_STEP run_cpack_test(MINIMAL "RPM;DEB;TGZ" false) +run_cpack_source_test(SOURCE_PACKAGE "RPM" true) run_cpack_test(PARTIALLY_RELOCATABLE_WARNING "RPM" false) run_cpack_test(DEB_EXTRA "DEB" false) run_cpack_test(DEPENDENCIES "RPM;DEB" true) @@ -18,3 +19,4 @@ run_cpack_test(DEB_GENERATE_SHLIBS "DEB" true) run_cpack_test(DEB_GENERATE_SHLIBS_LDCONFIG "DEB" true) run_cpack_test(DEBUGINFO "RPM" true) run_cpack_test(LONG_FILENAMES "DEB" false) +run_cpack_test_subtests(PACKAGE_CHECKSUM "invalid;MD5;SHA1;SHA224;SHA256;SHA384;SHA512" "TGZ" false) diff --git a/Tests/RunCMake/CPack/SOURCE_PACKAGE.cmake b/Tests/RunCMake/CPack/SOURCE_PACKAGE.cmake new file mode 100644 index 0000000..9958c2a --- /dev/null +++ b/Tests/RunCMake/CPack/SOURCE_PACKAGE.cmake @@ -0,0 +1,9 @@ +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/main.cpp" + "int main() {return 0;}") +add_executable(test_prog "${CMAKE_CURRENT_BINARY_DIR}/main.cpp") + +install(TARGETS test_prog DESTINATION foo COMPONENT applications) + +set(CPACK_RPM_FILE_NAME "RPM-DEFAULT") + +set(CPACK_PACKAGE_NAME "source_package") diff --git a/Tests/RunCMake/CPack/TGZ/PACKAGE_CHECKSUM-ExpectedFiles.cmake b/Tests/RunCMake/CPack/TGZ/PACKAGE_CHECKSUM-ExpectedFiles.cmake new file mode 100644 index 0000000..205dcd8 --- /dev/null +++ b/Tests/RunCMake/CPack/TGZ/PACKAGE_CHECKSUM-ExpectedFiles.cmake @@ -0,0 +1,9 @@ +set(whitespaces_ "[\t\n\r ]*") + +set(EXPECTED_FILES_COUNT "0") + +if (NOT ${RunCMake_SUBTEST_SUFFIX} MATCHES "invalid") + set(EXPECTED_FILES_COUNT "1") + set(EXPECTED_FILE_1 "package_checksum*.tar.gz") + set(EXPECTED_FILE_CONTENT_1 "^[^\n]*package_checksum*-[^\n]*/foo/\n[^\n]*package_checksum-[^\n]*/foo/CMakeLists.txt$") +endif() diff --git a/Tests/RunCMake/CPack/TGZ/PACKAGE_CHECKSUM-VerifyResult.cmake b/Tests/RunCMake/CPack/TGZ/PACKAGE_CHECKSUM-VerifyResult.cmake new file mode 100644 index 0000000..e9e65d6 --- /dev/null +++ b/Tests/RunCMake/CPack/TGZ/PACKAGE_CHECKSUM-VerifyResult.cmake @@ -0,0 +1,14 @@ +if(NOT ${RunCMake_SUBTEST_SUFFIX} MATCHES "invalid") + string(TOLOWER ${RunCMake_SUBTEST_SUFFIX} EXTENSION) + file(GLOB PACKAGE RELATIVE ${bin_dir} "*.tar.gz") + file(GLOB CSUMFILE RELATIVE ${bin_dir} "*.${EXTENSION}") + file(STRINGS ${CSUMFILE} CHSUM_VALUE) + file(${RunCMake_SUBTEST_SUFFIX} ${PACKAGE} expected_value ) + set(expected_value "${expected_value} ${PACKAGE}") + + if(NOT expected_value STREQUAL CHSUM_VALUE) + message(FATAL_ERROR "Generated checksum is not valid! Expected [${expected_value}] Got [${CHSUM_VALUE}]") + endif() +else() + message(${error}) +endif() diff --git a/Tests/RunCMake/CPack/TGZ/PACKAGE_CHECKSUM-invalid-stderr.txt b/Tests/RunCMake/CPack/TGZ/PACKAGE_CHECKSUM-invalid-stderr.txt new file mode 100644 index 0000000..abf6d8c --- /dev/null +++ b/Tests/RunCMake/CPack/TGZ/PACKAGE_CHECKSUM-invalid-stderr.txt @@ -0,0 +1,2 @@ +^CPack Error: Cannot recognize algorithm: invalid +CPack Error: Error when generating package: package_checksum$ diff --git a/Tests/RunCMake/CPack/VerifyResult.cmake b/Tests/RunCMake/CPack/VerifyResult.cmake index 074890f..8bc2a58 100644 --- a/Tests/RunCMake/CPack/VerifyResult.cmake +++ b/Tests/RunCMake/CPack/VerifyResult.cmake @@ -8,10 +8,10 @@ file(READ "${bin_dir}/test_error.txt" error) file(READ "${config_file}" config_file_content) set(output_error_message - "\nCPack output: '${output}'\nCPack error: '${error}';\nconfig file: '${config_file_content}'") + "\nCPack output: '${output}'\nCPack error: '${error}';\nCPack result: '${PACKAGING_RESULT}';\nconfig file: '${config_file_content}'") # check that expected generated files exist and contain expected content -include("${src_dir}/${GENERATOR_TYPE}/${RunCMake_TEST}-ExpectedFiles.cmake") +include("${src_dir}/${GENERATOR_TYPE}/${RunCMake_TEST_FILE_PREFIX}-ExpectedFiles.cmake") if(NOT EXPECTED_FILES_COUNT EQUAL 0) foreach(file_no_ RANGE 1 ${EXPECTED_FILES_COUNT}) @@ -82,8 +82,8 @@ else() endif() # handle additional result verifications -if(EXISTS "${src_dir}/${GENERATOR_TYPE}/${RunCMake_TEST}-VerifyResult.cmake") - include("${src_dir}/${GENERATOR_TYPE}/${RunCMake_TEST}-VerifyResult.cmake") +if(EXISTS "${src_dir}/${GENERATOR_TYPE}/${RunCMake_TEST_FILE_PREFIX}-VerifyResult.cmake") + include("${src_dir}/${GENERATOR_TYPE}/${RunCMake_TEST_FILE_PREFIX}-VerifyResult.cmake") else() # by default only print out output and error so that they can be compared by # regex diff --git a/Tests/RunCMake/CommandLine/E_server-arg-result.txt b/Tests/RunCMake/CommandLine/E_server-arg-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_server-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/E_server-arg-stderr.txt b/Tests/RunCMake/CommandLine/E_server-arg-stderr.txt new file mode 100644 index 0000000..4dcbab9 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_server-arg-stderr.txt @@ -0,0 +1 @@ +^CMake Error: Unknown argument for server mode$ diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake index 6ae47a8..9f76ad9 100644 --- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake +++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake @@ -12,6 +12,7 @@ run_cmake_command(E_capabilities ${CMAKE_COMMAND} -E capabilities) run_cmake_command(E_capabilities-arg ${CMAKE_COMMAND} -E capabilities --extra-arg) 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_server-arg ${CMAKE_COMMAND} -E server --extra-arg) run_cmake_command(E_touch_nocreate-no-arg ${CMAKE_COMMAND} -E touch_nocreate) run_cmake_command(E_time ${CMAKE_COMMAND} -E time ${CMAKE_COMMAND} -E echo "hello world") diff --git a/Tests/RunCMake/add_custom_command/AppendNotOutput-stderr.txt b/Tests/RunCMake/add_custom_command/AppendNotOutput-stderr.txt index 96d0972..cd542d8 100644 --- a/Tests/RunCMake/add_custom_command/AppendNotOutput-stderr.txt +++ b/Tests/RunCMake/add_custom_command/AppendNotOutput-stderr.txt @@ -1,5 +1,8 @@ CMake Error at AppendNotOutput.cmake:1 \(add_custom_command\): - add_custom_command given APPEND option with output.* + add_custom_command given APPEND option with output + + .*RunCMake/add_custom_command/AppendNotOutput-build/out.* + which is not already a custom command output. Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/file/DOWNLOAD-httpheader-not-set-result.txt b/Tests/RunCMake/file/DOWNLOAD-httpheader-not-set-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/file/DOWNLOAD-httpheader-not-set-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/file/DOWNLOAD-httpheader-not-set-stderr.txt b/Tests/RunCMake/file/DOWNLOAD-httpheader-not-set-stderr.txt new file mode 100644 index 0000000..247923b --- /dev/null +++ b/Tests/RunCMake/file/DOWNLOAD-httpheader-not-set-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at DOWNLOAD-httpheader-not-set.cmake:[0-9]+ \(file\): + file DOWNLOAD missing string for HTTPHEADER. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/file/DOWNLOAD-httpheader-not-set.cmake b/Tests/RunCMake/file/DOWNLOAD-httpheader-not-set.cmake new file mode 100644 index 0000000..6efc958 --- /dev/null +++ b/Tests/RunCMake/file/DOWNLOAD-httpheader-not-set.cmake @@ -0,0 +1 @@ +file(DOWNLOAD "" "" HTTPHEADER "Content-Type: application/x-compressed-tar" HTTPHEADER) diff --git a/Tests/RunCMake/file/DOWNLOAD-pass-not-set-result.txt b/Tests/RunCMake/file/DOWNLOAD-pass-not-set-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/file/DOWNLOAD-pass-not-set-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/file/DOWNLOAD-pass-not-set-stderr.txt b/Tests/RunCMake/file/DOWNLOAD-pass-not-set-stderr.txt new file mode 100644 index 0000000..2fa2731 --- /dev/null +++ b/Tests/RunCMake/file/DOWNLOAD-pass-not-set-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at DOWNLOAD-pass-not-set.cmake:[0-9]+ \(file\): + file DOWNLOAD missing string for USERPWD. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/file/DOWNLOAD-pass-not-set.cmake b/Tests/RunCMake/file/DOWNLOAD-pass-not-set.cmake new file mode 100644 index 0000000..61eff6d --- /dev/null +++ b/Tests/RunCMake/file/DOWNLOAD-pass-not-set.cmake @@ -0,0 +1 @@ +file(DOWNLOAD "" "" USERPWD) diff --git a/Tests/RunCMake/file/DOWNLOAD-unused-argument-result.txt b/Tests/RunCMake/file/DOWNLOAD-unused-argument-result.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/file/DOWNLOAD-unused-argument-result.txt diff --git a/Tests/RunCMake/file/DOWNLOAD-unused-argument-stderr.txt b/Tests/RunCMake/file/DOWNLOAD-unused-argument-stderr.txt new file mode 100644 index 0000000..82a78c9 --- /dev/null +++ b/Tests/RunCMake/file/DOWNLOAD-unused-argument-stderr.txt @@ -0,0 +1,5 @@ +^CMake Warning \(dev\) at DOWNLOAD-unused-argument.cmake:[0-9]+ \(file\): + Unexpected argument: JUNK +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) +This warning is for project developers. Use -Wno-dev to suppress it.$ diff --git a/Tests/RunCMake/file/DOWNLOAD-unused-argument.cmake b/Tests/RunCMake/file/DOWNLOAD-unused-argument.cmake new file mode 100644 index 0000000..2e3fbe1 --- /dev/null +++ b/Tests/RunCMake/file/DOWNLOAD-unused-argument.cmake @@ -0,0 +1,5 @@ +file(DOWNLOAD + "file://${CMAKE_CURRENT_SOURCE_DIR}/DOWNLOAD-unused-argument.txt" + "${CMAKE_CURRENT_BINARY_DIR}/unused-argument.txt" + JUNK + ) diff --git a/Tests/RunCMake/file/DOWNLOAD-unused-argument.txt b/Tests/RunCMake/file/DOWNLOAD-unused-argument.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/file/DOWNLOAD-unused-argument.txt diff --git a/Tests/RunCMake/file/LOCK-lowercase.cmake b/Tests/RunCMake/file/LOCK-lowercase.cmake new file mode 100644 index 0000000..373afda --- /dev/null +++ b/Tests/RunCMake/file/LOCK-lowercase.cmake @@ -0,0 +1,11 @@ +set(lock "${CMAKE_CURRENT_BINARY_DIR}/file-to-lock") + +if(WIN32) + string(TOLOWER ${lock} lock) +endif() + +file(LOCK ${lock} TIMEOUT 0) +file(LOCK ${lock} RELEASE) + +file(LOCK ${lock} TIMEOUT 0) +file(LOCK ${lock} RELEASE) diff --git a/Tests/RunCMake/file/RunCMakeTest.cmake b/Tests/RunCMake/file/RunCMakeTest.cmake index 5f85bba..48fa757 100644 --- a/Tests/RunCMake/file/RunCMakeTest.cmake +++ b/Tests/RunCMake/file/RunCMakeTest.cmake @@ -1,6 +1,12 @@ include(RunCMake) run_cmake(DOWNLOAD-hash-mismatch) +run_cmake(DOWNLOAD-unused-argument) +run_cmake(DOWNLOAD-httpheader-not-set) +run_cmake(DOWNLOAD-pass-not-set) +run_cmake(UPLOAD-unused-argument) +run_cmake(UPLOAD-httpheader-not-set) +run_cmake(UPLOAD-pass-not-set) run_cmake(INSTALL-DIRECTORY) run_cmake(INSTALL-MESSAGE-bad) run_cmake(FileOpenFailRead) @@ -18,6 +24,7 @@ run_cmake(LOCK-error-no-result-variable) run_cmake(LOCK-error-no-timeout) run_cmake(LOCK-error-timeout) run_cmake(LOCK-error-unknown-option) +run_cmake(LOCK-lowercase) run_cmake(GLOB) run_cmake(GLOB_RECURSE) # test is valid both for GLOB and GLOB_RECURSE diff --git a/Tests/RunCMake/file/UPLOAD-httpheader-not-set-result.txt b/Tests/RunCMake/file/UPLOAD-httpheader-not-set-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/file/UPLOAD-httpheader-not-set-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/file/UPLOAD-httpheader-not-set-stderr.txt b/Tests/RunCMake/file/UPLOAD-httpheader-not-set-stderr.txt new file mode 100644 index 0000000..341baf5 --- /dev/null +++ b/Tests/RunCMake/file/UPLOAD-httpheader-not-set-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at UPLOAD-httpheader-not-set.cmake:[0-9]+ \(file\): + file UPLOAD missing string for HTTPHEADER. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/file/UPLOAD-httpheader-not-set.cmake b/Tests/RunCMake/file/UPLOAD-httpheader-not-set.cmake new file mode 100644 index 0000000..18d43cc --- /dev/null +++ b/Tests/RunCMake/file/UPLOAD-httpheader-not-set.cmake @@ -0,0 +1 @@ +file(UPLOAD "" "" HTTPHEADER "Content-Type: application/x-compressed-tar" HTTPHEADER) diff --git a/Tests/RunCMake/file/UPLOAD-pass-not-set-result.txt b/Tests/RunCMake/file/UPLOAD-pass-not-set-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/file/UPLOAD-pass-not-set-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/file/UPLOAD-pass-not-set-stderr.txt b/Tests/RunCMake/file/UPLOAD-pass-not-set-stderr.txt new file mode 100644 index 0000000..089c0ad --- /dev/null +++ b/Tests/RunCMake/file/UPLOAD-pass-not-set-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at UPLOAD-pass-not-set.cmake:[0-9]+ \(file\): + file UPLOAD missing string for USERPWD. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/file/UPLOAD-pass-not-set.cmake b/Tests/RunCMake/file/UPLOAD-pass-not-set.cmake new file mode 100644 index 0000000..4f3d86c --- /dev/null +++ b/Tests/RunCMake/file/UPLOAD-pass-not-set.cmake @@ -0,0 +1 @@ +file(UPLOAD "" "" USERPWD) diff --git a/Tests/RunCMake/file/UPLOAD-unused-argument-result.txt b/Tests/RunCMake/file/UPLOAD-unused-argument-result.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/file/UPLOAD-unused-argument-result.txt diff --git a/Tests/RunCMake/file/UPLOAD-unused-argument-stderr.txt b/Tests/RunCMake/file/UPLOAD-unused-argument-stderr.txt new file mode 100644 index 0000000..3c1b744 --- /dev/null +++ b/Tests/RunCMake/file/UPLOAD-unused-argument-stderr.txt @@ -0,0 +1,5 @@ +^CMake Warning \(dev\) at UPLOAD-unused-argument.cmake:[0-9]+ \(file\): + Unexpected argument: JUNK +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) +This warning is for project developers. Use -Wno-dev to suppress it.$ diff --git a/Tests/RunCMake/file/UPLOAD-unused-argument.cmake b/Tests/RunCMake/file/UPLOAD-unused-argument.cmake new file mode 100644 index 0000000..94ac9ac --- /dev/null +++ b/Tests/RunCMake/file/UPLOAD-unused-argument.cmake @@ -0,0 +1,5 @@ +file(UPLOAD + "${CMAKE_CURRENT_SOURCE_DIR}/UPLOAD-unused-argument.txt" + "file://${CMAKE_CURRENT_BINARY_DIR}/unused-argument.txt" + JUNK + ) diff --git a/Tests/RunCMake/file/UPLOAD-unused-argument.txt b/Tests/RunCMake/file/UPLOAD-unused-argument.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/file/UPLOAD-unused-argument.txt diff --git a/Tests/RunCMake/get_filename_component/KnownComponents.cmake b/Tests/RunCMake/get_filename_component/KnownComponents.cmake index d822258..7dfb55d 100644 --- a/Tests/RunCMake/get_filename_component/KnownComponents.cmake +++ b/Tests/RunCMake/get_filename_component/KnownComponents.cmake @@ -19,12 +19,12 @@ foreach(c DIRECTORY NAME EXT NAME_WE PATH) endforeach() # Test Windows paths with DIRECTORY component and an absolute Windows path. -get_filename_component(test_slashes "c:\\path\\to\\filename.ext.in" DIRECTORY) -check("DIRECTORY from backslashes" "${test_slashes}" "c:/path/to") +get_filename_component(test_slashes "C:\\path\\to\\filename.ext.in" DIRECTORY) +check("DIRECTORY from backslashes" "${test_slashes}" "C:/path/to") list(APPEND non_cache_vars test_slashes) -get_filename_component(test_winroot "c:\\filename.ext.in" DIRECTORY) -check("DIRECTORY in windows root" "${test_winroot}" "c:/") +get_filename_component(test_winroot "C:\\filename.ext.in" DIRECTORY) +check("DIRECTORY in windows root" "${test_winroot}" "C:/") list(APPEND non_cache_vars test_winroot) # Test finding absolute paths. @@ -33,8 +33,8 @@ check("ABSOLUTE" "${test_absolute}" "/path/to/filename.ext.in") get_filename_component(test_absolute "/../path/to/filename.ext.in" ABSOLUTE) check("ABSOLUTE .. in root" "${test_absolute}" "/path/to/filename.ext.in") -get_filename_component(test_absolute "c:/../path/to/filename.ext.in" ABSOLUTE) -check("ABSOLUTE .. in windows root" "${test_absolute}" "c:/path/to/filename.ext.in") +get_filename_component(test_absolute "C:/../path/to/filename.ext.in" ABSOLUTE) +check("ABSOLUTE .. in windows root" "${test_absolute}" "C:/path/to/filename.ext.in") list(APPEND non_cache_vars test_absolute) diff --git a/Tests/RunCMake/get_property/directory_properties-stderr.txt b/Tests/RunCMake/get_property/directory_properties-stderr.txt index 80c9877..6d5bcdb 100644 --- a/Tests/RunCMake/get_property/directory_properties-stderr.txt +++ b/Tests/RunCMake/get_property/directory_properties-stderr.txt @@ -3,4 +3,20 @@ get_property: --><-- get_directory_property: -->value<-- get_property: -->value<-- get_directory_property: --><-- -get_property: --><--$ +get_property: --><-- +get_directory_property: -->[^<;]*Tests/RunCMake/get_property/directory_properties<-- +get_property: -->[^<;]*Tests/RunCMake/get_property/directory_properties<-- +get_directory_property: -->[^<;]*Tests/RunCMake/get_property/directory_properties/sub1;[^<;]*Tests/RunCMake/get_property/directory_properties/sub2<-- +get_property: -->[^<;]*Tests/RunCMake/get_property/directory_properties/sub1;[^<;]*Tests/RunCMake/get_property/directory_properties/sub2<-- +get_directory_property: -->CustomTop;InterfaceTop<-- +get_property: -->CustomTop;InterfaceTop<-- +get_directory_property: -->CustomSub;InterfaceSub<-- +get_property: -->CustomSub;InterfaceSub<-- +get_directory_property: -->[^<;]*/Tests/RunCMake/get_property/directory_properties-build<-- +get_property: -->[^<;]*/Tests/RunCMake/get_property/directory_properties-build<-- +get_directory_property: -->[^<;]*/RunCMake/get_property<-- +get_property: -->[^<;]*/Tests/RunCMake/get_property<-- +get_directory_property: -->[^<;]*/Tests/RunCMake/get_property/directory_properties-build/directory_properties<-- +get_property: -->[^<;]*/Tests/RunCMake/get_property/directory_properties-build/directory_properties<-- +get_directory_property: -->[^<;]*/Tests/RunCMake/get_property/directory_properties<-- +get_property: -->[^<;]*/Tests/RunCMake/get_property/directory_properties<--$ diff --git a/Tests/RunCMake/get_property/directory_properties.cmake b/Tests/RunCMake/get_property/directory_properties.cmake index b0a9b1b..4e68738 100644 --- a/Tests/RunCMake/get_property/directory_properties.cmake +++ b/Tests/RunCMake/get_property/directory_properties.cmake @@ -13,3 +13,18 @@ set_directory_properties(PROPERTIES empty "" custom value) check_directory_property("${CMAKE_CURRENT_SOURCE_DIR}" empty) check_directory_property("${CMAKE_CURRENT_SOURCE_DIR}" custom) check_directory_property("${CMAKE_CURRENT_SOURCE_DIR}" noexist) + +add_custom_target(CustomTop) +add_library(InterfaceTop INTERFACE) +add_library(my::InterfaceTop ALIAS InterfaceTop) + +add_subdirectory(directory_properties) +check_directory_property("${CMAKE_CURRENT_SOURCE_DIR}" SUBDIRECTORIES) +check_directory_property("${CMAKE_CURRENT_SOURCE_DIR}/directory_properties" SUBDIRECTORIES) +check_directory_property("${CMAKE_CURRENT_SOURCE_DIR}" BUILDSYSTEM_TARGETS) +check_directory_property("${CMAKE_CURRENT_SOURCE_DIR}/directory_properties" BUILDSYSTEM_TARGETS) + +check_directory_property("${CMAKE_CURRENT_SOURCE_DIR}" BINARY_DIR) +check_directory_property("${CMAKE_CURRENT_SOURCE_DIR}" SOURCE_DIR) +check_directory_property("${CMAKE_CURRENT_SOURCE_DIR}/directory_properties" BINARY_DIR) +check_directory_property("${CMAKE_CURRENT_SOURCE_DIR}/directory_properties" SOURCE_DIR) diff --git a/Tests/RunCMake/get_property/directory_properties/CMakeLists.txt b/Tests/RunCMake/get_property/directory_properties/CMakeLists.txt new file mode 100644 index 0000000..7318b97 --- /dev/null +++ b/Tests/RunCMake/get_property/directory_properties/CMakeLists.txt @@ -0,0 +1,6 @@ +add_subdirectory(sub1) +subdirs(sub2) + +add_custom_target(CustomSub) +add_library(InterfaceSub INTERFACE) +add_library(my::InterfaceSub ALIAS InterfaceSub) diff --git a/Tests/RunCMake/get_property/directory_properties/sub1/CMakeLists.txt b/Tests/RunCMake/get_property/directory_properties/sub1/CMakeLists.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/get_property/directory_properties/sub1/CMakeLists.txt diff --git a/Tests/RunCMake/get_property/directory_properties/sub2/CMakeLists.txt b/Tests/RunCMake/get_property/directory_properties/sub2/CMakeLists.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/get_property/directory_properties/sub2/CMakeLists.txt |