diff --git a/lib/CppInterOp/Paths.h b/lib/CppInterOp/Paths.h index 46948ae87..3e9e741ee 100644 --- a/lib/CppInterOp/Paths.h +++ b/lib/CppInterOp/Paths.h @@ -12,6 +12,7 @@ #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" + #include #include diff --git a/unittests/CppInterOp/CMakeLists.txt b/unittests/CppInterOp/CMakeLists.txt index 92ce2fdab..ba34cd1f2 100644 --- a/unittests/CppInterOp/CMakeLists.txt +++ b/unittests/CppInterOp/CMakeLists.txt @@ -21,6 +21,7 @@ add_cppinterop_unittest(CppInterOpTests TypeReflectionTest.cpp Utils.cpp VariableReflectionTest.cpp + PathsTest.cpp ${EXTRA_TEST_SOURCE_FILES} ) diff --git a/unittests/CppInterOp/PathsTest.cpp b/unittests/CppInterOp/PathsTest.cpp new file mode 100644 index 000000000..4b9b79837 --- /dev/null +++ b/unittests/CppInterOp/PathsTest.cpp @@ -0,0 +1,30 @@ +#include "gtest/gtest.h" +#include "CppInterOp/CppInterOp.h" + +#include +#include +#include + +namespace { + +TEST(PathsTest, GetIncludePathsEdgeCases) { + std::vector InterpArgs = { + "-fmodule-cache-path=/tmp/fake_cache", + }; + + Cpp::CreateInterpreter(InterpArgs); + + std::vector IncPaths; + Cpp::GetIncludePaths(IncPaths, true, true); + + auto Contains = [&](const std::string& flag) { + return std::find(IncPaths.begin(), IncPaths.end(), flag) != IncPaths.end(); + }; + + bool hasModuleCache = Contains("-fmodule-cache-path=/tmp/fake_cache") || + (Contains("-fmodule-cache-path") && Contains("/tmp/fake_cache")); + + EXPECT_TRUE(hasModuleCache); +} + +} \ No newline at end of file