Skip to content

Commit

Permalink
[clangd] Dont assert on specific uris for diagnostics docs
Browse files Browse the repository at this point in the history
To enable customization of links in downstream projects without
breaking tests (and also ease of pointing at different links in the future).
Just check for existence instead.

Differential Revision: https://reviews.llvm.org/D157071
  • Loading branch information
kadircet committed Aug 4, 2023
1 parent 892305a commit 734da23
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
8 changes: 4 additions & 4 deletions clang-tools-extra/clangd/test/include-cleaner-batch-fix.test
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
# CHECK-NEXT: {
# CHECK-NEXT: "code": "missing-includes",
# CHECK-NEXT: "codeDescription": {
# CHECK-NEXT: "href": "https://clangd.llvm.org/guides/include-cleaner"
# CHECK-NEXT: "href": "{{.*}}"
# CHECK-NEXT: },
# CHECK-NEXT: "message": "No header providing \"Foo\" is directly included (fixes available)",
# CHECK-NEXT: "range": {
Expand All @@ -53,7 +53,7 @@
# CHECK-NEXT: {
# CHECK-NEXT: "code": "missing-includes",
# CHECK-NEXT: "codeDescription": {
# CHECK-NEXT: "href": "https://clangd.llvm.org/guides/include-cleaner"
# CHECK-NEXT: "href": "{{.*}}"
# CHECK-NEXT: },
# CHECK-NEXT: "message": "No header providing \"Bar\" is directly included (fixes available)",
# CHECK-NEXT: "range": {
Expand All @@ -72,7 +72,7 @@
# CHECK-NEXT: {
# CHECK-NEXT: "code": "unused-includes",
# CHECK-NEXT: "codeDescription": {
# CHECK-NEXT: "href": "https://clangd.llvm.org/guides/include-cleaner"
# CHECK-NEXT: "href": "{{.*}}"
# CHECK-NEXT: },
# CHECK-NEXT: "message": "Included header all1.h is not used directly (fixes available)",
# CHECK-NEXT: "range": {
Expand All @@ -94,7 +94,7 @@
# CHECK-NEXT: {
# CHECK-NEXT: "code": "unused-includes",
# CHECK-NEXT: "codeDescription": {
# CHECK-NEXT: "href": "https://clangd.llvm.org/guides/include-cleaner"
# CHECK-NEXT: "href": "{{.*}}"
# CHECK-NEXT: },
# CHECK-NEXT: "message": "Included header all2.h is not used directly (fixes available)",
# CHECK-NEXT: "range": {
Expand Down
5 changes: 3 additions & 2 deletions clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "llvm/Support/JSON.h"
#include "llvm/Support/ScopedPrinter.h"
#include "llvm/Support/TargetSelect.h"
#include "llvm/Testing/Support/SupportHelpers.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include <cstddef>
Expand Down Expand Up @@ -1961,8 +1962,8 @@ TEST(DiagnosticsTest, IncludeCleaner) {
withTag(DiagnosticTag::Unnecessary), diagSource(Diag::Clangd),
withFix(Fix(Test.range("fix"), "", "remove #include directive")))));
auto &Diag = AST.getDiagnostics().front();
EXPECT_EQ(getDiagnosticDocURI(Diag.Source, Diag.ID, Diag.Name),
std::string("https://clangd.llvm.org/guides/include-cleaner"));
EXPECT_THAT(getDiagnosticDocURI(Diag.Source, Diag.ID, Diag.Name),
llvm::ValueIs(Not(IsEmpty())));
Cfg.Diagnostics.SuppressAll = true;
WithContextValue SuppressAllWithCfg(Config::Key, std::move(Cfg));
EXPECT_THAT(TU.build().getDiagnostics(), IsEmpty());
Expand Down

0 comments on commit 734da23

Please sign in to comment.