This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Drop TestTUs dependency on gtest
ClosedPublic

Authored by kadircet on Jun 4 2021, 4:35 AM.

Details

Summary

TestTU now prints errors to llvm::errs and aborts on failures via
llvm_unreachable, rather than executing ASSERT_FALSE.

We'd like to make use of these testing libraries in different test suits that
might be compiling with a different gtest version than LLVM has.

Diff Detail

Event Timeline

kadircet created this revision.Jun 4 2021, 4:35 AM
kadircet requested review of this revision.Jun 4 2021, 4:35 AM
sammccall added inline comments.Jun 4 2021, 6:53 AM
clang-tools-extra/clangd/unittests/TestTU.cpp
75

I don't love using llvm_unreachable for error handling (esp environment sensitive kind like this), it compiles down to UB in ndebug mode.

Log + abort would be preferable I think, though it's one extra line.

121–122

I think we should replace this one with abort() too now

121–122

this check is now a log message that could still let the test pass
Make it an assert instead?

(I think assert without any early return is appropriate per normal llvm style)

149

this needs to fail the test. abort()?

kadircet updated this revision to Diff 350206.Jun 7 2021, 2:15 AM
kadircet marked 3 inline comments as done.
  • Use log + abort instead of llvm_unreachable to not rely on UB.
clang-tools-extra/clangd/unittests/TestTU.cpp
75

ah I thought it always compiled down to abort (and sometimes inserted a builtin to indicate noreturn). looks like i've missed the conditional macro definition.

121–122

aborting instead of just assert(false), since the rest of the code assumes AST->getDiagnostics has a value.

sammccall accepted this revision.Jun 7 2021, 2:38 AM
sammccall added inline comments.
clang-tools-extra/clangd/unittests/TestTU.cpp
121–122

This is actually a can't-happen condition even if the test is messed up, and we normally assert on those before dereferencing a pointer. But up to you.

This revision is now accepted and ready to land.Jun 7 2021, 2:38 AM
kadircet updated this revision to Diff 350231.Jun 7 2021, 3:41 AM
  • Assert for daigs rather than abort.
This revision was automatically updated to reflect the committed changes.