[clangd] Fix data race in BackgroundIndex test
MockFSProvider is not thread-safe. Make sure we don't modify it while background index is working.
This commit is contained in:
parent
b05c8c5756
commit
c746781f50
|
|
@ -443,6 +443,7 @@ TEST_F(BackgroundIndexTest, NoDotsInAbsPath) {
|
||||||
OverlayCDB CDB(/*Base=*/nullptr);
|
OverlayCDB CDB(/*Base=*/nullptr);
|
||||||
BackgroundIndex Idx(Context::empty(), FS, CDB,
|
BackgroundIndex Idx(Context::empty(), FS, CDB,
|
||||||
[&](llvm::StringRef) { return &MSS; });
|
[&](llvm::StringRef) { return &MSS; });
|
||||||
|
ASSERT_TRUE(Idx.blockUntilIdleForTest());
|
||||||
|
|
||||||
tooling::CompileCommand Cmd;
|
tooling::CompileCommand Cmd;
|
||||||
FS.Files[testPath("root/A.cc")] = "";
|
FS.Files[testPath("root/A.cc")] = "";
|
||||||
|
|
@ -450,14 +451,15 @@ TEST_F(BackgroundIndexTest, NoDotsInAbsPath) {
|
||||||
Cmd.Directory = testPath("root/build");
|
Cmd.Directory = testPath("root/build");
|
||||||
Cmd.CommandLine = {"clang++", "../A.cc"};
|
Cmd.CommandLine = {"clang++", "../A.cc"};
|
||||||
CDB.setCompileCommand(testPath("root/build/../A.cc"), Cmd);
|
CDB.setCompileCommand(testPath("root/build/../A.cc"), Cmd);
|
||||||
|
ASSERT_TRUE(Idx.blockUntilIdleForTest());
|
||||||
|
|
||||||
FS.Files[testPath("root/B.cc")] = "";
|
FS.Files[testPath("root/B.cc")] = "";
|
||||||
Cmd.Filename = "./B.cc";
|
Cmd.Filename = "./B.cc";
|
||||||
Cmd.Directory = testPath("root");
|
Cmd.Directory = testPath("root");
|
||||||
Cmd.CommandLine = {"clang++", "./B.cc"};
|
Cmd.CommandLine = {"clang++", "./B.cc"};
|
||||||
CDB.setCompileCommand(testPath("root/./B.cc"), Cmd);
|
CDB.setCompileCommand(testPath("root/./B.cc"), Cmd);
|
||||||
|
|
||||||
ASSERT_TRUE(Idx.blockUntilIdleForTest());
|
ASSERT_TRUE(Idx.blockUntilIdleForTest());
|
||||||
|
|
||||||
for (llvm::StringRef AbsPath : MSS.AccessedPaths.keys()) {
|
for (llvm::StringRef AbsPath : MSS.AccessedPaths.keys()) {
|
||||||
EXPECT_FALSE(AbsPath.contains("./")) << AbsPath;
|
EXPECT_FALSE(AbsPath.contains("./")) << AbsPath;
|
||||||
EXPECT_FALSE(AbsPath.contains("../")) << AbsPath;
|
EXPECT_FALSE(AbsPath.contains("../")) << AbsPath;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue