From 09353d927b965dd61c9144879b62d97fe34fad0c Mon Sep 17 00:00:00 2001 From: Nikolai Kosjar Date: Wed, 13 May 2020 12:25:24 +0200 Subject: [PATCH] ClangTools: Fix ReadExportedDiagnostics.* tests These fail [ FAILED ] ReadExportedDiagnostics.Tidy [ FAILED ] ReadExportedDiagnostics.Tidy_Clang [ FAILED ] ReadExportedDiagnostics.Tidy_ClangAnalyzer [ FAILED ] ReadExportedDiagnostics.Clazy as 07ec6de8d94e1498407158525baba4be441a791c introduced Diagnostic::name but did not adapt tests and printing. Change-Id: Icadace9c23ad1ad03eee7ad394bbc0211aea31f3 Reviewed-by: Marco Bubke --- tests/unit/unittest/gtest-creator-printing.cpp | 1 + tests/unit/unittest/readexporteddiagnostics-test.cpp | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/tests/unit/unittest/gtest-creator-printing.cpp b/tests/unit/unittest/gtest-creator-printing.cpp index 6d5f7a2cf34..62561d279b3 100644 --- a/tests/unit/unittest/gtest-creator-printing.cpp +++ b/tests/unit/unittest/gtest-creator-printing.cpp @@ -1347,6 +1347,7 @@ std::ostream &operator<<(std::ostream &out, const ExplainingStep &step) std::ostream &operator<<(std::ostream &out, const Diagnostic &diag) { return out << "(" + << diag.name << ", " << diag.description << ", " << diag.category << ", " << diag.type << ", " diff --git a/tests/unit/unittest/readexporteddiagnostics-test.cpp b/tests/unit/unittest/readexporteddiagnostics-test.cpp index 368c868233b..cc52c51450a 100644 --- a/tests/unit/unittest/readexporteddiagnostics-test.cpp +++ b/tests/unit/unittest/readexporteddiagnostics-test.cpp @@ -106,6 +106,7 @@ TEST_F(ReadExportedDiagnostics, Tidy) const QString sourceFile = TESTDATA "tidy.modernize-use-nullptr.cpp"; const QString exportedFile = createFile(TESTDATA "tidy.modernize-use-nullptr.yaml", sourceFile); Diagnostic expectedDiag; + expectedDiag.name = "modernize-use-nullptr"; expectedDiag.location = {sourceFile, 2, 25}; expectedDiag.description = "use nullptr [modernize-use-nullptr]"; expectedDiag.type = "warning"; @@ -143,6 +144,7 @@ TEST_F(ReadExportedDiagnostics, Tidy_Clang) const QString sourceFile = TESTDATA "clang.unused-parameter.cpp"; const QString exportedFile = createFile(TESTDATA "clang.unused-parameter.yaml", sourceFile); Diagnostic expectedDiag; + expectedDiag.name = "clang-diagnostic-unused-parameter"; expectedDiag.location = {sourceFile, 4, 12}; expectedDiag.description = "unused parameter 'g' [clang-diagnostic-unused-parameter]"; expectedDiag.type = "warning"; @@ -162,6 +164,7 @@ TEST_F(ReadExportedDiagnostics, Tidy_ClangAnalyzer) const QString sourceFile = TESTDATA "clang-analyzer.dividezero.cpp"; const QString exportedFile = createFile(TESTDATA "clang-analyzer.dividezero.yaml", sourceFile); Diagnostic expectedDiag; + expectedDiag.name = "clang-analyzer-core.DivideZero"; expectedDiag.location = {sourceFile, 4, 15}; expectedDiag.description = "Division by zero [clang-analyzer-core.DivideZero]"; expectedDiag.type = "warning"; @@ -197,6 +200,7 @@ TEST_F(ReadExportedDiagnostics, Clazy) const QString sourceFile = TESTDATA "clazy.qgetenv.cpp"; const QString exportedFile = createFile(TESTDATA "clazy.qgetenv.yaml", sourceFile); Diagnostic expectedDiag; + expectedDiag.name = "clazy-qgetenv"; expectedDiag.location = {sourceFile, 7, 5}; expectedDiag.description = "qgetenv().isEmpty() allocates. Use qEnvironmentVariableIsEmpty() instead [clazy-qgetenv]"; expectedDiag.type = "warning";