From c05ea48545f04dee8666094b0731366b64dfc9ad Mon Sep 17 00:00:00 2001 From: Taylor Braun-Jones Date: Mon, 21 Mar 2016 14:34:34 -0400 Subject: [PATCH] VS: Improve unit test macros Change `getFirstProject` macro to more flexible version `getProjectNames` --- .../VSSolution/StartupProject-check.cmake | 3 ++- .../VSSolution/StartupProjectMissing-check.cmake | 3 ++- Tests/RunCMake/VSSolution/solution_parsing.cmake | 15 ++++++++------- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Tests/RunCMake/VSSolution/StartupProject-check.cmake b/Tests/RunCMake/VSSolution/StartupProject-check.cmake index 352bbd53f..f36aab275 100644 --- a/Tests/RunCMake/VSSolution/StartupProject-check.cmake +++ b/Tests/RunCMake/VSSolution/StartupProject-check.cmake @@ -1,4 +1,5 @@ -getFirstProject(first_project StartupProject) +getProjectNames(projects) +list(GET projects 0 first_project) if(NOT first_project STREQUAL "TestStartup") error("TestStartup is not the startup project") endif() diff --git a/Tests/RunCMake/VSSolution/StartupProjectMissing-check.cmake b/Tests/RunCMake/VSSolution/StartupProjectMissing-check.cmake index 95fede754..b1017dd07 100644 --- a/Tests/RunCMake/VSSolution/StartupProjectMissing-check.cmake +++ b/Tests/RunCMake/VSSolution/StartupProjectMissing-check.cmake @@ -1,4 +1,5 @@ -getFirstProject(first_project StartupProjectMissing) +getProjectNames(projects) +list(GET projects 0 first_project) if(NOT first_project STREQUAL "ALL_BUILD") error("ALL_BUILD is not the startup project") endif() diff --git a/Tests/RunCMake/VSSolution/solution_parsing.cmake b/Tests/RunCMake/VSSolution/solution_parsing.cmake index 001b584a8..4e5bb5908 100644 --- a/Tests/RunCMake/VSSolution/solution_parsing.cmake +++ b/Tests/RunCMake/VSSolution/solution_parsing.cmake @@ -50,17 +50,18 @@ macro(parseGlobalSections arg_out_pre arg_out_post testName) endmacro() -macro(getFirstProject arg_out_first_project testName) - set(${arg_out_first_project} "") - set(sln "${RunCMake_TEST_BINARY_DIR}/${testName}.sln") +macro(getProjectNames arg_out_projects) + set(${arg_out_projects} "") + set(sln "${RunCMake_TEST_BINARY_DIR}/${test}.sln") if(NOT EXISTS "${sln}") error("Expected solution file ${sln} does not exist") endif() file(STRINGS "${sln}" project_lines REGEX "^Project\\(") - list(GET project_lines 0 first_project) - string(REGEX REPLACE ".* = \"" "" first_project "${first_project}") - string(REGEX REPLACE "\", .*" "" first_project "${first_project}") - set(${arg_out_first_project} "${first_project}") + foreach(project_line IN LISTS project_lines) + string(REGEX REPLACE ".* = \"" "" project_line "${project_line}") + string(REGEX REPLACE "\", .*" "" project_line "${project_line}") + list(APPEND ${arg_out_projects} "${project_line}") + endforeach() endmacro()