diff options
Diffstat (limited to 'Tests')
15 files changed, 112 insertions, 2 deletions
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 408c941..2a8d3e6 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -1417,6 +1417,10 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release add_subdirectory(FindJsonCpp) endif() + if(CMake_TEST_FindLibLZMA) + add_subdirectory(FindLibLZMA) + endif() + if(CMake_TEST_FindLibRHash) add_subdirectory(FindLibRHash) endif() diff --git a/Tests/FindLibLZMA/CMakeLists.txt b/Tests/FindLibLZMA/CMakeLists.txt new file mode 100644 index 0000000..6dff0ef --- /dev/null +++ b/Tests/FindLibLZMA/CMakeLists.txt @@ -0,0 +1,10 @@ +add_test(NAME FindLibLZMA.Test COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindLibLZMA/Test" + "${CMake_BINARY_DIR}/Tests/FindLibLZMA/Test" + ${build_generator_args} + --build-project TestFindLibLZMA + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) diff --git a/Tests/FindLibLZMA/Test/CMakeLists.txt b/Tests/FindLibLZMA/Test/CMakeLists.txt new file mode 100644 index 0000000..c59dcdb --- /dev/null +++ b/Tests/FindLibLZMA/Test/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.4) +project(TestFindLZMA C) +include(CTest) + +find_package(LibLZMA REQUIRED) + +add_executable(test_tgt main.c) +target_link_libraries(test_tgt LibLZMA::LibLZMA) +add_test(NAME test_tgt COMMAND test_tgt) + +add_executable(test_var main.c) +target_include_directories(test_var PRIVATE ${LIBLZMA_INCLUDE_DIRS}) +target_link_libraries(test_var PRIVATE ${LIBLZMA_LIBRARIES}) +add_test(NAME test_var COMMAND test_var) diff --git a/Tests/FindLibLZMA/Test/main.c b/Tests/FindLibLZMA/Test/main.c new file mode 100644 index 0000000..06e8065 --- /dev/null +++ b/Tests/FindLibLZMA/Test/main.c @@ -0,0 +1,15 @@ +#include <assert.h> +#include <lzma.h> +#include <string.h> + +static const uint8_t test_string[9] = "123456789"; + +int main() +{ + static const uint32_t test_vector = 0xCBF43926; + + uint32_t crc = lzma_crc32(test_string, sizeof(test_string), 0); + assert(crc == test_vector); + + return 0; +} diff --git a/Tests/RunCMake/ExternalProject/LogOutputOnFailure-build-result.txt b/Tests/RunCMake/ExternalProject/LogOutputOnFailure-build-result.txt new file mode 100644 index 0000000..c20fd86 --- /dev/null +++ b/Tests/RunCMake/ExternalProject/LogOutputOnFailure-build-result.txt @@ -0,0 +1 @@ +^[^0] diff --git a/Tests/RunCMake/ExternalProject/LogOutputOnFailure-build-stderr.txt b/Tests/RunCMake/ExternalProject/LogOutputOnFailure-build-stderr.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/ExternalProject/LogOutputOnFailure-build-stderr.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/ExternalProject/LogOutputOnFailure-build-stdout.txt b/Tests/RunCMake/ExternalProject/LogOutputOnFailure-build-stdout.txt new file mode 100644 index 0000000..87e5384 --- /dev/null +++ b/Tests/RunCMake/ExternalProject/LogOutputOnFailure-build-stdout.txt @@ -0,0 +1,8 @@ +( )?-- stdout output is: +( )?This is some dummy output with some long lines to ensure formatting is preserved +( )? Including lines with leading spaces +( )? +( )?And also blank lines[ + ]+ +( )?-- stderr output is: +( )?cmake -E env: no command given diff --git a/Tests/RunCMake/ExternalProject/LogOutputOnFailure.cmake b/Tests/RunCMake/ExternalProject/LogOutputOnFailure.cmake new file mode 100644 index 0000000..863bbef --- /dev/null +++ b/Tests/RunCMake/ExternalProject/LogOutputOnFailure.cmake @@ -0,0 +1,20 @@ +include(ExternalProject) + +set(dummyOutput [[ +This is some dummy output with some long lines to ensure formatting is preserved + Including lines with leading spaces + +And also blank lines +]]) + +ExternalProject_Add(FailsWithOutput + SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR} + CONFIGURE_COMMAND "" + BUILD_COMMAND ${CMAKE_COMMAND} -E echo ${dummyOutput} + COMMAND ${CMAKE_COMMAND} -E env # missing command, forces fail + TEST_COMMAND "" + INSTALL_COMMAND "" + LOG_BUILD YES + LOG_OUTPUT_ON_FAILURE YES + USES_TERMINAL_BUILD YES +) diff --git a/Tests/RunCMake/ExternalProject/LogOutputOnFailureMerged-build-result.txt b/Tests/RunCMake/ExternalProject/LogOutputOnFailureMerged-build-result.txt new file mode 100644 index 0000000..c20fd86 --- /dev/null +++ b/Tests/RunCMake/ExternalProject/LogOutputOnFailureMerged-build-result.txt @@ -0,0 +1 @@ +^[^0] diff --git a/Tests/RunCMake/ExternalProject/LogOutputOnFailureMerged-build-stderr.txt b/Tests/RunCMake/ExternalProject/LogOutputOnFailureMerged-build-stderr.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/ExternalProject/LogOutputOnFailureMerged-build-stderr.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/ExternalProject/LogOutputOnFailureMerged-build-stdout.txt b/Tests/RunCMake/ExternalProject/LogOutputOnFailureMerged-build-stdout.txt new file mode 100644 index 0000000..11c7317 --- /dev/null +++ b/Tests/RunCMake/ExternalProject/LogOutputOnFailureMerged-build-stdout.txt @@ -0,0 +1,7 @@ +( )?-- Log output is: +( )?This is some dummy output with some long lines to ensure formatting is preserved +( )? Including lines with leading spaces +( )? +( )?And also blank lines[ + ]+ +( )?cmake -E env: no command given diff --git a/Tests/RunCMake/ExternalProject/LogOutputOnFailureMerged.cmake b/Tests/RunCMake/ExternalProject/LogOutputOnFailureMerged.cmake new file mode 100644 index 0000000..116448b --- /dev/null +++ b/Tests/RunCMake/ExternalProject/LogOutputOnFailureMerged.cmake @@ -0,0 +1,21 @@ +include(ExternalProject) + +set(dummyOutput [[ +This is some dummy output with some long lines to ensure formatting is preserved + Including lines with leading spaces + +And also blank lines +]]) + +ExternalProject_Add(FailsWithOutput + SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR} + CONFIGURE_COMMAND "" + BUILD_COMMAND ${CMAKE_COMMAND} -E echo ${dummyOutput} + COMMAND ${CMAKE_COMMAND} -E env # missing command, forces fail + TEST_COMMAND "" + INSTALL_COMMAND "" + LOG_BUILD YES + LOG_OUTPUT_ON_FAILURE YES + LOG_MERGED_STDOUTERR YES + USES_TERMINAL_BUILD YES +) diff --git a/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake b/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake index bf11381..caaf0d2 100644 --- a/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake +++ b/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake @@ -29,6 +29,13 @@ endfunction() __ep_test_with_build(MultiCommand) +# Output is not predictable enough to be able to verify it reliably +# when using the various different Visual Studio generators +if(NOT RunCMake_GENERATOR MATCHES "Visual Studio") + __ep_test_with_build(LogOutputOnFailure) + __ep_test_with_build(LogOutputOnFailureMerged) +endif() + # We can't test the substitution when using the old MSYS due to # make/sh mangling the paths (substitution is performed correctly, # but the mangling means we can't reliably test the output). diff --git a/Tests/RunCMake/install/TARGETS-Defaults-Cache-all-check.cmake b/Tests/RunCMake/install/TARGETS-Defaults-Cache-all-check.cmake index 6fc735c..57ad6e1 100644 --- a/Tests/RunCMake/install/TARGETS-Defaults-Cache-all-check.cmake +++ b/Tests/RunCMake/install/TARGETS-Defaults-Cache-all-check.cmake @@ -21,8 +21,8 @@ elseif(CYGWIN) [[lib4]] [[lib4/cyglib4\.dll]] [[mybin]] - [[mybin/exe\.exe]] [[mybin/cyglib1\.dll]] + [[mybin/exe\.exe]] [[myinclude]] [[myinclude/obj4\.h]] [[myinclude/obj5\.h]] diff --git a/Tests/RunCMake/install/TARGETS-Defaults-all-check.cmake b/Tests/RunCMake/install/TARGETS-Defaults-all-check.cmake index 59209e6..c41cb2a 100644 --- a/Tests/RunCMake/install/TARGETS-Defaults-all-check.cmake +++ b/Tests/RunCMake/install/TARGETS-Defaults-all-check.cmake @@ -17,8 +17,8 @@ if(WIN32) elseif(CYGWIN) set(_check_files [[bin]] - [[bin/exe\.exe]] [[bin/cyglib1\.dll]] + [[bin/exe\.exe]] [[include]] [[include/obj4\.h]] [[include/obj5\.h]] |