Skip to content

Commit

Permalink
[clangd] Fix data race in BackgroundIndex test
Browse files Browse the repository at this point in the history
MockFSProvider is not thread-safe. Make sure we don't modify it while
background index is working.
  • Loading branch information
kadircet committed May 9, 2020
1 parent b05c8c5 commit c746781
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
Expand Up @@ -443,21 +443,23 @@ TEST_F(BackgroundIndexTest, NoDotsInAbsPath) {
OverlayCDB CDB(/*Base=*/nullptr);
BackgroundIndex Idx(Context::empty(), FS, CDB,
[&](llvm::StringRef) { return &MSS; });
ASSERT_TRUE(Idx.blockUntilIdleForTest());

tooling::CompileCommand Cmd;
FS.Files[testPath("root/A.cc")] = "";
Cmd.Filename = "../A.cc";
Cmd.Directory = testPath("root/build");
Cmd.CommandLine = {"clang++", "../A.cc"};
CDB.setCompileCommand(testPath("root/build/../A.cc"), Cmd);
ASSERT_TRUE(Idx.blockUntilIdleForTest());

FS.Files[testPath("root/B.cc")] = "";
Cmd.Filename = "./B.cc";
Cmd.Directory = testPath("root");
Cmd.CommandLine = {"clang++", "./B.cc"};
CDB.setCompileCommand(testPath("root/./B.cc"), Cmd);

ASSERT_TRUE(Idx.blockUntilIdleForTest());

for (llvm::StringRef AbsPath : MSS.AccessedPaths.keys()) {
EXPECT_FALSE(AbsPath.contains("./")) << AbsPath;
EXPECT_FALSE(AbsPath.contains("../")) << AbsPath;
Expand Down

0 comments on commit c746781

Please sign in to comment.