[clang-tools-extra] 4891ef2 - Revert "[test][clangd] Try to unbrake bots after 72142fbac4"

Vitaly Buka via cfe-commits cfe-commits at lists.llvm.org
Sun Sep 11 10:07:42 PDT 2022


Author: Vitaly Buka
Date: 2022-09-11T10:07:26-07:00
New Revision: 4891ef23a0acfa0bad244ee89b8d9511a4187a84

URL: https://github.com/llvm/llvm-project/commit/4891ef23a0acfa0bad244ee89b8d9511a4187a84
DIFF: https://github.com/llvm/llvm-project/commit/4891ef23a0acfa0bad244ee89b8d9511a4187a84.diff

LOG: Revert "[test][clangd] Try to unbrake bots after 72142fbac4"

It does not help.

This reverts commit 355dbd3b2aa28d479170c4e43265de186317dd86.

Added: 
    

Modified: 
    clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp b/clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
index 66260ab64fbe6..4e95fcfea91c1 100644
--- a/clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
+++ b/clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
@@ -169,7 +169,6 @@ class TUSchedulerTests : public ::testing::Test {
 
   MockFS FS;
   MockCompilationDatabase CDB;
-  Deadline BlockTimeout = timeoutSeconds(60);
 };
 
 Key<llvm::unique_function<void(PathRef File, std::vector<Diag>)>>
@@ -242,7 +241,7 @@ TEST_F(TUSchedulerTests, WantDiagnostics) {
                     [&](std::vector<Diag>) { ++CallbackCount; });
     Ready.notify();
 
-    ASSERT_TRUE(S.blockUntilIdle(BlockTimeout));
+    ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(10)));
   }
   EXPECT_EQ(2, CallbackCount);
 }
@@ -265,7 +264,7 @@ TEST_F(TUSchedulerTests, Debounce) {
   Notification N;
   updateWithDiags(S, Path, "auto (timed out)", WantDiagnostics::Auto,
                   [&](std::vector<Diag>) { N.notify(); });
-  EXPECT_TRUE(N.wait(BlockTimeout));
+  EXPECT_TRUE(N.wait(timeoutSeconds(5)));
 
   // Once we start shutting down the TUScheduler, this one becomes a dead write.
   updateWithDiags(S, Path, "auto (discarded)", WantDiagnostics::Auto,
@@ -331,7 +330,7 @@ TEST_F(TUSchedulerTests, Cancellation) {
     Read("R3")();
     Proceed.notify();
 
-    ASSERT_TRUE(S.blockUntilIdle(BlockTimeout));
+    ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(10)));
   }
   EXPECT_THAT(DiagsSeen, ElementsAre("U2", "U3"))
       << "U1 and all dependent reads were cancelled. "
@@ -352,7 +351,7 @@ TEST_F(TUSchedulerTests, InvalidationNoCrash) {
   // We expect invalidation logic to not crash by trying to invalidate a running
   // request.
   S.update(Path, getInputs(Path, ""), WantDiagnostics::Auto);
-  ASSERT_TRUE(S.blockUntilIdle(BlockTimeout));
+  ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(10)));
   S.runWithAST(
       "invalidatable-but-running", Path,
       [&](llvm::Expected<InputsAndAST> AST) {
@@ -364,7 +363,7 @@ TEST_F(TUSchedulerTests, InvalidationNoCrash) {
   StartedRunning.wait();
   S.update(Path, getInputs(Path, ""), WantDiagnostics::Auto);
   ScheduledChange.notify();
-  ASSERT_TRUE(S.blockUntilIdle(BlockTimeout));
+  ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(10)));
 }
 
 TEST_F(TUSchedulerTests, Invalidation) {
@@ -420,7 +419,7 @@ TEST_F(TUSchedulerTests, Invalidation) {
       },
       TUScheduler::InvalidateOnUpdate);
   Start.notify();
-  ASSERT_TRUE(S.blockUntilIdle(BlockTimeout));
+  ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(10)));
 
   EXPECT_EQ(2, Builds.load()) << "Middle build should be skipped";
   EXPECT_EQ(4, Actions.load()) << "All actions should run (some with error)";
@@ -453,7 +452,7 @@ TEST_F(TUSchedulerTests, InvalidationUnchanged) {
     ADD_FAILURE() << "Shouldn't build, identical to previous";
   });
   Start.notify();
-  ASSERT_TRUE(S.blockUntilIdle(BlockTimeout));
+  ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(10)));
 
   EXPECT_EQ(1, Actions.load()) << "All actions should run";
 }
@@ -560,7 +559,7 @@ TEST_F(TUSchedulerTests, ManyUpdates) {
         }
       }
     }
-    ASSERT_TRUE(S.blockUntilIdle(BlockTimeout));
+    ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(10)));
   } // TUScheduler destructor waits for all operations to finish.
 
   std::lock_guard<std::mutex> Lock(Mut);
@@ -602,7 +601,7 @@ TEST_F(TUSchedulerTests, EvictedAST) {
   // one that the cache will evict.
   updateWithCallback(S, Foo, SourceContents, WantDiagnostics::Yes,
                      [&BuiltASTCounter]() { ++BuiltASTCounter; });
-  ASSERT_TRUE(S.blockUntilIdle(BlockTimeout));
+  ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(10)));
   ASSERT_EQ(BuiltASTCounter.load(), 1);
   EXPECT_THAT(Tracer.takeMetric("ast_access_diag", "hit"), SizeIs(0));
   EXPECT_THAT(Tracer.takeMetric("ast_access_diag", "miss"), SizeIs(1));
@@ -613,7 +612,7 @@ TEST_F(TUSchedulerTests, EvictedAST) {
                      [&BuiltASTCounter]() { ++BuiltASTCounter; });
   updateWithCallback(S, Baz, SourceContents, WantDiagnostics::Yes,
                      [&BuiltASTCounter]() { ++BuiltASTCounter; });
-  ASSERT_TRUE(S.blockUntilIdle(BlockTimeout));
+  ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(10)));
   ASSERT_EQ(BuiltASTCounter.load(), 3);
   EXPECT_THAT(Tracer.takeMetric("ast_access_diag", "hit"), SizeIs(0));
   EXPECT_THAT(Tracer.takeMetric("ast_access_diag", "miss"), SizeIs(2));
@@ -624,7 +623,7 @@ TEST_F(TUSchedulerTests, EvictedAST) {
   // Access the old file again.
   updateWithCallback(S, Foo, OtherSourceContents, WantDiagnostics::Yes,
                      [&BuiltASTCounter]() { ++BuiltASTCounter; });
-  ASSERT_TRUE(S.blockUntilIdle(BlockTimeout));
+  ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(10)));
   ASSERT_EQ(BuiltASTCounter.load(), 4);
   EXPECT_THAT(Tracer.takeMetric("ast_access_diag", "hit"), SizeIs(0));
   EXPECT_THAT(Tracer.takeMetric("ast_access_diag", "miss"), SizeIs(1));
@@ -650,16 +649,16 @@ TEST_F(TUSchedulerTests, NoopChangesDontThrashCache) {
 
   // After opening Foo then Bar, AST cache contains Bar.
   S.update(Foo, FooInputs, WantDiagnostics::Auto);
-  ASSERT_TRUE(S.blockUntilIdle(BlockTimeout));
+  ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(10)));
   S.update(Bar, BarInputs, WantDiagnostics::Auto);
-  ASSERT_TRUE(S.blockUntilIdle(BlockTimeout));
+  ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(10)));
   ASSERT_THAT(S.getFilesWithCachedAST(), ElementsAre(Bar));
 
   // Any number of no-op updates to Foo don't dislodge Bar from the cache.
   S.update(Foo, FooInputs, WantDiagnostics::Auto);
   S.update(Foo, FooInputs, WantDiagnostics::Auto);
   S.update(Foo, FooInputs, WantDiagnostics::Auto);
-  ASSERT_TRUE(S.blockUntilIdle(BlockTimeout));
+  ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(10)));
   ASSERT_THAT(S.getFilesWithCachedAST(), ElementsAre(Bar));
   // In fact each file has been built only once.
   ASSERT_EQ(S.fileStats().lookup(Foo).ASTBuilds, 1u);
@@ -689,12 +688,12 @@ TEST_F(TUSchedulerTests, EmptyPreamble) {
             0u);
       });
   // Wait while the preamble is being built.
-  ASSERT_TRUE(S.blockUntilIdle(BlockTimeout));
+  ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(10)));
 
   // Update the file which results in an empty preamble.
   S.update(Foo, getInputs(Foo, WithEmptyPreamble), WantDiagnostics::Auto);
   // Wait while the preamble is being built.
-  ASSERT_TRUE(S.blockUntilIdle(BlockTimeout));
+  ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(10)));
   S.runWithPreamble(
       "getEmptyPreamble", Foo, TUScheduler::Stale,
       [&](Expected<InputsAndPreamble> Preamble) {
@@ -722,7 +721,7 @@ TEST_F(TUSchedulerTests, ASTSignalsSmokeTests) {
   // Update the file which results in an empty preamble.
   S.update(Foo, getInputs(Foo, Contents), WantDiagnostics::Yes);
   // Wait while the preamble is being built.
-  ASSERT_TRUE(S.blockUntilIdle(BlockTimeout));
+  ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(10)));
   Notification TaskRun;
   S.runWithPreamble(
       "ASTSignals", Foo, TUScheduler::Stale,
@@ -769,7 +768,7 @@ TEST_F(TUSchedulerTests, RunWaitsForPreamble) {
           Preambles[I] = cantFail(std::move(IP)).Preamble;
         });
   }
-  ASSERT_TRUE(S.blockUntilIdle(BlockTimeout));
+  ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(10)));
   // Check all actions got the same non-null preamble.
   std::lock_guard<std::mutex> Lock(PreamblesMut);
   ASSERT_NE(Preambles[0], nullptr);
@@ -796,7 +795,7 @@ TEST_F(TUSchedulerTests, NoopOnEmptyChanges) {
     Updated = false;
     updateWithDiags(S, Source, Contents, WantDiagnostics::Yes,
                     [&Updated](std::vector<Diag>) { Updated = true; });
-    bool UpdateFinished = S.blockUntilIdle(BlockTimeout);
+    bool UpdateFinished = S.blockUntilIdle(timeoutSeconds(10));
     if (!UpdateFinished)
       ADD_FAILURE() << "Updated has not finished in one second. Threading bug?";
     return Updated;
@@ -866,7 +865,7 @@ TEST_F(TUSchedulerTests, MissingHeader) {
                                 Field(&Diag::Message,
                                       "use of undeclared identifier 'b'")));
       });
-  S.blockUntilIdle(BlockTimeout);
+  S.blockUntilIdle(timeoutSeconds(10));
 
   FS.Files[HeaderB] = "int b;";
   FS.Timestamps[HeaderB] = time_t(1);
@@ -879,7 +878,7 @@ TEST_F(TUSchedulerTests, MissingHeader) {
                   });
 
   // Ensure previous assertions are done before we touch the FS again.
-  ASSERT_TRUE(S.blockUntilIdle(BlockTimeout));
+  ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(10)));
   // Add the high-priority header file, which should reintroduce the error.
   FS.Files[HeaderA] = "int a;";
   FS.Timestamps[HeaderA] = time_t(1);
@@ -901,7 +900,7 @@ TEST_F(TUSchedulerTests, MissingHeader) {
         ElementsAre(Field(&Diag::Message, "use of undeclared identifier 'b'"));
       });
 
-  ASSERT_TRUE(S.blockUntilIdle(BlockTimeout));
+  ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(10)));
   EXPECT_EQ(DiagCount, 3U);
 }
 
@@ -923,7 +922,7 @@ TEST_F(TUSchedulerTests, NoChangeDiags) {
     // Make sure the AST was actually built.
     cantFail(std::move(IA));
   });
-  ASSERT_TRUE(S.blockUntilIdle(BlockTimeout));
+  ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(10)));
   EXPECT_THAT(Tracer.takeMetric("ast_access_read", "hit"), SizeIs(0));
   EXPECT_THAT(Tracer.takeMetric("ast_access_read", "miss"), SizeIs(1));
 
@@ -932,7 +931,7 @@ TEST_F(TUSchedulerTests, NoChangeDiags) {
   std::atomic<bool> SeenDiags(false);
   updateWithDiags(S, FooCpp, Contents, WantDiagnostics::Auto,
                   [&](std::vector<Diag>) { SeenDiags = true; });
-  ASSERT_TRUE(S.blockUntilIdle(BlockTimeout));
+  ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(10)));
   ASSERT_TRUE(SeenDiags);
   EXPECT_THAT(Tracer.takeMetric("ast_access_diag", "hit"), SizeIs(1));
   EXPECT_THAT(Tracer.takeMetric("ast_access_diag", "miss"), SizeIs(0));
@@ -942,7 +941,7 @@ TEST_F(TUSchedulerTests, NoChangeDiags) {
   updateWithDiags(
       S, FooCpp, Contents, WantDiagnostics::Auto,
       [&](std::vector<Diag>) { ADD_FAILURE() << "Should not be called."; });
-  ASSERT_TRUE(S.blockUntilIdle(BlockTimeout));
+  ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(10)));
 }
 
 TEST_F(TUSchedulerTests, Run) {
@@ -954,7 +953,7 @@ TEST_F(TUSchedulerTests, Run) {
     std::atomic<int> Counter(0);
     S.run("add 1", /*Path=*/"", [&] { ++Counter; });
     S.run("add 2", /*Path=*/"", [&] { Counter += 2; });
-    ASSERT_TRUE(S.blockUntilIdle(BlockTimeout));
+    ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(10)));
     EXPECT_EQ(Counter.load(), 3);
 
     Notification TaskRun;
@@ -1146,7 +1145,7 @@ TEST_F(TUSchedulerTests, AsyncPreambleThread) {
   auto PI = getInputs(File, "");
   PI.Version = InputsV0.str();
   S.update(File, PI, WantDiagnostics::Auto);
-  S.blockUntilIdle(BlockTimeout);
+  S.blockUntilIdle(timeoutSeconds(10));
 
   // Block preamble builds.
   PI.Version = InputsV1.str();
@@ -1182,15 +1181,15 @@ TEST_F(TUSchedulerTests, OnlyPublishWhenPreambleIsBuilt) {
 
   Path File = testPath("foo.cpp");
   S.update(File, getInputs(File, ""), WantDiagnostics::Auto);
-  S.blockUntilIdle(BlockTimeout);
+  S.blockUntilIdle(timeoutSeconds(10));
   EXPECT_EQ(PreamblePublishCount, 1);
   // Same contents, no publish.
   S.update(File, getInputs(File, ""), WantDiagnostics::Auto);
-  S.blockUntilIdle(BlockTimeout);
+  S.blockUntilIdle(timeoutSeconds(10));
   EXPECT_EQ(PreamblePublishCount, 1);
   // New contents, should publish.
   S.update(File, getInputs(File, "#define FOO"), WantDiagnostics::Auto);
-  S.blockUntilIdle(BlockTimeout);
+  S.blockUntilIdle(timeoutSeconds(10));
   EXPECT_EQ(PreamblePublishCount, 2);
 }
 
@@ -1227,14 +1226,14 @@ TEST_F(TUSchedulerTests, IncluderCache) {
   TUScheduler S(CDB, optsForTest());
   auto GetFlags = [&](PathRef Header) {
     S.update(Header, getInputs(Header, ";"), WantDiagnostics::Yes);
-    EXPECT_TRUE(S.blockUntilIdle(BlockTimeout));
+    EXPECT_TRUE(S.blockUntilIdle(timeoutSeconds(10)));
     tooling::CompileCommand Cmd;
     S.runWithPreamble("GetFlags", Header, TUScheduler::StaleOrAbsent,
                       [&](llvm::Expected<InputsAndPreamble> Inputs) {
                         ASSERT_FALSE(!Inputs) << Inputs.takeError();
                         Cmd = std::move(Inputs->Command);
                       });
-    EXPECT_TRUE(S.blockUntilIdle(BlockTimeout));
+    EXPECT_TRUE(S.blockUntilIdle(timeoutSeconds(10)));
     return Cmd.CommandLine;
   };
 
@@ -1252,7 +1251,7 @@ TEST_F(TUSchedulerTests, IncluderCache) {
     #include "unreliable.h"
   )cpp";
   S.update(Main, getInputs(Main, AllIncludes), WantDiagnostics::Yes);
-  EXPECT_TRUE(S.blockUntilIdle(BlockTimeout));
+  EXPECT_TRUE(S.blockUntilIdle(timeoutSeconds(10)));
   EXPECT_THAT(GetFlags(NoCmd), Contains("-DMAIN"))
       << "Included from main file, has no own command";
   EXPECT_THAT(GetFlags(Unreliable), Contains("-DMAIN"))
@@ -1268,7 +1267,7 @@ TEST_F(TUSchedulerTests, IncluderCache) {
     #include "not_included.h"
   )cpp";
   S.update(Main2, getInputs(Main2, SomeIncludes), WantDiagnostics::Yes);
-  EXPECT_TRUE(S.blockUntilIdle(BlockTimeout));
+  EXPECT_TRUE(S.blockUntilIdle(timeoutSeconds(10)));
   EXPECT_THAT(GetFlags(NoCmd),
               AllOf(Contains("-DMAIN"), Not(Contains("-DMAIN2"))))
       << "mainfile association is stable";
@@ -1279,14 +1278,14 @@ TEST_F(TUSchedulerTests, IncluderCache) {
   // Remove includes from main - this marks the associations as invalid but
   // doesn't actually remove them until another preamble claims them.
   S.update(Main, getInputs(Main, ""), WantDiagnostics::Yes);
-  EXPECT_TRUE(S.blockUntilIdle(BlockTimeout));
+  EXPECT_TRUE(S.blockUntilIdle(timeoutSeconds(10)));
   EXPECT_THAT(GetFlags(NoCmd),
               AllOf(Contains("-DMAIN"), Not(Contains("-DMAIN2"))))
       << "mainfile association not updated yet!";
 
   // Open yet another file - this time it claims the associations.
   S.update(Main3, getInputs(Main3, SomeIncludes), WantDiagnostics::Yes);
-  EXPECT_TRUE(S.blockUntilIdle(BlockTimeout));
+  EXPECT_TRUE(S.blockUntilIdle(timeoutSeconds(10)));
   EXPECT_THAT(GetFlags(NoCmd), Contains("-DMAIN3"))
       << "association invalidated and then claimed by main3";
   EXPECT_THAT(GetFlags(Unreliable), Contains("-DMAIN"))
@@ -1301,11 +1300,11 @@ TEST_F(TUSchedulerTests, IncluderCache) {
   // Also run update for Main3 to invalidate the preeamble to make sure next
   // update populates include cache associations.
   S.update(Main3, getInputs(Main3, SomeIncludes), WantDiagnostics::Yes);
-  EXPECT_TRUE(S.blockUntilIdle(BlockTimeout));
+  EXPECT_TRUE(S.blockUntilIdle(timeoutSeconds(10)));
   // Re-add the file and make sure nothing crashes.
   CDB.FailAll = false;
   S.update(Main3, getInputs(Main3, SomeIncludes), WantDiagnostics::Yes);
-  EXPECT_TRUE(S.blockUntilIdle(BlockTimeout));
+  EXPECT_TRUE(S.blockUntilIdle(timeoutSeconds(10)));
   EXPECT_THAT(GetFlags(NoCmd), Contains("-DMAIN3"))
       << "association invalidated and then claimed by main3";
 }
@@ -1319,7 +1318,7 @@ TEST_F(TUSchedulerTests, PreservesLastActiveFile) {
 
     auto CheckNoFileActionsSeesLastActiveFile =
         [&](llvm::StringRef LastActiveFile) {
-          ASSERT_TRUE(S.blockUntilIdle(BlockTimeout));
+          ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(10)));
           std::atomic<int> Counter(0);
           // We only check for run and runQuick as runWithAST and
           // runWithPreamble is always bound to a file.
@@ -1331,7 +1330,7 @@ TEST_F(TUSchedulerTests, PreservesLastActiveFile) {
             ++Counter;
             EXPECT_EQ(LastActiveFile, boundPath());
           });
-          ASSERT_TRUE(S.blockUntilIdle(BlockTimeout));
+          ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(10)));
           EXPECT_EQ(2, Counter.load());
         };
 
@@ -1460,7 +1459,7 @@ TEST_F(TUSchedulerTests, PreambleThrottle) {
       Filenames.push_back(Path);
       S.update(Path, getInputs(Path, ""), WantDiagnostics::Yes);
     }
-    ASSERT_TRUE(S.blockUntilIdle(BlockTimeout));
+    ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(10)));
 
     // The throttler saw all files, and we built them.
     EXPECT_THAT(Throttler.Acquires,


        


More information about the cfe-commits mailing list