[PATCH] D89297: [clangd] Add a TestWorkspace utility

Nathan Ridge via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 12 23:54:21 PDT 2020


nridge added a comment.

This patch is a spinoff from my call hierarchy work (which I haven't posted for review yet, though I posted a draft at D89296 <https://reviews.llvm.org/D89296>).

I'd like to be able to write tests where I can:

- specify the contents of multiple header and source files, which may have `#include` relationships among them
- index the files
- create an AST for one or more of these files
- run operations that require an AST + the index and make assertions about their results.

The `TestWorkspace` utility in this patch is my attempt to allow writing tests of this form without a lot of boilerplate. I also use it in one existing test, `BackgroundIndexTest.RelationsMultiFile`, though this use is not the most interesting as it does not involve ASTs. There is a more interesting use in D89298 <https://reviews.llvm.org/D89298> for writing a call hierarchy test that does use ASTs.

I am seeking guidance on the following:

- Is this a useful utility to have? I've certainly found it useful for writing call hierarchy tests.
- Is it OK that it depends on `BackgroundIndex`? In principle, it should be possible to make the same interface work with `FileIndex` under the hood, but I haven't figured out how. (Specifically, I haven't figured out how to get `FileIndex` to resolve `#include`s, because you can't pass a `MockFS` to it the way you can to `BackgroundIndex`.)
- If we keep the dependency on `BackgroundIndex`, is it OK to move the related dependencies (like `MemoryShardStorage`) to a header, so that `TestWorkspace` itself can live in a header and tests from different files (not just `BackgroundIndexTest.cpp`) can use it?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89297



More information about the cfe-commits mailing list