Skip to content
This repository has been archived by the owner on Jan 6, 2020. It is now read-only.

Commit

Permalink
Merge branch 'next' into MAID-846
Browse files Browse the repository at this point in the history
  • Loading branch information
Fraser Hutchison committed Mar 12, 2015
2 parents 5a41536 + f9f0e9f commit c1c7650
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 91 deletions.
52 changes: 34 additions & 18 deletions cmake_modules/add_gtests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -139,22 +139,38 @@ macro(get_network_test_arg)
endmacro()


# Gets all type values from all "typedef testing::Types<type, type, ...> varname" statements.
# For each varname, a variable named "varname_VAR" is set in parent_scope which contains all
# the types specified in the template parameters.
# Gets all type values from all "typedef testing::Types<type, type, ...> varname;" statements and
# "using varname = testing::Types<type, type, ...>;" statements. For each varname, a variable named
# "varname_VAR" is set in parent_scope which contains all the types specified in the template parameters.
function(get_gtest_typedef_types FileContents)
string(REGEX MATCHALL "testing::Types[.\n]*[^;]*" Typedefs "${FileContents}")
if(NOT Typedefs)
# Get all instances of "using var = testing::Types<...>" or "typedef testing::Types<...>"
string(REGEX MATCHALL "(using[ \t\n]+([^ \t\n]+)[ \t\n]*=[ \t\n]*|typedef[ \t\n]+)(::)?testing::Types[^;]*" Aliases "${FileContents}")
if(NOT Aliases)
return()
endif()
foreach(Typedef ${Typedefs})
string(REGEX REPLACE "testing::Types<+" "" Typedef ${Typedef})
string(REGEX REPLACE "\n" "" Typedef ${Typedef})
string(REGEX MATCH ">.*" TypedefName ${Typedef})
string(REGEX REPLACE ${TypedefName} "" Typedef ${Typedef})
string(REGEX REPLACE ["\ >"] "" TypedefName ${TypedefName})
string(REGEX REPLACE ,["\ "]* ";" Typedef ${Typedef})
set(${TypedefName}Var ${Typedef} PARENT_SCOPE)
foreach(Alias ${Aliases})
# Fourth matched part will be the list of types. The alias' name will be the second match for
# "using" syntax or the fifth for "typedef" syntax.
string(REGEX MATCH "(using[ \t\n]+([^ \t\n]+)[ \t\n]*=[ \t\n]*|typedef[ \t\n]+)(::)?testing::Types[ \t\n]*<(.*)>[ \t\n]*([^;]*)" UnusedVar "${Alias}")
set(UsingOrTypedef "${CMAKE_MATCH_1}")
set(NameIfUsing "${CMAKE_MATCH_2}")
set(NameIfTypedef "${CMAKE_MATCH_5}")
set(Types "${CMAKE_MATCH_4}")
if(UsingOrTypedef MATCHES "using")
set(AliasName "${NameIfUsing}")
elseif(UsingOrTypedef MATCHES "typedef")
set(AliasName "${NameIfTypedef}")
else()
message(AUTHOR_WARNING "Unexpected parsing failure of gtest aliases.")
return()
endif()
# We don't need to know the actual types, we ultimately only need a count. Remove all commas except
# those separating the list of types (there could be some inside a type's template args, e.g.
# std::pair<int, int> should count as one variable, not two.) Also remove whitespace.
string(REGEX REPLACE "<[^>]*>|[ \t\n]" "" Types "${Types}")
# Turn the comma-separated list into a CMake list
string(REGEX REPLACE "," ";" Types "${Types}")
set(${AliasName}Var ${Types} PARENT_SCOPE)
endforeach()
endfunction()

Expand All @@ -175,9 +191,9 @@ function(get_gtest_fixtures_types FileContents)
string(REGEX REPLACE "[\n\ ]" "" TestType ${TestType})
string(REGEX MATCH "[^,]+" GtestFixtureName ${TestType})
string(REGEX REPLACE "${GtestFixtureName}," "" TestType ${TestType})
string(REGEX REPLACE "[\)]" "" TypedefName ${TestType})
string(REGEX REPLACE "[\)]" "" AliasName ${TestType})
set(ParamaterCount 0)
foreach(TYPE ${${TypedefName}Var})
foreach(Type ${${AliasName}Var})
set(${GtestFixtureName}Types ${${GtestFixtureName}Types} "${GtestFixtureName}/${ParamaterCount}.@@@@@")
math(EXPR ParamaterCount ${ParamaterCount}+1)
endforeach()
Expand Down Expand Up @@ -263,13 +279,13 @@ function(get_gtest_fixtures_type_parameters FileContents)
string(REGEX MATCH "[^,]+" GtestFixtureName ${Instantiation})
set(PartialTestName ${PartialTestName}/${GtestFixtureName})
string(REGEX REPLACE "${GtestFixtureName}," "" Instantiation ${Instantiation})
string(REGEX REPLACE "[\)]" "" TypedefName ${Instantiation})
string(REGEX REPLACE "[\)]" "" AliasName ${Instantiation})
# The 3rd parameter of INSTANTIATE_TYPED_TEST_CASE_P can be either a single type to be run, or a typedef
# of a testing::Types with several types to be run. If we can't find a parsed typedef to match we'll
# assume it's a single type.
if(DEFINED ${TypedefName}Var)
if(DEFINED ${AliasName}Var)
set(ParamaterCount 0)
foreach(TYPE ${${TypedefName}Var})
foreach(Type ${${AliasName}Var})
set(${GtestFixtureName}TypeParameters ${${GtestFixtureName}TypeParameters} ${PartialTestName}/${ParamaterCount}.@@@@@)
math(EXPR ParamaterCount ${ParamaterCount}+1)
endforeach()
Expand Down
1 change: 0 additions & 1 deletion cmake_modules/headers_helper.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,5 @@ file(COPY ${CryptoHeaders} DESTINATION "@MonolithicIncludes@/cryptopp")
file(COPY "@CMAKE_SOURCE_DIR@/src/third_party_libs/header_only/asio.hpp" DESTINATION "@MonolithicIncludes@")
file(COPY "@CMAKE_SOURCE_DIR@/src/third_party_libs/header_only/asio" DESTINATION "@MonolithicIncludes@")
file(COPY "@CMAKE_SOURCE_DIR@/src/third_party_libs/header_only/cereal" DESTINATION "@MonolithicIncludes@")
file(COPY "@CMAKE_SOURCE_DIR@/src/third_party_libs/header_only/eggs" DESTINATION "@MonolithicIncludes@")
file(COPY "@CMAKE_SOURCE_DIR@/src/third_party_libs/sqlite/include/sqlite3.h" DESTINATION "@MonolithicIncludes@/sqlite")
#file(COPY "@MaidsafeGeneratedSourcesDir@/nfs/include/maidsafe" DESTINATION "@MonolithicIncludes@")
72 changes: 0 additions & 72 deletions src/third_party_libs/header_only/eggs/variant/nullvariant.hpp

This file was deleted.

0 comments on commit c1c7650

Please sign in to comment.