Blame SOURCES/clangd-tests.patch

e756a9
diff --git a/clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp b/clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
e756a9
index 0c9455f..22638ee 100644
e756a9
--- a/clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
e756a9
+++ b/clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
e756a9
@@ -451,123 +451,6 @@ TEST_F(TUSchedulerTests, InvalidationUnchanged) {
e756a9
   EXPECT_EQ(1, Actions.load()) << "All actions should run";
e756a9
 }
e756a9
 
e756a9
-TEST_F(TUSchedulerTests, ManyUpdates) {
e756a9
-  const int FilesCount = 3;
e756a9
-  const int UpdatesPerFile = 10;
e756a9
-
e756a9
-  std::mutex Mut;
e756a9
-  int TotalASTReads = 0;
e756a9
-  int TotalPreambleReads = 0;
e756a9
-  int TotalUpdates = 0;
e756a9
-  llvm::StringMap<int> LatestDiagVersion;
e756a9
-
e756a9
-  // Run TUScheduler and collect some stats.
e756a9
-  {
e756a9
-    auto Opts = optsForTest();
e756a9
-    Opts.UpdateDebounce = DebouncePolicy::fixed(std::chrono::milliseconds(50));
e756a9
-    TUScheduler S(CDB, Opts, captureDiags());
e756a9
-
e756a9
-    std::vector<std::string> Files;
e756a9
-    for (int I = 0; I < FilesCount; ++I) {
e756a9
-      std::string Name = "foo" + std::to_string(I) + ".cpp";
e756a9
-      Files.push_back(testPath(Name));
e756a9
-      this->FS.Files[Files.back()] = "";
e756a9
-    }
e756a9
-
e756a9
-    StringRef Contents1 = R"cpp(int a;)cpp";
e756a9
-    StringRef Contents2 = R"cpp(int main() { return 1; })cpp";
e756a9
-    StringRef Contents3 = R"cpp(int a; int b; int sum() { return a + b; })cpp";
e756a9
-
e756a9
-    StringRef AllContents[] = {Contents1, Contents2, Contents3};
e756a9
-    const int AllContentsSize = 3;
e756a9
-
e756a9
-    // Scheduler may run tasks asynchronously, but should propagate the
e756a9
-    // context. We stash a nonce in the context, and verify it in the task.
e756a9
-    static Key<int> NonceKey;
e756a9
-    int Nonce = 0;
e756a9
-
e756a9
-    for (int FileI = 0; FileI < FilesCount; ++FileI) {
e756a9
-      for (int UpdateI = 0; UpdateI < UpdatesPerFile; ++UpdateI) {
e756a9
-        auto Contents = AllContents[(FileI + UpdateI) % AllContentsSize];
e756a9
-
e756a9
-        auto File = Files[FileI];
e756a9
-        auto Inputs = getInputs(File, Contents.str());
e756a9
-        {
e756a9
-          WithContextValue WithNonce(NonceKey, ++Nonce);
e756a9
-          Inputs.Version = std::to_string(UpdateI);
e756a9
-          updateWithDiags(
e756a9
-              S, File, Inputs, WantDiagnostics::Auto,
e756a9
-              [File, Nonce, Version(Inputs.Version), &Mut, &TotalUpdates,
e756a9
-               &LatestDiagVersion](std::vector<Diag>) {
e756a9
-                EXPECT_THAT(Context::current().get(NonceKey), Pointee(Nonce));
e756a9
-                EXPECT_EQ(File, boundPath());
e756a9
-
e756a9
-                std::lock_guard<std::mutex> Lock(Mut);
e756a9
-                ++TotalUpdates;
e756a9
-                EXPECT_EQ(File, *TUScheduler::getFileBeingProcessedInContext());
e756a9
-                // Make sure Diags are for a newer version.
e756a9
-                auto It = LatestDiagVersion.try_emplace(File, -1);
e756a9
-                const int PrevVersion = It.first->second;
e756a9
-                int CurVersion;
e756a9
-                ASSERT_TRUE(llvm::to_integer(Version, CurVersion, 10));
e756a9
-                EXPECT_LT(PrevVersion, CurVersion);
e756a9
-                It.first->getValue() = CurVersion;
e756a9
-              });
e756a9
-        }
e756a9
-        {
e756a9
-          WithContextValue WithNonce(NonceKey, ++Nonce);
e756a9
-          S.runWithAST(
e756a9
-              "CheckAST", File,
e756a9
-              [File, Inputs, Nonce, &Mut,
e756a9
-               &TotalASTReads](Expected<InputsAndAST> AST) {
e756a9
-                EXPECT_THAT(Context::current().get(NonceKey), Pointee(Nonce));
e756a9
-                EXPECT_EQ(File, boundPath());
e756a9
-
e756a9
-                ASSERT_TRUE((bool)AST);
e756a9
-                EXPECT_EQ(AST->Inputs.Contents, Inputs.Contents);
e756a9
-                EXPECT_EQ(AST->Inputs.Version, Inputs.Version);
e756a9
-                EXPECT_EQ(AST->AST.version(), Inputs.Version);
e756a9
-
e756a9
-                std::lock_guard<std::mutex> Lock(Mut);
e756a9
-                ++TotalASTReads;
e756a9
-                EXPECT_EQ(File, *TUScheduler::getFileBeingProcessedInContext());
e756a9
-              });
e756a9
-        }
e756a9
-
e756a9
-        {
e756a9
-          WithContextValue WithNonce(NonceKey, ++Nonce);
e756a9
-          S.runWithPreamble(
e756a9
-              "CheckPreamble", File, TUScheduler::Stale,
e756a9
-              [File, Inputs, Nonce, &Mut,
e756a9
-               &TotalPreambleReads](Expected<InputsAndPreamble> Preamble) {
e756a9
-                EXPECT_THAT(Context::current().get(NonceKey), Pointee(Nonce));
e756a9
-                EXPECT_EQ(File, boundPath());
e756a9
-
e756a9
-                ASSERT_TRUE((bool)Preamble);
e756a9
-                EXPECT_EQ(Preamble->Contents, Inputs.Contents);
e756a9
-
e756a9
-                std::lock_guard<std::mutex> Lock(Mut);
e756a9
-                ++TotalPreambleReads;
e756a9
-                EXPECT_EQ(File, *TUScheduler::getFileBeingProcessedInContext());
e756a9
-              });
e756a9
-        }
e756a9
-      }
e756a9
-    }
e756a9
-    ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(10)));
e756a9
-  } // TUScheduler destructor waits for all operations to finish.
e756a9
-
e756a9
-  std::lock_guard<std::mutex> Lock(Mut);
e756a9
-  // Updates might get coalesced in preamble thread and result in dropping
e756a9
-  // diagnostics for intermediate snapshots.
e756a9
-  EXPECT_GE(TotalUpdates, FilesCount);
e756a9
-  EXPECT_LE(TotalUpdates, FilesCount * UpdatesPerFile);
e756a9
-  // We should receive diags for last update.
e756a9
-  for (const auto &Entry : LatestDiagVersion)
e756a9
-    EXPECT_EQ(Entry.second, UpdatesPerFile - 1);
e756a9
-  EXPECT_EQ(TotalASTReads, FilesCount * UpdatesPerFile);
e756a9
-  EXPECT_EQ(TotalPreambleReads, FilesCount * UpdatesPerFile);
e756a9
-}
e756a9
-
e756a9
 TEST_F(TUSchedulerTests, EvictedAST) {
e756a9
   std::atomic<int> BuiltASTCounter(0);
e756a9
   auto Opts = optsForTest();