From d331292c121269ccfceee302a0f9bbb960b9f02d Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Wed, 7 Aug 2013 17:07:30 -0400 Subject: cmTestGenerator: Evaluate generator expressions in test properties This is useful for cases like: add_test(NAME mytest COMMAND mydriver $) set_tests_properties(mytest PROPERTIES REQUIRED_FILES "$" WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/$" ) In this example we require the actual test executable to exist to run the test in addition to the test driver at argv[0]. Also the $ expression improves over \${CTEST_CONFIGURATION_TYPE} because the latter is not normalized for case-sensitive filesystems. --- Tests/GeneratorExpression/CMakeLists.txt | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'Tests/GeneratorExpression/CMakeLists.txt') diff --git a/Tests/GeneratorExpression/CMakeLists.txt b/Tests/GeneratorExpression/CMakeLists.txt index 4d8d7ed25d..89d878076b 100644 --- a/Tests/GeneratorExpression/CMakeLists.txt +++ b/Tests/GeneratorExpression/CMakeLists.txt @@ -1,5 +1,7 @@ cmake_minimum_required (VERSION 2.8.8) -project(GeneratorExpression CXX) +project(GeneratorExpression) + +include(CTest) # This test is split into multiple parts as needed to avoid NMake command # length limits. @@ -190,3 +192,31 @@ add_custom_target(check-part3 ALL COMMAND ${CMAKE_COMMAND} -E echo "check done (part 3 of 3)" VERBATIM ) + +#----------------------------------------------------------------------------- +# Cover test properties with generator expressions. +add_executable(echo echo.c) +add_executable(pwd pwd.c) + +add_test(NAME echo-configuration COMMAND echo $) +set_property(TEST echo-configuration PROPERTY + PASS_REGULAR_EXPRESSION "^$\n$") + +add_test(NAME echo-target-file COMMAND echo $) +set_property(TEST echo-target-file PROPERTY + PASS_REGULAR_EXPRESSION "/echo${CMAKE_EXECUTABLE_SUFFIX}\n$") +set_property(TEST echo-target-file PROPERTY + REQUIRED_FILES "$") + +add_test(NAME working-dir-arg + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/WorkingDirectory/$" + COMMAND pwd) +set_property(TEST working-dir-arg PROPERTY + PASS_REGULAR_EXPRESSION "WorkingDirectory/$\n$") +foreach(c ${CMAKE_CONFIGURATION_TYPES} ${CMAKE_BUILD_TYPE}) + file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/WorkingDirectory/${c}") +endforeach() + +add_test(echo-old-style echo "\$") +set_property(TEST echo-old-style PROPERTY + PASS_REGULAR_EXPRESSION "^\\$\n$") -- cgit v1.2.1