VS: Improve unit test macros

Change `getFirstProject` macro to more flexible version
`getProjectNames`
This commit is contained in:
Taylor Braun-Jones 2016-03-21 14:34:34 -04:00 committed by Brad King
parent 78ec046130
commit c05ea48545
3 changed files with 12 additions and 9 deletions

View File

@ -1,4 +1,5 @@
getFirstProject(first_project StartupProject) getProjectNames(projects)
list(GET projects 0 first_project)
if(NOT first_project STREQUAL "TestStartup") if(NOT first_project STREQUAL "TestStartup")
error("TestStartup is not the startup project") error("TestStartup is not the startup project")
endif() endif()

View File

@ -1,4 +1,5 @@
getFirstProject(first_project StartupProjectMissing) getProjectNames(projects)
list(GET projects 0 first_project)
if(NOT first_project STREQUAL "ALL_BUILD") if(NOT first_project STREQUAL "ALL_BUILD")
error("ALL_BUILD is not the startup project") error("ALL_BUILD is not the startup project")
endif() endif()

View File

@ -50,17 +50,18 @@ macro(parseGlobalSections arg_out_pre arg_out_post testName)
endmacro() endmacro()
macro(getFirstProject arg_out_first_project testName) macro(getProjectNames arg_out_projects)
set(${arg_out_first_project} "") set(${arg_out_projects} "")
set(sln "${RunCMake_TEST_BINARY_DIR}/${testName}.sln") set(sln "${RunCMake_TEST_BINARY_DIR}/${test}.sln")
if(NOT EXISTS "${sln}") if(NOT EXISTS "${sln}")
error("Expected solution file ${sln} does not exist") error("Expected solution file ${sln} does not exist")
endif() endif()
file(STRINGS "${sln}" project_lines REGEX "^Project\\(") file(STRINGS "${sln}" project_lines REGEX "^Project\\(")
list(GET project_lines 0 first_project) foreach(project_line IN LISTS project_lines)
string(REGEX REPLACE ".* = \"" "" first_project "${first_project}") string(REGEX REPLACE ".* = \"" "" project_line "${project_line}")
string(REGEX REPLACE "\", .*" "" first_project "${first_project}") string(REGEX REPLACE "\", .*" "" project_line "${project_line}")
set(${arg_out_first_project} "${first_project}") list(APPEND ${arg_out_projects} "${project_line}")
endforeach()
endmacro() endmacro()