[PATCH] D77669: [clangd] Update TUStatus test to handle async PreambleThread

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 9 14:24:57 PDT 2020


sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

Thanks! Now having read it, I'm slightly nervous we're not catching all the interleavings.
An alternate approach if this is too messy would be just to capture the two streams of enums into separate vectors, drop duplicates, and assert the sequence of each.
Anyway, up to you what to do here, I'm happy if we're testing at least something in the async configuration.



================
Comment at: clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp:849
+  auto Opts = ClangdServer::optsForTest();
+  Opts.AsyncThreadsCount = 0;
+  ClangdServer Server(CDB, FS, Opts, &CaptureTUStatus);
----------------
kadircet wrote:
> sammccall wrote:
> > This seems unfortunate because it doesn't test the production configuration.
> > 
> > How many possible sequences are there? Are there fewer if we blockuntilidle between adddoc + locatesymbolat?
> > 
> > Can we use testing::AnyOf to fudge around the nondeterminism?
> I didn't want to do that as it was rather asserting on action ordering of preamble and ast worker threads rather than checking for whether we emit TUStatuses, but I suppose this test was always trying to assert both.
> 
> Introducing some more simplications by turning of diagnostics and also making use of the assumption that ASTWorker will block for first preamble build.
This makes sense, at the risk of being a massive pain do you think we should have a separate test that (only) creates diagnostics?


================
Comment at: clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp:885
+          AnyOf(TUState(PreambleAction::Idle, ASTAction::RunningAction),
+                TUState(PreambleAction::Idle, ASTAction::RunningAction),
+                TUState(PreambleAction::Building, ASTAction::Idle)),
----------------
haha, including the (idle,runningaction) case twice is fun :-) Maybe not necessary though


================
Comment at: clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp:891
+          // action.
+          TUState(PreambleAction::Idle, ASTAction::RunningAction),
+          // Builds AST and serves the request, then goes idle.
----------------
Hmm... are you sure the preamble can't still be running at this point? What stops it from pausing forever before exiting?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D77669/new/

https://reviews.llvm.org/D77669





More information about the cfe-commits mailing list