diff options
Diffstat (limited to 'Tests/GeneratorExpression')
-rw-r--r-- | Tests/GeneratorExpression/CMakeLists.txt | 32 | ||||
-rw-r--r-- | Tests/GeneratorExpression/echo.c | 8 | ||||
-rw-r--r-- | Tests/GeneratorExpression/pwd.c | 34 |
3 files changed, 73 insertions, 1 deletions
diff --git a/Tests/GeneratorExpression/CMakeLists.txt b/Tests/GeneratorExpression/CMakeLists.txt index 4d8d7ed..89d8780 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 $<CONFIGURATION>) +set_property(TEST echo-configuration PROPERTY + PASS_REGULAR_EXPRESSION "^$<CONFIGURATION>\n$") + +add_test(NAME echo-target-file COMMAND echo $<TARGET_FILE: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 "$<TARGET_FILE:echo>") + +add_test(NAME working-dir-arg + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/WorkingDirectory/$<CONFIGURATION>" + COMMAND pwd) +set_property(TEST working-dir-arg PROPERTY + PASS_REGULAR_EXPRESSION "WorkingDirectory/$<CONFIGURATION>\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 "\$<CONFIGURATION>") +set_property(TEST echo-old-style PROPERTY + PASS_REGULAR_EXPRESSION "^\\$<CONFIGURATION>\n$") diff --git a/Tests/GeneratorExpression/echo.c b/Tests/GeneratorExpression/echo.c new file mode 100644 index 0000000..06b0844 --- /dev/null +++ b/Tests/GeneratorExpression/echo.c @@ -0,0 +1,8 @@ +#include <stdio.h> +#include <stdlib.h> + +int main(int argc, char* argv[]) +{ + printf("%s\n", argv[1]); + return EXIT_SUCCESS; +} diff --git a/Tests/GeneratorExpression/pwd.c b/Tests/GeneratorExpression/pwd.c new file mode 100644 index 0000000..054b1af --- /dev/null +++ b/Tests/GeneratorExpression/pwd.c @@ -0,0 +1,34 @@ +#include <limits.h> +#include <stdio.h> +#include <stdlib.h> + +#ifdef _WIN32 +#include <direct.h> +#define getcurdir _getcwd +#else +#include <unistd.h> +#define getcurdir getcwd +#endif + +int main(int argc, char* argv[]) +{ +#define BUFSZ 20000 + char buf[BUFSZ + 1]; +#ifdef _WIN32 + char *pos; +#endif + getcurdir(buf, BUFSZ); +#ifdef _WIN32 + pos = buf; + while (*pos) + { + if (*pos == '\\') + { + *pos = '/'; + } + ++pos; + } +#endif + printf("%s\n", buf); + return EXIT_SUCCESS; +} |