Skip to content

Commit 9e65dca

Browse files
committed
[clangd] Add some regression tests for clang-tidy finding severities
1 parent 0b8866d commit 9e65dca

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1984,6 +1984,30 @@ TEST(Diagnostics, Tags) {
19841984
withTag(DiagnosticTag::Deprecated)))));
19851985
}
19861986

1987+
TEST(Diagnostics, TidyDiagsArentAffectedFromWerror) {
1988+
TestTU TU;
1989+
TU.ExtraArgs = {"-Werror"};
1990+
Annotations Test(R"cpp($typedef[[typedef int INT]]; // error-ok)cpp");
1991+
TU.Code = Test.code().str();
1992+
TU.ClangTidyProvider = addTidyChecks("modernize-use-using");
1993+
EXPECT_THAT(
1994+
TU.build().getDiagnostics(),
1995+
ifTidyChecks(UnorderedElementsAre(
1996+
AllOf(Diag(Test.range("typedef"), "use 'using' instead of 'typedef'"),
1997+
// Make sure severity for clang-tidy finding isn't bumped to
1998+
// error due to Werror in compile flags.
1999+
diagSeverity(DiagnosticsEngine::Warning)))));
2000+
2001+
TU.ClangTidyProvider =
2002+
addTidyChecks("modernize-use-using", /*WarningsAsErrors=*/"modernize-*");
2003+
EXPECT_THAT(
2004+
TU.build().getDiagnostics(),
2005+
ifTidyChecks(UnorderedElementsAre(
2006+
AllOf(Diag(Test.range("typedef"), "use 'using' instead of 'typedef'"),
2007+
// Unless bumped explicitly with WarnAsError.
2008+
diagSeverity(DiagnosticsEngine::Error)))));
2009+
}
2010+
19872011
TEST(Diagnostics, DeprecatedDiagsAreHints) {
19882012
ClangdDiagnosticOptions Opts;
19892013
std::optional<clangd::Diagnostic> Diag;

0 commit comments

Comments
 (0)