Pass the include dir for c++utilities and RapidJSON to tests

So test cases do not fail if the header files for those
dependencies are installed in a custom location.
This commit is contained in:
Martchus 2017-11-17 22:01:18 +01:00
parent 227d3f3942
commit 8c3dd5535d
2 changed files with 11 additions and 2 deletions

View File

@ -72,4 +72,13 @@ add_reflection_generator_invocation(
include(TestTarget)
include(ShellCompletion)
include(Doxygen)
# add paths for include dirs of c++utilities and RapidJSON to config header so test cases can use it
set(META_CUSTOM_CONFIG "#define CPP_UTILITIES_INCLUDE_DIRS \"${CPP_UTILITIES_INCLUDE_DIRS}\"\n")
if(RapidJSON_FOUND)
string(APPEND META_CUSTOM_CONFIG "#define RAPIDJSON_INCLUDE_DIRS \"${RAPIDJSON_INCLUDE_DIRS}\"\n")
endif()
# make config header
include(ConfigHeader)

View File

@ -65,7 +65,7 @@ void JsonGeneratorTests::testGeneratorItself()
{
const string inputFilePath(testFilePath("some_structs.h"));
const vector<const char *> inputFiles{ inputFilePath.data() };
const vector<const char *> clangOptions{};
const vector<string> clangOptions{"-I" CPP_UTILITIES_INCLUDE_DIRS, "-I" RAPIDJSON_INCLUDE_DIRS};
stringstream buffer;
JsonSerializationCodeGenerator::Options jsonOptions;
@ -88,7 +88,7 @@ void JsonGeneratorTests::testCLI()
string stdout, stderr;
const string inputFilePath(testFilePath("some_structs.h"));
const char *const args1[] = { PROJECT_NAME, "-i", inputFilePath.data(), "--json-classes", "TestNamespace2::ThirdPartyStruct", nullptr };
const char *const args1[] = { PROJECT_NAME, "-i", inputFilePath.data(), "--json-classes", "TestNamespace2::ThirdPartyStruct", "--clang-opt", "-I" CPP_UTILITIES_INCLUDE_DIRS, "-I" RAPIDJSON_INCLUDE_DIRS, nullptr };
TESTUTILS_ASSERT_EXEC(args1);
assertEqualityLinewise(m_expectedCode, toArrayOfLines(stdout));
#endif