Loading clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp +10 −1 Original line number Diff line number Diff line Loading @@ -527,6 +527,13 @@ TEST_F(BackgroundIndexTest, UncompilableFiles) { } } MATCHER_P(HasPrefix, Prefix, "") { auto Arg = arg; // Force copy. if (Arg.size() > Prefix.size()) Arg.resize(Prefix.size()); return Arg == Prefix; } TEST_F(BackgroundIndexTest, CmdLineHash) { MockFSProvider FS; llvm::StringMap<std::string> Storage; Loading @@ -552,7 +559,8 @@ TEST_F(BackgroundIndexTest, CmdLineHash) { { tooling::CompileCommand CmdStored = *MSS.loadShard(testPath("A.cc"))->Cmd; EXPECT_EQ(CmdStored.CommandLine, Cmd.CommandLine); // Accept prefix because -isysroot gets added on mac. EXPECT_THAT(CmdStored.CommandLine, HasPrefix(Cmd.CommandLine)); EXPECT_EQ(CmdStored.Directory, Cmd.Directory); } Loading @@ -566,6 +574,7 @@ TEST_F(BackgroundIndexTest, CmdLineHash) { { tooling::CompileCommand CmdStored = *MSS.loadShard(testPath("A.cc"))->Cmd; EXPECT_THAT(CmdStored.CommandLine, HasPrefix(Cmd.CommandLine)); EXPECT_EQ(CmdStored.CommandLine, Cmd.CommandLine); EXPECT_EQ(CmdStored.Directory, Cmd.Directory); } Loading clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp +16 −7 Original line number Diff line number Diff line Loading @@ -102,12 +102,20 @@ TEST_F(OverlayCDBTest, GetCompileCommand) { Contains("-DA=3")); } // Remove -isysroot injected on mac, if present, to simplify tests. std::vector<std::string> stripSysroot(std::vector<std::string> Cmd) { // Allow -isysroot injection on Mac. if (Cmd.size() > 2 && Cmd[Cmd.size() - 2] == "-isysroot") Cmd.resize(Cmd.size() - 2); return Cmd; } TEST_F(OverlayCDBTest, GetFallbackCommand) { OverlayCDB CDB(Base.get(), {"-DA=4"}); EXPECT_THAT(CDB.getFallbackCommand(testPath("bar.cc")).CommandLine, ElementsAre(EndsWith("clang"), "-DA=2", testPath("bar.cc"), "-DA=4", "-fsyntax-only", StartsWith("-resource-dir"))); EXPECT_THAT( stripSysroot(CDB.getFallbackCommand(testPath("bar.cc")).CommandLine), ElementsAre(EndsWith("clang"), "-DA=2", testPath("bar.cc"), "-DA=4", "-fsyntax-only", StartsWith("-resource-dir"))); } TEST_F(OverlayCDBTest, NoBase) { Loading @@ -118,7 +126,8 @@ TEST_F(OverlayCDBTest, NoBase) { EXPECT_THAT(CDB.getCompileCommand(testPath("bar.cc"))->CommandLine, Contains("-DA=5")); EXPECT_THAT(CDB.getFallbackCommand(testPath("foo.cc")).CommandLine, EXPECT_THAT( stripSysroot(CDB.getFallbackCommand(testPath("foo.cc")).CommandLine), ElementsAre(EndsWith("clang"), testPath("foo.cc"), "-DA=6", "-fsyntax-only")); } Loading Loading
clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp +10 −1 Original line number Diff line number Diff line Loading @@ -527,6 +527,13 @@ TEST_F(BackgroundIndexTest, UncompilableFiles) { } } MATCHER_P(HasPrefix, Prefix, "") { auto Arg = arg; // Force copy. if (Arg.size() > Prefix.size()) Arg.resize(Prefix.size()); return Arg == Prefix; } TEST_F(BackgroundIndexTest, CmdLineHash) { MockFSProvider FS; llvm::StringMap<std::string> Storage; Loading @@ -552,7 +559,8 @@ TEST_F(BackgroundIndexTest, CmdLineHash) { { tooling::CompileCommand CmdStored = *MSS.loadShard(testPath("A.cc"))->Cmd; EXPECT_EQ(CmdStored.CommandLine, Cmd.CommandLine); // Accept prefix because -isysroot gets added on mac. EXPECT_THAT(CmdStored.CommandLine, HasPrefix(Cmd.CommandLine)); EXPECT_EQ(CmdStored.Directory, Cmd.Directory); } Loading @@ -566,6 +574,7 @@ TEST_F(BackgroundIndexTest, CmdLineHash) { { tooling::CompileCommand CmdStored = *MSS.loadShard(testPath("A.cc"))->Cmd; EXPECT_THAT(CmdStored.CommandLine, HasPrefix(Cmd.CommandLine)); EXPECT_EQ(CmdStored.CommandLine, Cmd.CommandLine); EXPECT_EQ(CmdStored.Directory, Cmd.Directory); } Loading
clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp +16 −7 Original line number Diff line number Diff line Loading @@ -102,12 +102,20 @@ TEST_F(OverlayCDBTest, GetCompileCommand) { Contains("-DA=3")); } // Remove -isysroot injected on mac, if present, to simplify tests. std::vector<std::string> stripSysroot(std::vector<std::string> Cmd) { // Allow -isysroot injection on Mac. if (Cmd.size() > 2 && Cmd[Cmd.size() - 2] == "-isysroot") Cmd.resize(Cmd.size() - 2); return Cmd; } TEST_F(OverlayCDBTest, GetFallbackCommand) { OverlayCDB CDB(Base.get(), {"-DA=4"}); EXPECT_THAT(CDB.getFallbackCommand(testPath("bar.cc")).CommandLine, ElementsAre(EndsWith("clang"), "-DA=2", testPath("bar.cc"), "-DA=4", "-fsyntax-only", StartsWith("-resource-dir"))); EXPECT_THAT( stripSysroot(CDB.getFallbackCommand(testPath("bar.cc")).CommandLine), ElementsAre(EndsWith("clang"), "-DA=2", testPath("bar.cc"), "-DA=4", "-fsyntax-only", StartsWith("-resource-dir"))); } TEST_F(OverlayCDBTest, NoBase) { Loading @@ -118,7 +126,8 @@ TEST_F(OverlayCDBTest, NoBase) { EXPECT_THAT(CDB.getCompileCommand(testPath("bar.cc"))->CommandLine, Contains("-DA=5")); EXPECT_THAT(CDB.getFallbackCommand(testPath("foo.cc")).CommandLine, EXPECT_THAT( stripSysroot(CDB.getFallbackCommand(testPath("foo.cc")).CommandLine), ElementsAre(EndsWith("clang"), testPath("foo.cc"), "-DA=6", "-fsyntax-only")); } Loading