diff options
Diffstat (limited to 'Tests/RunCMake')
56 files changed, 279 insertions, 15 deletions
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index d2465c4..c2c744f 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -255,6 +255,11 @@ if(PKG_CONFIG_FOUND) add_RunCMake_test(FindPkgConfig) endif() +find_package(GTK2 QUIET) +if (GTK2_FOUND) + add_RunCMake_test(FindGTK2) +endif() + if("${CMAKE_GENERATOR}" MATCHES "Visual Studio") add_RunCMake_test(include_external_msproject) if("${CMAKE_GENERATOR}" MATCHES "Visual Studio ([789]|10)" AND NOT CMAKE_VS_DEVENV_COMMAND) @@ -340,12 +345,14 @@ if("${CMAKE_GENERATOR}" MATCHES "Make|Ninja") endif() add_executable(pseudo_tidy pseudo_tidy.c) add_executable(pseudo_iwyu pseudo_iwyu.c) + add_executable(pseudo_cpplint pseudo_cpplint.c) add_RunCMake_test(ClangTidy -DPSEUDO_TIDY=$<TARGET_FILE:pseudo_tidy>) add_RunCMake_test(IncludeWhatYouUse -DPSEUDO_IWYU=$<TARGET_FILE:pseudo_iwyu>) + add_RunCMake_test(Cpplint -DPSEUDO_CPPLINT=$<TARGET_FILE:pseudo_cpplint>) add_RunCMake_test(CompilerLauncher) endif() -add_RunCMake_test_group(CPack "DEB;RPM;7Z;TBZ2;TGZ;TXZ;TZ;ZIP") +add_RunCMake_test_group(CPack "DEB;RPM;7Z;TBZ2;TGZ;TXZ;TZ;ZIP;STGZ") # add a test to make sure symbols are exported from a shared library # for MSVC compilers CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS property is used add_RunCMake_test(AutoExportDll) diff --git a/Tests/RunCMake/CPack/RunCMakeTest.cmake b/Tests/RunCMake/CPack/RunCMakeTest.cmake index ebaf792..65399db 100644 --- a/Tests/RunCMake/CPack/RunCMakeTest.cmake +++ b/Tests/RunCMake/CPack/RunCMakeTest.cmake @@ -16,7 +16,7 @@ run_cpack_test(GENERATE_SHLIBS_LDCONFIG "DEB" true "COMPONENT") run_cpack_test(INSTALL_SCRIPTS "RPM" false "COMPONENT") run_cpack_test(LONG_FILENAMES "DEB" false "MONOLITHIC") run_cpack_test_subtests(MAIN_COMPONENT "invalid;found" "RPM" false "COMPONENT") -run_cpack_test(MINIMAL "RPM;DEB;7Z;TBZ2;TGZ;TXZ;TZ;ZIP" false "MONOLITHIC;COMPONENT") +run_cpack_test(MINIMAL "RPM;DEB;7Z;TBZ2;TGZ;TXZ;TZ;ZIP;STGZ" false "MONOLITHIC;COMPONENT") run_cpack_test_subtests(PACKAGE_CHECKSUM "invalid;MD5;SHA1;SHA224;SHA256;SHA384;SHA512" "TGZ" false "MONOLITHIC") run_cpack_test(PARTIALLY_RELOCATABLE_WARNING "RPM" false "COMPONENT") run_cpack_test(PER_COMPONENT_FIELDS "RPM;DEB" false "COMPONENT") diff --git a/Tests/RunCMake/CPack/STGZ/Helpers.cmake b/Tests/RunCMake/CPack/STGZ/Helpers.cmake new file mode 100644 index 0000000..08224d3 --- /dev/null +++ b/Tests/RunCMake/CPack/STGZ/Helpers.cmake @@ -0,0 +1,64 @@ +set(ALL_FILES_GLOB "*.sh") + +function(getPackageContent FILE RESULT_VAR) + get_filename_component(path_ "${FILE}" DIRECTORY) + file(REMOVE_RECURSE "${path_}/content") + file(MAKE_DIRECTORY "${path_}/content") + execute_process(COMMAND ${FILE} --prefix=${path_}/content --include-subdir + RESULT_VARIABLE extract_result_ + ERROR_VARIABLE extract_error_ + OUTPUT_STRIP_TRAILING_WHITESPACE) + + if(extract_result_) + message(FATAL_ERROR "Extracting STGZ archive failed: '${extract_result_}';" + " '${extract_error_}'.") + endif() + + file(GLOB_RECURSE package_content_ LIST_DIRECTORIES true RELATIVE + "${path_}/content" "${path_}/content/*") + + set(${RESULT_VAR} "${package_content_}" PARENT_SCOPE) +endfunction() + +function(getPackageNameGlobexpr NAME COMPONENT VERSION REVISION FILE_NO RESULT_VAR) + if(COMPONENT) + set(COMPONENT "-${COMPONENT}") + endif() + + set(${RESULT_VAR} "${NAME}-${VERSION}-*${COMPONENT}.sh" PARENT_SCOPE) +endfunction() + +function(getPackageContentList FILE RESULT_VAR) + getPackageContent("${FILE}" package_content_) + + set(${RESULT_VAR} "${package_content_}" PARENT_SCOPE) +endfunction() + +function(toExpectedContentList FILE_NO CONTENT_VAR) + findExpectedFile("${FILE_NO}" "file_") + + get_filename_component(prefix_ "${file_}" NAME) + # NAME_WE removes everything after the dot and dot is in version so replace instead + string(REPLACE ".sh" "" prefix_ "${prefix_}") + + if(NOT PACKAGING_TYPE STREQUAL "MONOLITHIC") + # STGZ packages don't have component dir prefix in subdir + string(FIND "${prefix_}" "-" pos_ REVERSE) + string(SUBSTRING "${prefix_}" 0 ${pos_} prefix_) + endif() + + if(NOT DEFINED TEST_MAIN_INSTALL_PREFIX_PATH) + set(TEST_MAIN_INSTALL_PREFIX_PATH "/usr") + endif() + + set(filtered_ "${prefix_}") + foreach(part_ IN LISTS ${CONTENT_VAR}) + string(REGEX REPLACE "^${TEST_MAIN_INSTALL_PREFIX_PATH}(/|$)" "" part_ "${part_}") + + if(part_) + list(APPEND filtered_ "${prefix_}/${part_}") + endif() + endforeach() + + set(${CONTENT_VAR} "${filtered_}" PARENT_SCOPE) +endfunction() diff --git a/Tests/RunCMake/CPack/STGZ/Prerequirements.cmake b/Tests/RunCMake/CPack/STGZ/Prerequirements.cmake new file mode 100644 index 0000000..3b015ca --- /dev/null +++ b/Tests/RunCMake/CPack/STGZ/Prerequirements.cmake @@ -0,0 +1,11 @@ +function(get_test_prerequirements found_var config_file) + if(EXISTS "/bin/sh") + #gunzip is not part of posix so we should not rely on it being installed + find_program(GUNZIP_EXECUTABLE gunzip) + + if(GUNZIP_EXECUTABLE) + file(WRITE "${config_file}" "") + set(${found_var} true PARENT_SCOPE) + endif() + endif() +endfunction() diff --git a/Tests/RunCMake/CPack/STGZ/packaging_COMPONENT_default.cmake b/Tests/RunCMake/CPack/STGZ/packaging_COMPONENT_default.cmake new file mode 100644 index 0000000..81a5035 --- /dev/null +++ b/Tests/RunCMake/CPack/STGZ/packaging_COMPONENT_default.cmake @@ -0,0 +1 @@ +set(CPACK_ARCHIVE_COMPONENT_INSTALL "ON") diff --git a/Tests/RunCMake/CommandLine/E___run_iwyu-no-iwyu-stderr.txt b/Tests/RunCMake/CommandLine/E___run_iwyu-no-iwyu-stderr.txt index 0d0d899..35f50b7 100644 --- a/Tests/RunCMake/CommandLine/E___run_iwyu-no-iwyu-stderr.txt +++ b/Tests/RunCMake/CommandLine/E___run_iwyu-no-iwyu-stderr.txt @@ -1 +1 @@ -^__run_iwyu missing --tidy= or --iwyu=$ +^__run_iwyu missing --cpplint=, --iwyu=, --lwyu=, and/or --tidy=$ diff --git a/Tests/RunCMake/Cpplint/C-Build-stdout.txt b/Tests/RunCMake/Cpplint/C-Build-stdout.txt new file mode 100644 index 0000000..6a22b79 --- /dev/null +++ b/Tests/RunCMake/Cpplint/C-Build-stdout.txt @@ -0,0 +1 @@ +Total errors found: 0 diff --git a/Tests/RunCMake/Cpplint/C-error-Build-result.txt b/Tests/RunCMake/Cpplint/C-error-Build-result.txt new file mode 100644 index 0000000..d197c91 --- /dev/null +++ b/Tests/RunCMake/Cpplint/C-error-Build-result.txt @@ -0,0 +1 @@ +[^0] diff --git a/Tests/RunCMake/Cpplint/C-error-Build-stdout.txt b/Tests/RunCMake/Cpplint/C-error-Build-stdout.txt new file mode 100644 index 0000000..3e7a1e9 --- /dev/null +++ b/Tests/RunCMake/Cpplint/C-error-Build-stdout.txt @@ -0,0 +1 @@ +Tests[/\]RunCMake[/\]Cpplint[/\]main\.c:0: message \[category/category\] \[0\] diff --git a/Tests/RunCMake/Cpplint/C-error-launch-Build-result.txt b/Tests/RunCMake/Cpplint/C-error-launch-Build-result.txt new file mode 100644 index 0000000..d197c91 --- /dev/null +++ b/Tests/RunCMake/Cpplint/C-error-launch-Build-result.txt @@ -0,0 +1 @@ +[^0] diff --git a/Tests/RunCMake/Cpplint/C-error-launch-Build-stdout.txt b/Tests/RunCMake/Cpplint/C-error-launch-Build-stdout.txt new file mode 100644 index 0000000..3e7a1e9 --- /dev/null +++ b/Tests/RunCMake/Cpplint/C-error-launch-Build-stdout.txt @@ -0,0 +1 @@ +Tests[/\]RunCMake[/\]Cpplint[/\]main\.c:0: message \[category/category\] \[0\] diff --git a/Tests/RunCMake/Cpplint/C-error-launch.cmake b/Tests/RunCMake/Cpplint/C-error-launch.cmake new file mode 100644 index 0000000..c76e2e2 --- /dev/null +++ b/Tests/RunCMake/Cpplint/C-error-launch.cmake @@ -0,0 +1,3 @@ +set(CTEST_USE_LAUNCHERS 1) +include(CTestUseLaunchers) +include(C-error.cmake) diff --git a/Tests/RunCMake/Cpplint/C-error.cmake b/Tests/RunCMake/Cpplint/C-error.cmake new file mode 100644 index 0000000..29cf7ba --- /dev/null +++ b/Tests/RunCMake/Cpplint/C-error.cmake @@ -0,0 +1,3 @@ +enable_language(C) +set(CMAKE_C_CPPLINT "${PSEUDO_CPPLINT}" --error) +add_executable(main main.c) diff --git a/Tests/RunCMake/Cpplint/C-launch-Build-stdout.txt b/Tests/RunCMake/Cpplint/C-launch-Build-stdout.txt new file mode 100644 index 0000000..6a22b79 --- /dev/null +++ b/Tests/RunCMake/Cpplint/C-launch-Build-stdout.txt @@ -0,0 +1 @@ +Total errors found: 0 diff --git a/Tests/RunCMake/Cpplint/C-launch.cmake b/Tests/RunCMake/Cpplint/C-launch.cmake new file mode 100644 index 0000000..e66ca20 --- /dev/null +++ b/Tests/RunCMake/Cpplint/C-launch.cmake @@ -0,0 +1,3 @@ +set(CTEST_USE_LAUNCHERS 1) +include(CTestUseLaunchers) +include(C.cmake) diff --git a/Tests/RunCMake/Cpplint/C.cmake b/Tests/RunCMake/Cpplint/C.cmake new file mode 100644 index 0000000..68e6ff4 --- /dev/null +++ b/Tests/RunCMake/Cpplint/C.cmake @@ -0,0 +1,3 @@ +enable_language(C) +set(CMAKE_C_CPPLINT "${PSEUDO_CPPLINT}" --verbose=0 --linelength=80) +add_executable(main main.c) diff --git a/Tests/RunCMake/Cpplint/CMakeLists.txt b/Tests/RunCMake/Cpplint/CMakeLists.txt new file mode 100644 index 0000000..a640c56 --- /dev/null +++ b/Tests/RunCMake/Cpplint/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.7) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/Cpplint/CXX-Build-stdout.txt b/Tests/RunCMake/Cpplint/CXX-Build-stdout.txt new file mode 100644 index 0000000..6a22b79 --- /dev/null +++ b/Tests/RunCMake/Cpplint/CXX-Build-stdout.txt @@ -0,0 +1 @@ +Total errors found: 0 diff --git a/Tests/RunCMake/Cpplint/CXX-error-Build-result.txt b/Tests/RunCMake/Cpplint/CXX-error-Build-result.txt new file mode 100644 index 0000000..d197c91 --- /dev/null +++ b/Tests/RunCMake/Cpplint/CXX-error-Build-result.txt @@ -0,0 +1 @@ +[^0] diff --git a/Tests/RunCMake/Cpplint/CXX-error-Build-stdout.txt b/Tests/RunCMake/Cpplint/CXX-error-Build-stdout.txt new file mode 100644 index 0000000..028cd37 --- /dev/null +++ b/Tests/RunCMake/Cpplint/CXX-error-Build-stdout.txt @@ -0,0 +1 @@ +Tests[/\]RunCMake[/\]Cpplint[/\]main\.cxx:0: message \[category\/category\] \[0\] diff --git a/Tests/RunCMake/Cpplint/CXX-error-launch-Build-result.txt b/Tests/RunCMake/Cpplint/CXX-error-launch-Build-result.txt new file mode 100644 index 0000000..d197c91 --- /dev/null +++ b/Tests/RunCMake/Cpplint/CXX-error-launch-Build-result.txt @@ -0,0 +1 @@ +[^0] diff --git a/Tests/RunCMake/Cpplint/CXX-error-launch-Build-stdout.txt b/Tests/RunCMake/Cpplint/CXX-error-launch-Build-stdout.txt new file mode 100644 index 0000000..028cd37 --- /dev/null +++ b/Tests/RunCMake/Cpplint/CXX-error-launch-Build-stdout.txt @@ -0,0 +1 @@ +Tests[/\]RunCMake[/\]Cpplint[/\]main\.cxx:0: message \[category\/category\] \[0\] diff --git a/Tests/RunCMake/Cpplint/CXX-error-launch.cmake b/Tests/RunCMake/Cpplint/CXX-error-launch.cmake new file mode 100644 index 0000000..72dcbe9 --- /dev/null +++ b/Tests/RunCMake/Cpplint/CXX-error-launch.cmake @@ -0,0 +1,3 @@ +set(CTEST_USE_LAUNCHERS 1) +include(CTestUseLaunchers) +include(CXX-error.cmake) diff --git a/Tests/RunCMake/Cpplint/CXX-error.cmake b/Tests/RunCMake/Cpplint/CXX-error.cmake new file mode 100644 index 0000000..ad66ff5 --- /dev/null +++ b/Tests/RunCMake/Cpplint/CXX-error.cmake @@ -0,0 +1,3 @@ +enable_language(CXX) +set(CMAKE_CXX_CPPLINT "${PSEUDO_CPPLINT}" --error) +add_executable(main main.cxx) diff --git a/Tests/RunCMake/Cpplint/CXX-launch-Build-stdout.txt b/Tests/RunCMake/Cpplint/CXX-launch-Build-stdout.txt new file mode 100644 index 0000000..6a22b79 --- /dev/null +++ b/Tests/RunCMake/Cpplint/CXX-launch-Build-stdout.txt @@ -0,0 +1 @@ +Total errors found: 0 diff --git a/Tests/RunCMake/Cpplint/CXX-launch.cmake b/Tests/RunCMake/Cpplint/CXX-launch.cmake new file mode 100644 index 0000000..3002c9d --- /dev/null +++ b/Tests/RunCMake/Cpplint/CXX-launch.cmake @@ -0,0 +1,3 @@ +set(CTEST_USE_LAUNCHERS 1) +include(CTestUseLaunchers) +include(CXX.cmake) diff --git a/Tests/RunCMake/Cpplint/CXX.cmake b/Tests/RunCMake/Cpplint/CXX.cmake new file mode 100644 index 0000000..35f05ee --- /dev/null +++ b/Tests/RunCMake/Cpplint/CXX.cmake @@ -0,0 +1,3 @@ +enable_language(CXX) +set(CMAKE_CXX_CPPLINT "${PSEUDO_CPPLINT}" --verbose=0 --linelength=80) +add_executable(main main.cxx) diff --git a/Tests/RunCMake/Cpplint/RunCMakeTest.cmake b/Tests/RunCMake/Cpplint/RunCMakeTest.cmake new file mode 100644 index 0000000..5a8471e --- /dev/null +++ b/Tests/RunCMake/Cpplint/RunCMakeTest.cmake @@ -0,0 +1,26 @@ +include(RunCMake) + +set(RunCMake_TEST_OPTIONS "-DPSEUDO_CPPLINT=${PSEUDO_CPPLINT}") + +function(run_cpplint lang) + # Use a single build tree for tests without cleaning. + set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/${lang}-build") + set(RunCMake_TEST_NO_CLEAN 1) + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + run_cmake(${lang}) + set(RunCMake_TEST_OUTPUT_MERGE 1) + run_cmake_command(${lang}-Build ${CMAKE_COMMAND} --build .) +endfunction() + +run_cpplint(C) +run_cpplint(CXX) +run_cpplint(C-error) +run_cpplint(CXX-error) + +if(NOT RunCMake_GENERATOR STREQUAL "Watcom WMake") + run_cpplint(C-launch) + run_cpplint(CXX-launch) + run_cpplint(C-error-launch) + run_cpplint(CXX-error-launch) +endif() diff --git a/Tests/RunCMake/Cpplint/main.c b/Tests/RunCMake/Cpplint/main.c new file mode 100644 index 0000000..8488f4e --- /dev/null +++ b/Tests/RunCMake/Cpplint/main.c @@ -0,0 +1,4 @@ +int main(void) +{ + return 0; +} diff --git a/Tests/RunCMake/Cpplint/main.cxx b/Tests/RunCMake/Cpplint/main.cxx new file mode 100644 index 0000000..f8b643a --- /dev/null +++ b/Tests/RunCMake/Cpplint/main.cxx @@ -0,0 +1,4 @@ +int main() +{ + return 0; +} diff --git a/Tests/RunCMake/FindGTK2/CMakeLists.txt b/Tests/RunCMake/FindGTK2/CMakeLists.txt new file mode 100644 index 0000000..93ee9df --- /dev/null +++ b/Tests/RunCMake/FindGTK2/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.5) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/FindGTK2/FindGTK2RunTwice.cmake b/Tests/RunCMake/FindGTK2/FindGTK2RunTwice.cmake new file mode 100644 index 0000000..e0585ee --- /dev/null +++ b/Tests/RunCMake/FindGTK2/FindGTK2RunTwice.cmake @@ -0,0 +1,21 @@ +cmake_minimum_required(VERSION 3.7) +project(testFindGTK2 C) + +# First call +find_package(GTK2 REQUIRED) + +# Backup variables +set(GTK2_LIBRARIES_BAK ${GTK2_LIBRARIES}) +set(GTK2_TARGETS_BAK ${GTK2_TARGETS}) + +# Second call +find_package(GTK2 REQUIRED) + +# Check variables +if(NOT "${GTK2_LIBRARIES_BAK}" STREQUAL "${GTK2_LIBRARIES}") + message(SEND_ERROR "GTK2_LIBRARIES is different:\nbefore: ${GTK2_LIBRARIES_BAK}\nafter: ${GTK2_LIBRARIES}") +endif() + +if(NOT "${GTK2_TARGETS_BAK}" STREQUAL "${GTK2_TARGETS}") + message(SEND_ERROR "GTK2_TARGETS is different:\nbefore: ${GTK2_TARGETS_BAK}\nafter: ${GTK2_TARGETS}") +endif() diff --git a/Tests/RunCMake/FindGTK2/RunCMakeTest.cmake b/Tests/RunCMake/FindGTK2/RunCMakeTest.cmake new file mode 100644 index 0000000..66364ca --- /dev/null +++ b/Tests/RunCMake/FindGTK2/RunCMakeTest.cmake @@ -0,0 +1,3 @@ +include(RunCMake) + +run_cmake(FindGTK2RunTwice) diff --git a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake index 60912c2..f51a107 100644 --- a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake +++ b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake @@ -166,3 +166,24 @@ if(NOT XCODE_VERSION VERSION_LESS 6) unset(RunCMake_TEST_NO_CLEAN) unset(RunCMake_TEST_OPTIONS) endif() + +if(NOT XCODE_VERSION VERSION_LESS 5) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeMultiplatform-build) + set(RunCMake_TEST_NO_CLEAN 1) + + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + + run_cmake(XcodeMultiplatform) + + # build ios before macos + run_cmake_command(XcodeMultiplatform-iphonesimulator-build ${CMAKE_COMMAND} --build . -- -sdk iphonesimulator) + run_cmake_command(XcodeMultiplatform-iphonesimulator-install ${CMAKE_COMMAND} --build . --target install -- -sdk iphonesimulator DESTDIR=${RunCMake_TEST_BINARY_DIR}/_install_iphonesimulator) + + run_cmake_command(XcodeMultiplatform-macosx-build ${CMAKE_COMMAND} --build . -- -sdk macosx) + run_cmake_command(XcodeMultiplatform-macosx-install ${CMAKE_COMMAND} --build . --target install -- -sdk macosx DESTDIR=${RunCMake_TEST_BINARY_DIR}/_install_macosx) + + unset(RunCMake_TEST_BINARY_DIR) + unset(RunCMake_TEST_NO_CLEAN) + unset(RunCMake_TEST_OPTIONS) +endif() diff --git a/Tests/RunCMake/XcodeProject/XcodeMultiplatform.cmake b/Tests/RunCMake/XcodeProject/XcodeMultiplatform.cmake new file mode 100644 index 0000000..a1064f4 --- /dev/null +++ b/Tests/RunCMake/XcodeProject/XcodeMultiplatform.cmake @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.3) +enable_language(CXX) + +set_property(GLOBAL PROPERTY XCODE_EMIT_EFFECTIVE_PLATFORM_NAME ON) + +set(CMAKE_XCODE_ATTRIBUTE_SUPPORTED_PLATFORMS "macosx iphonesimulator") +set(CMAKE_MACOSX_BUNDLE true) + +add_library(library STATIC foo.cpp) + +add_executable(main main.cpp) +target_link_libraries(main library) + +install(TARGETS library ARCHIVE DESTINATION lib) diff --git a/Tests/RunCMake/ctest_memcheck/RunCMakeTest.cmake b/Tests/RunCMake/ctest_memcheck/RunCMakeTest.cmake index 352a381..ab4c5ab 100644 --- a/Tests/RunCMake/ctest_memcheck/RunCMakeTest.cmake +++ b/Tests/RunCMake/ctest_memcheck/RunCMakeTest.cmake @@ -19,7 +19,7 @@ unset(CMAKELISTS_EXTRA_CODE) #----------------------------------------------------------------------------- # add ThreadSanitizer test set(CTEST_EXTRA_CODE -"set(CTEST_MEMORYCHECK_COMMAND_OPTIONS \"report_bugs=1 history_size=5 exitcode=55\") +"set(CTEST_MEMORYCHECK_SANITIZER_OPTIONS \"report_bugs=1:history_size=5:exitcode=55\") ") set(CMAKELISTS_EXTRA_CODE "add_test(NAME TestSan COMMAND \"\${CMAKE_COMMAND}\" @@ -71,7 +71,7 @@ unset(CTEST_EXTRA_CODE) #----------------------------------------------------------------------------- # add MemorySanitizer test set(CTEST_EXTRA_CODE -"set(CTEST_MEMORYCHECK_COMMAND_OPTIONS \"simulate_sanitizer=1:report_bugs=1:history_size=5:exitcode=55\") +"set(CTEST_MEMORYCHECK_SANITIZER_OPTIONS \"simulate_sanitizer=1:report_bugs=1:history_size=5:exitcode=55\") ") set(CMAKELISTS_EXTRA_CODE "add_test(NAME TestSan COMMAND \"\${CMAKE_COMMAND}\" diff --git a/Tests/RunCMake/ctest_memcheck/testAddressLeakSanitizer.cmake b/Tests/RunCMake/ctest_memcheck/testAddressLeakSanitizer.cmake index 2a57b11..ca36a7c 100644 --- a/Tests/RunCMake/ctest_memcheck/testAddressLeakSanitizer.cmake +++ b/Tests/RunCMake/ctest_memcheck/testAddressLeakSanitizer.cmake @@ -2,7 +2,7 @@ # options message("ASAN_OPTIONS = [$ENV{ASAN_OPTIONS}]") -string(REGEX REPLACE ".*log_path=\"([^\"]*)\".*" "\\1" LOG_FILE "$ENV{ASAN_OPTIONS}") +string(REGEX REPLACE ".*log_path=\'([^\']*)\'.*" "\\1" LOG_FILE "$ENV{ASAN_OPTIONS}") message("LOG_FILE=[${LOG_FILE}]") # if we are not asked to simulate AddressSanitizer don't do it diff --git a/Tests/RunCMake/ctest_memcheck/testAddressSanitizer.cmake b/Tests/RunCMake/ctest_memcheck/testAddressSanitizer.cmake index 3082e4b..1219666 100644 --- a/Tests/RunCMake/ctest_memcheck/testAddressSanitizer.cmake +++ b/Tests/RunCMake/ctest_memcheck/testAddressSanitizer.cmake @@ -2,7 +2,7 @@ # options message("ASAN_OPTIONS = [$ENV{ASAN_OPTIONS}]") -string(REGEX REPLACE ".*log_path=\"([^\"]*)\".*" "\\1" LOG_FILE "$ENV{ASAN_OPTIONS}") +string(REGEX REPLACE ".*log_path=\'([^\']*)\'.*" "\\1" LOG_FILE "$ENV{ASAN_OPTIONS}") message("LOG_FILE=[${LOG_FILE}]") # if we are not asked to simulate address sanitizer don't do it diff --git a/Tests/RunCMake/ctest_memcheck/testLeakSanitizer.cmake b/Tests/RunCMake/ctest_memcheck/testLeakSanitizer.cmake index af214c8..6d51f83 100644 --- a/Tests/RunCMake/ctest_memcheck/testLeakSanitizer.cmake +++ b/Tests/RunCMake/ctest_memcheck/testLeakSanitizer.cmake @@ -2,7 +2,7 @@ # options message("LSAN_OPTIONS = [$ENV{LSAN_OPTIONS}]") -string(REGEX REPLACE ".*log_path=\"([^\"]*)\".*" "\\1" LOG_FILE "$ENV{LSAN_OPTIONS}") +string(REGEX REPLACE ".*log_path=\'([^\']*)\'.*" "\\1" LOG_FILE "$ENV{LSAN_OPTIONS}") message("LOG_FILE=[${LOG_FILE}]") # if we are not asked to simulate LeakSanitizer don't do it diff --git a/Tests/RunCMake/ctest_memcheck/testMemorySanitizer.cmake b/Tests/RunCMake/ctest_memcheck/testMemorySanitizer.cmake index c87af9a..3b3ac22 100644 --- a/Tests/RunCMake/ctest_memcheck/testMemorySanitizer.cmake +++ b/Tests/RunCMake/ctest_memcheck/testMemorySanitizer.cmake @@ -1,8 +1,8 @@ -# this file simulates a program that has been built with thread sanitizer +# this file simulates a program that has been built with MemorySanitizer # options message("MSAN_OPTIONS = [$ENV{MSAN_OPTIONS}]") -string(REGEX REPLACE ".*log_path=\"([^\"]*)\".*" "\\1" LOG_FILE "$ENV{MSAN_OPTIONS}") +string(REGEX REPLACE ".*log_path=\'([^\']*)\'.*" "\\1" LOG_FILE "$ENV{MSAN_OPTIONS}") message("LOG_FILE=[${LOG_FILE}]") # if we are not asked to simulate address sanitizer don't do it diff --git a/Tests/RunCMake/ctest_memcheck/testThreadSanitizer.cmake b/Tests/RunCMake/ctest_memcheck/testThreadSanitizer.cmake index d591931..e7a5c9f 100644 --- a/Tests/RunCMake/ctest_memcheck/testThreadSanitizer.cmake +++ b/Tests/RunCMake/ctest_memcheck/testThreadSanitizer.cmake @@ -1,8 +1,8 @@ -# this file simulates a program that has been built with thread sanitizer +# this file simulates a program that has been built with ThreadSanitizer # options message("TSAN_OPTIONS = [$ENV{TSAN_OPTIONS}]") -string(REGEX REPLACE ".*log_path=\"([^\"]*)\".*" "\\1" LOG_FILE "$ENV{TSAN_OPTIONS}") +string(REGEX REPLACE ".*log_path=\'([^\']*)\'.*" "\\1" LOG_FILE "$ENV{TSAN_OPTIONS}") message("LOG_FILE=[${LOG_FILE}]") set(error_types diff --git a/Tests/RunCMake/ctest_memcheck/testUndefinedBehaviorSanitizer.cmake b/Tests/RunCMake/ctest_memcheck/testUndefinedBehaviorSanitizer.cmake index 8ef3c0a..ba6122d 100644 --- a/Tests/RunCMake/ctest_memcheck/testUndefinedBehaviorSanitizer.cmake +++ b/Tests/RunCMake/ctest_memcheck/testUndefinedBehaviorSanitizer.cmake @@ -1,8 +1,8 @@ -# this file simulates a program that has been built with undefined behavior -# sanitizer options +# this file simulates a program that has been built with +# UndefinedBehaviorSanitizer options message("UBSAN_OPTIONS = [$ENV{UBSAN_OPTIONS}]") -string(REGEX REPLACE ".*log_path=\"([^\"]*)\".*" "\\1" LOG_FILE "$ENV{UBSAN_OPTIONS}") +string(REGEX REPLACE ".*log_path=\'([^\']*)\'.*" "\\1" LOG_FILE "$ENV{UBSAN_OPTIONS}") message("LOG_FILE=[${LOG_FILE}]") # if we are not asked to simulate address sanitizer don't do it diff --git a/Tests/RunCMake/pseudo_cpplint.c b/Tests/RunCMake/pseudo_cpplint.c new file mode 100644 index 0000000..8b9ebf4 --- /dev/null +++ b/Tests/RunCMake/pseudo_cpplint.c @@ -0,0 +1,21 @@ +#include <stdio.h> +#include <string.h> + +int main(int argc, char* argv[]) +{ + int error = 0; + int i; + for (i = 1; i < argc; ++i) { + if (strcmp(argv[i], "--error") == 0) { + error = 1; + } + if (argv[i][0] != '-') { + if (error) { + fprintf(stderr, "%s:0: message [category/category] [0]\n", argv[i]); + } + fprintf(stdout, "Done processing %s\nTotal errors found: %i\n", argv[i], + error); + } + } + return error; +} diff --git a/Tests/RunCMake/string/RunCMakeTest.cmake b/Tests/RunCMake/string/RunCMakeTest.cmake index 8067d9d..38a77b0 100644 --- a/Tests/RunCMake/string/RunCMakeTest.cmake +++ b/Tests/RunCMake/string/RunCMakeTest.cmake @@ -6,6 +6,11 @@ run_cmake(AppendNoArgs) run_cmake(Concat) run_cmake(ConcatNoArgs) +run_cmake(Timestamp) +run_cmake(TimestampEmpty) +run_cmake(TimestampInvalid) +run_cmake(TimestampInvalid2) + run_cmake(Uuid) run_cmake(UuidMissingNamespace) run_cmake(UuidMissingNamespaceValue) diff --git a/Tests/RunCMake/string/Timestamp-result.txt b/Tests/RunCMake/string/Timestamp-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/string/Timestamp-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/string/Timestamp-stderr.txt b/Tests/RunCMake/string/Timestamp-stderr.txt new file mode 100644 index 0000000..c12b070 --- /dev/null +++ b/Tests/RunCMake/string/Timestamp-stderr.txt @@ -0,0 +1 @@ +RESULT=2005-08-07 23:19:49 Sun Aug 05 day=219 wd=0 week=32 %%I=11 diff --git a/Tests/RunCMake/string/Timestamp.cmake b/Tests/RunCMake/string/Timestamp.cmake new file mode 100644 index 0000000..1232300 --- /dev/null +++ b/Tests/RunCMake/string/Timestamp.cmake @@ -0,0 +1,3 @@ +set(ENV{SOURCE_DATE_EPOCH} "1123456789") +string(TIMESTAMP RESULT "%Y-%m-%d %H:%M:%S %a %b %y day=%j wd=%w week=%U %%I=%I" UTC) +message("RESULT=${RESULT}") diff --git a/Tests/RunCMake/string/TimestampEmpty-result.txt b/Tests/RunCMake/string/TimestampEmpty-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/string/TimestampEmpty-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/string/TimestampEmpty-stderr.txt b/Tests/RunCMake/string/TimestampEmpty-stderr.txt new file mode 100644 index 0000000..35cbd3c --- /dev/null +++ b/Tests/RunCMake/string/TimestampEmpty-stderr.txt @@ -0,0 +1 @@ +RESULT=2 diff --git a/Tests/RunCMake/string/TimestampEmpty.cmake b/Tests/RunCMake/string/TimestampEmpty.cmake new file mode 100644 index 0000000..21b770f --- /dev/null +++ b/Tests/RunCMake/string/TimestampEmpty.cmake @@ -0,0 +1,3 @@ +set(ENV{SOURCE_DATE_EPOCH} "") +string(TIMESTAMP RESULT "%Y-%m-%d %H:%M:%S" UTC) +message("RESULT=${RESULT}") diff --git a/Tests/RunCMake/string/TimestampInvalid-result.txt b/Tests/RunCMake/string/TimestampInvalid-result.txt new file mode 100644 index 0000000..f64f5d8 --- /dev/null +++ b/Tests/RunCMake/string/TimestampInvalid-result.txt @@ -0,0 +1 @@ +27 diff --git a/Tests/RunCMake/string/TimestampInvalid-stderr.txt b/Tests/RunCMake/string/TimestampInvalid-stderr.txt new file mode 100644 index 0000000..75566da --- /dev/null +++ b/Tests/RunCMake/string/TimestampInvalid-stderr.txt @@ -0,0 +1 @@ +CMake Error: Cannot parse SOURCE_DATE_EPOCH as integer diff --git a/Tests/RunCMake/string/TimestampInvalid.cmake b/Tests/RunCMake/string/TimestampInvalid.cmake new file mode 100644 index 0000000..ab36270 --- /dev/null +++ b/Tests/RunCMake/string/TimestampInvalid.cmake @@ -0,0 +1,3 @@ +set(ENV{SOURCE_DATE_EPOCH} "invalid-integer") +string(TIMESTAMP RESULT "%Y-%m-%d %H:%M:%S" UTC) +message("RESULT=${RESULT}") diff --git a/Tests/RunCMake/string/TimestampInvalid2-result.txt b/Tests/RunCMake/string/TimestampInvalid2-result.txt new file mode 100644 index 0000000..f64f5d8 --- /dev/null +++ b/Tests/RunCMake/string/TimestampInvalid2-result.txt @@ -0,0 +1 @@ +27 diff --git a/Tests/RunCMake/string/TimestampInvalid2-stderr.txt b/Tests/RunCMake/string/TimestampInvalid2-stderr.txt new file mode 100644 index 0000000..75566da --- /dev/null +++ b/Tests/RunCMake/string/TimestampInvalid2-stderr.txt @@ -0,0 +1 @@ +CMake Error: Cannot parse SOURCE_DATE_EPOCH as integer diff --git a/Tests/RunCMake/string/TimestampInvalid2.cmake b/Tests/RunCMake/string/TimestampInvalid2.cmake new file mode 100644 index 0000000..5cc61b8 --- /dev/null +++ b/Tests/RunCMake/string/TimestampInvalid2.cmake @@ -0,0 +1,3 @@ +set(ENV{SOURCE_DATE_EPOCH} "123trailing-garbage") +string(TIMESTAMP RESULT "%Y-%m-%d %H:%M:%S" UTC) +message("RESULT=${RESULT}") |