From d7f1a100d92a772e12b3c0daee77e91d4bb35c9a Mon Sep 17 00:00:00 2001 From: Brad King Date: Sun, 23 Feb 2025 08:25:32 -0500 Subject: [PATCH] Tests: Split CustomTransitiveProperties argument checks into helper --- .../CustomTransitiveProperties/CMakeLists.txt | 2 ++ Tests/CustomTransitiveProperties/check-args.c | 16 ++++++++++++++ Tests/CustomTransitiveProperties/main.c | 21 ++----------------- 3 files changed, 20 insertions(+), 19 deletions(-) create mode 100644 Tests/CustomTransitiveProperties/check-args.c diff --git a/Tests/CustomTransitiveProperties/CMakeLists.txt b/Tests/CustomTransitiveProperties/CMakeLists.txt index 83ceff5482..8c276e9448 100644 --- a/Tests/CustomTransitiveProperties/CMakeLists.txt +++ b/Tests/CustomTransitiveProperties/CMakeLists.txt @@ -91,6 +91,7 @@ target_compile_definitions(CustomTransitiveProperties PRIVATE ) # Test TRANSITIVE_*_PROPERTY evaluation outside of usage requirements. +add_executable(check-args check-args.c) set(out "${CMAKE_CURRENT_BINARY_DIR}/out-$.txt") file(GENERATE OUTPUT "${out}" CONTENT "# file(GENERATE) produced: iface1 CUSTOM_A: '$' @@ -129,6 +130,7 @@ main INTERFACE_CUSTOM_W: '$ -Dout=${out} -P${CMAKE_CURRENT_SOURCE_DIR}/check.cmake COMMAND CustomTransitiveProperties + COMMAND check-args "$" "CUSTOM_A_STATIC1;CUSTOM_A_IFACE2;CUSTOM_A_TARGET_TYPE_STATIC_LIBRARY;CUSTOM_A_IFACE1;CUSTOM_A_TARGET_NAME_STATIC1" "$" "CUSTOM_B_STATIC1;CUSTOM_B_IFACE1" "$" "CUSTOM_U_STATIC1;CUSTOM_U_IFACE2;CUSTOM_U_TARGET_TYPE_STATIC_LIBRARY;CUSTOM_U_IFACE1;CUSTOM_U_TARGET_NAME_STATIC1" diff --git a/Tests/CustomTransitiveProperties/check-args.c b/Tests/CustomTransitiveProperties/check-args.c new file mode 100644 index 0000000000..da97f8a695 --- /dev/null +++ b/Tests/CustomTransitiveProperties/check-args.c @@ -0,0 +1,16 @@ +#include +#include + +int main(int argc, char** argv) +{ + int result = 0; + int i; + for (i = 2; i < argc; i += 2) { + if (strcmp(argv[i - 1], argv[i]) != 0) { + fprintf(stderr, "Argument %d expected '%s' but got '%s'.\n", i, argv[i], + argv[i - 1]); + result = 1; + } + } + return result; +} diff --git a/Tests/CustomTransitiveProperties/main.c b/Tests/CustomTransitiveProperties/main.c index ab70eb0816..03325a0517 100644 --- a/Tests/CustomTransitiveProperties/main.c +++ b/Tests/CustomTransitiveProperties/main.c @@ -1,6 +1,3 @@ -#include -#include - #ifdef CUSTOM_A_IFACE1 # error "CUSTOM_A_IFACE1 incorrectly defined" #endif @@ -117,21 +114,7 @@ extern int static1(void); extern int object1(void); -int check_args(int argc, char** argv) +int main(void) { - int result = 0; - int i; - for (i = 2; i < argc; i += 2) { - if (strcmp(argv[i - 1], argv[i]) != 0) { - fprintf(stderr, "Argument %d expected '%s' but got '%s'.\n", i, argv[i], - argv[i - 1]); - result = 1; - } - } - return result; -} - -int main(int argc, char** argv) -{ - return static1() + object1() + check_args(argc, argv); + return static1() + object1(); }