diff options
author | Brad King <brad.king@kitware.com> | 2017-07-13 11:46:16 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2017-07-13 11:46:47 (GMT) |
commit | 0f158272d6ad0f681495482530b37d307676a157 (patch) | |
tree | a84fe0133cf3a5f508bd07cb8a5a5f455ecc859e /Tests | |
parent | f5be951117711a3965db0f9cd59a2913efacece7 (diff) | |
parent | 117033c1d97456833e49336f6f3ebda5de3a5cbd (diff) | |
download | CMake-0f158272d6ad0f681495482530b37d307676a157.zip CMake-0f158272d6ad0f681495482530b37d307676a157.tar.gz CMake-0f158272d6ad0f681495482530b37d307676a157.tar.bz2 |
Merge topic 'test_include_files'
117033c1 Add TEST_INCLUDE_DIR[S] unit test
ed5bde30 Add TEST_INCLUDE_FILES
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1031
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/RunCMake/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/test_include_dirs/CMakeLists.txt | 3 | ||||
-rw-r--r-- | Tests/RunCMake/test_include_dirs/RunCMakeTest.cmake | 17 | ||||
-rw-r--r-- | Tests/RunCMake/test_include_dirs/TID-test-stdout.txt | 17 | ||||
-rw-r--r-- | Tests/RunCMake/test_include_dirs/TID.cmake | 29 | ||||
-rw-r--r-- | Tests/RunCMake/test_include_dirs/add-tests.cmake | 8 | ||||
-rw-r--r-- | Tests/RunCMake/test_include_dirs/dummy.cpp | 4 |
7 files changed, 79 insertions, 0 deletions
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index e15dd6c..347b9d2 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -223,6 +223,7 @@ add_RunCMake_test(return) add_RunCMake_test(separate_arguments) add_RunCMake_test(set_property) add_RunCMake_test(string) +add_RunCMake_test(test_include_dirs) foreach(var CMAKE_C_COMPILER_ID CMAKE_C_COMPILER_VERSION diff --git a/Tests/RunCMake/test_include_dirs/CMakeLists.txt b/Tests/RunCMake/test_include_dirs/CMakeLists.txt new file mode 100644 index 0000000..dc92486 --- /dev/null +++ b/Tests/RunCMake/test_include_dirs/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.6) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/test_include_dirs/RunCMakeTest.cmake b/Tests/RunCMake/test_include_dirs/RunCMakeTest.cmake new file mode 100644 index 0000000..d1633e4 --- /dev/null +++ b/Tests/RunCMake/test_include_dirs/RunCMakeTest.cmake @@ -0,0 +1,17 @@ +include(RunCMake) + +function(run_TID) + # Use a single build tree for a few tests without cleaning. + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/TID-build) + set(RunCMake_TEST_NO_CLEAN 1) + if(RunCMake_GENERATOR MATCHES "Make|Ninja") + set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Debug) + endif() + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + run_cmake(TID) + run_cmake_command(TID-build ${CMAKE_COMMAND} --build . --config Debug) + run_cmake_command(TID-test ${CMAKE_CTEST_COMMAND} -C Debug) +endfunction() + +run_TID() diff --git a/Tests/RunCMake/test_include_dirs/TID-test-stdout.txt b/Tests/RunCMake/test_include_dirs/TID-test-stdout.txt new file mode 100644 index 0000000..19bf051 --- /dev/null +++ b/Tests/RunCMake/test_include_dirs/TID-test-stdout.txt @@ -0,0 +1,17 @@ +Test project .* + Start 1: house\.dog +1/6 Test #1: house\.dog \.+ +Passed +[0-9.]+ sec + Start 2: house\.cat +2/6 Test #2: house\.cat \.+ +Passed +[0-9.]+ sec + Start 3: farm\.cow +3/6 Test #3: farm\.cow \.+ +Passed +[0-9.]+ sec + Start 4: farm\.pig +4/6 Test #4: farm\.pig \.+ +Passed +[0-9.]+ sec + Start 5: zoo\.fox +5/6 Test #5: zoo\.fox \.+ +Passed +[0-9.]+ sec + Start 6: zoo\.emu +6/6 Test #6: zoo\.emu \.+ +Passed +[0-9.]+ sec + +100% tests passed, 0 tests failed out of 6 + +Total Test time \(real\) = +[0-9.]+ sec diff --git a/Tests/RunCMake/test_include_dirs/TID.cmake b/Tests/RunCMake/test_include_dirs/TID.cmake new file mode 100644 index 0000000..1e74f90 --- /dev/null +++ b/Tests/RunCMake/test_include_dirs/TID.cmake @@ -0,0 +1,29 @@ +project(test_include_dirs) +include(CTest) + +enable_testing() + +add_executable(dummy dummy.cpp) + +function(generate_tests NAME) + set(ctest_file "${CMAKE_CURRENT_BINARY_DIR}/${NAME}_tests.cmake") + add_custom_command( + OUTPUT "${ctest_file}" + COMMAND "${CMAKE_COMMAND}" + -D "TEST_EXECUTABLE=$<TARGET_FILE:dummy>" + -D "TEST_SUITE=${NAME}" + -D "TEST_NAMES=${ARGN}" + -D "CTEST_FILE=${ctest_file}" + -P "${CMAKE_CURRENT_SOURCE_DIR}/add-tests.cmake" + VERBATIM + ) + add_custom_target(${NAME}_tests ALL DEPENDS "${ctest_file}") +endfunction() + +generate_tests(house dog cat) +generate_tests(farm cow pig) +generate_tests(zoo fox emu) + +set_property(DIRECTORY PROPERTY TEST_INCLUDE_FILE "house_tests.cmake") +set_property(DIRECTORY APPEND PROPERTY TEST_INCLUDE_FILES "farm_tests.cmake") +set_property(DIRECTORY APPEND PROPERTY TEST_INCLUDE_FILES "zoo_tests.cmake") diff --git a/Tests/RunCMake/test_include_dirs/add-tests.cmake b/Tests/RunCMake/test_include_dirs/add-tests.cmake new file mode 100644 index 0000000..e74665a --- /dev/null +++ b/Tests/RunCMake/test_include_dirs/add-tests.cmake @@ -0,0 +1,8 @@ +set(script) + +foreach(TEST_NAME ${TEST_NAMES}) + set(script "${script}add_test(\"${TEST_SUITE}.${TEST_NAME}\"") + set(script "${script} \"${TEST_EXECUTABLE}\")\n") +endforeach() + +file(WRITE "${CTEST_FILE}" "${script}") diff --git a/Tests/RunCMake/test_include_dirs/dummy.cpp b/Tests/RunCMake/test_include_dirs/dummy.cpp new file mode 100644 index 0000000..f8b643a --- /dev/null +++ b/Tests/RunCMake/test_include_dirs/dummy.cpp @@ -0,0 +1,4 @@ +int main() +{ + return 0; +} |