This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Set up machinery for gtests of ClangdLSPServer.
ClosedPublic

Authored by sammccall on Apr 8 2020, 5:04 PM.

Details

Summary

This is going to be needed to test e.g. diagnostics regeneration on
didSave where files changed on disk. Coordinating such changes is too
hard in lit tests.

Diff Detail

Event Timeline

sammccall created this revision.Apr 8 2020, 5:04 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 8 2020, 5:04 PM

It seems fairly likely that this is a big complicated thing we end up using for 1 or 2 tests that are too hard to test with lit but can't be tested at a lower level than ClangdLSPServer.
Suggestions on how to make it more lightweight would be welcome!

LGTM, mostly nits.

Unfortunately I don't see any way to make it simpler :/

clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
105

nit: move this to top of the file

clang-tools-extra/clangd/unittests/LSPClient.cpp
66

put methods before fields

69

i think logging errors here could help with debugging.

72

nit: static_cast

100

this check should happen before accessing Actions.front

107

put public before private

158

ah, the !Action check for stop now makes sense :D maybe get rid of the Stop flag inside transportimpl and say an empty action terminates the loop or make this invoke a T->stop(); which sets the flag

198

URI is not an optional field, so shouldn't !U -> ADD_FAILURE() ?

200

again diagnostics is not optional

clang-tools-extra/clangd/unittests/LSPClient.h
45

nit: put it before members, also some comments about "multiple call is failure" might be nice

kadircet accepted this revision.Apr 9 2020, 12:10 AM
This revision is now accepted and ready to land.Apr 9 2020, 12:10 AM
sammccall updated this revision to Diff 256449.Apr 9 2020, 5:18 PM
sammccall marked 12 inline comments as done.

Address review comments

clang-tools-extra/clangd/unittests/LSPClient.cpp
66

Done - I don't care much, but curious where this guideline comes from?
My impression is LLVM puts members at the very top of the class or at the very bottom (like google-style).
DependentSizedArrayType is a random example.

69

Errors don't have bodies, the mesasge is already logged by clangdlspserver. Added a comment.

This revision was automatically updated to reflect the committed changes.
kadircet added inline comments.Apr 10 2020, 2:57 AM
clang-tools-extra/clangd/unittests/LSPClient.cpp
66

i believe most of the code in LLVM puts the members at the top of the class. but my impression was in clangd code we tend to put members at the very bottom, hence i suggested that. personally i actually find having members at the top more useful.