diff options
author | Manuel Klimek <klimek@google.com> | 2015-08-11 14:21:26 +0000 |
---|---|---|
committer | Manuel Klimek <klimek@google.com> | 2015-08-11 14:21:26 +0000 |
commit | e8c8d887befd1c1a169da6e3711ac1b3419a5b04 (patch) | |
tree | 654e4058fee1b37bb0a2c53364e069c57c4bea6a | |
parent | 243c073a2ea3453ae888f3472fc1754c91c9a5f2 (diff) | |
download | bcm5719-llvm-e8c8d887befd1c1a169da6e3711ac1b3419a5b04.tar.gz bcm5719-llvm-e8c8d887befd1c1a169da6e3711ac1b3419a5b04.zip |
1. Disable tests that currently cannot work on windows due to missing path canonicalization in the file manager.
2. Add better output when a clang-tidy unit test fails so it's clear what the error is.
llvm-svn: 244602
-rw-r--r-- | clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h | 10 | ||||
-rw-r--r-- | clang-tools-extra/unittests/clang-tidy/IncludeInserterTest.cpp | 78 |
2 files changed, 54 insertions, 34 deletions
diff --git a/clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h b/clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h index 642057b00d0..54c6bea4307 100644 --- a/clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h +++ b/clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h @@ -17,6 +17,7 @@ #include "clang/Frontend/FrontendActions.h" #include "clang/Tooling/Refactoring.h" #include "clang/Tooling/Tooling.h" +#include "gtest/gtest.h" #include <map> namespace clang { @@ -76,8 +77,15 @@ runCheckOnCode(StringRef Code, std::vector<ClangTidyError> *Errors = nullptr, FileContent.second); } Invocation.setDiagnosticConsumer(&DiagConsumer); - if (!Invocation.run()) + bool Result = Invocation.run(); + if (!Result) { + std::string ErrorText; + for (const auto &Error : Context.getErrors()) { + ErrorText += Error.Message.Message + "\n"; + } + ADD_FAILURE() << ErrorText; return ""; + } DiagConsumer.finish(); tooling::Replacements Fixes; diff --git a/clang-tools-extra/unittests/clang-tidy/IncludeInserterTest.cpp b/clang-tools-extra/unittests/clang-tidy/IncludeInserterTest.cpp index 086fdca0ef6..92373f90a28 100644 --- a/clang-tools-extra/unittests/clang-tidy/IncludeInserterTest.cpp +++ b/clang-tools-extra/unittests/clang-tidy/IncludeInserterTest.cpp @@ -13,6 +13,16 @@ #include "ClangTidyTest.h" #include "gtest/gtest.h" +// FIXME: Canonicalize paths correctly on windows. +// Currently, adding virtual files will canonicalize the paths before +// storing the virtual entries. +// When resolving virtual entries in the FileManager, the paths (for +// example coming from a #include directive) are not canonicalized +// to native paths; thus, the virtual file is not found. +// This needs to be fixed in the FileManager before we can make +// clang-tidy tests work. +#if !defined(_WIN32) + namespace clang { namespace tidy { namespace { @@ -76,7 +86,7 @@ std::string runCheckOnCode(StringRef Code, StringRef Filename, return test::runCheckOnCode<Check>(Code, &Errors, Filename, None, ClangTidyOptions(), {// Main file include - {"devtools/cymbal/clang_tidy/tests/" + {"clang_tidy/tests/" "insert_includes_test_header.h", "\n"}, // Non system headers @@ -95,7 +105,7 @@ std::string runCheckOnCode(StringRef Code, StringRef Filename, TEST(IncludeInserterTest, InsertAfterLastNonSystemInclude) { const char *PreCode = R"( -#include "devtools/cymbal/clang_tidy/tests/insert_includes_test_header.h" +#include "clang_tidy/tests/insert_includes_test_header.h" #include <list> #include <map> @@ -106,7 +116,7 @@ void foo() { int a = 0; })"; const char *PostCode = R"( -#include "devtools/cymbal/clang_tidy/tests/insert_includes_test_header.h" +#include "clang_tidy/tests/insert_includes_test_header.h" #include <list> #include <map> @@ -119,14 +129,14 @@ void foo() { })"; EXPECT_EQ(PostCode, runCheckOnCode<NonSystemHeaderInserterCheck>( - PreCode, "devtools/cymbal/clang_tidy/tests/" + PreCode, "clang_tidy/tests/" "insert_includes_test_input2.cc", 1)); } TEST(IncludeInserterTest, InsertBeforeFirstNonSystemInclude) { const char *PreCode = R"( -#include "devtools/cymbal/clang_tidy/tests/insert_includes_test_header.h" +#include "clang_tidy/tests/insert_includes_test_header.h" #include <list> #include <map> @@ -137,7 +147,7 @@ void foo() { int a = 0; })"; const char *PostCode = R"( -#include "devtools/cymbal/clang_tidy/tests/insert_includes_test_header.h" +#include "clang_tidy/tests/insert_includes_test_header.h" #include <list> #include <map> @@ -150,14 +160,14 @@ void foo() { })"; EXPECT_EQ(PostCode, runCheckOnCode<NonSystemHeaderInserterCheck>( - PreCode, "devtools/cymbal/clang_tidy/tests/" + PreCode, "clang_tidy/tests/" "insert_includes_test_input2.cc", 1)); } TEST(IncludeInserterTest, InsertBetweenNonSystemIncludes) { const char *PreCode = R"( -#include "devtools/cymbal/clang_tidy/tests/insert_includes_test_header.h" +#include "clang_tidy/tests/insert_includes_test_header.h" #include <list> #include <map> @@ -169,7 +179,7 @@ void foo() { int a = 0; })"; const char *PostCode = R"( -#include "devtools/cymbal/clang_tidy/tests/insert_includes_test_header.h" +#include "clang_tidy/tests/insert_includes_test_header.h" #include <list> #include <map> @@ -183,14 +193,14 @@ void foo() { })"; EXPECT_EQ(PostCode, runCheckOnCode<NonSystemHeaderInserterCheck>( - PreCode, "devtools/cymbal/clang_tidy/tests/" + PreCode, "clang_tidy/tests/" "insert_includes_test_input2.cc", 1)); } TEST(IncludeInserterTest, NonSystemIncludeAlreadyIncluded) { const char *PreCode = R"( -#include "devtools/cymbal/clang_tidy/tests/insert_includes_test_header.h" +#include "clang_tidy/tests/insert_includes_test_header.h" #include <list> #include <map> @@ -203,14 +213,14 @@ void foo() { int a = 0; })"; EXPECT_EQ(PreCode, runCheckOnCode<NonSystemHeaderInserterCheck>( - PreCode, "devtools/cymbal/clang_tidy/tests/" + PreCode, "clang_tidy/tests/" "insert_includes_test_input2.cc", 0)); } TEST(IncludeInserterTest, InsertNonSystemIncludeAfterLastCXXSystemInclude) { const char *PreCode = R"( -#include "devtools/cymbal/clang_tidy/tests/insert_includes_test_header.h" +#include "clang_tidy/tests/insert_includes_test_header.h" #include <list> #include <map> @@ -219,7 +229,7 @@ void foo() { int a = 0; })"; const char *PostCode = R"( -#include "devtools/cymbal/clang_tidy/tests/insert_includes_test_header.h" +#include "clang_tidy/tests/insert_includes_test_header.h" #include <list> #include <map> @@ -231,20 +241,20 @@ void foo() { })"; EXPECT_EQ(PostCode, runCheckOnCode<NonSystemHeaderInserterCheck>( - PreCode, "devtools/cymbal/clang_tidy/tests/" + PreCode, "clang_tidy/tests/" "insert_includes_test_header.cc", 1)); } TEST(IncludeInserterTest, InsertNonSystemIncludeAfterMainFileInclude) { const char *PreCode = R"( -#include "devtools/cymbal/clang_tidy/tests/insert_includes_test_header.h" +#include "clang_tidy/tests/insert_includes_test_header.h" void foo() { int a = 0; })"; const char *PostCode = R"( -#include "devtools/cymbal/clang_tidy/tests/insert_includes_test_header.h" +#include "clang_tidy/tests/insert_includes_test_header.h" #include "path/to/header.h" @@ -253,14 +263,14 @@ void foo() { })"; EXPECT_EQ(PostCode, runCheckOnCode<NonSystemHeaderInserterCheck>( - PreCode, "devtools/cymbal/clang_tidy/tests/" + PreCode, "clang_tidy/tests/" "insert_includes_test_header.cc", 1)); } TEST(IncludeInserterTest, InsertCXXSystemIncludeAfterLastCXXSystemInclude) { const char *PreCode = R"( -#include "devtools/cymbal/clang_tidy/tests/insert_includes_test_header.h" +#include "clang_tidy/tests/insert_includes_test_header.h" #include <list> #include <map> @@ -271,7 +281,7 @@ void foo() { int a = 0; })"; const char *PostCode = R"( -#include "devtools/cymbal/clang_tidy/tests/insert_includes_test_header.h" +#include "clang_tidy/tests/insert_includes_test_header.h" #include <list> #include <map> @@ -284,14 +294,14 @@ void foo() { })"; EXPECT_EQ(PostCode, runCheckOnCode<CXXSystemIncludeInserterCheck>( - PreCode, "devtools/cymbal/clang_tidy/tests/" + PreCode, "clang_tidy/tests/" "insert_includes_test_header.cc", 1)); } TEST(IncludeInserterTest, InsertCXXSystemIncludeBeforeFirstCXXSystemInclude) { const char *PreCode = R"( -#include "devtools/cymbal/clang_tidy/tests/insert_includes_test_header.h" +#include "clang_tidy/tests/insert_includes_test_header.h" #include <vector> @@ -301,7 +311,7 @@ void foo() { int a = 0; })"; const char *PostCode = R"( -#include "devtools/cymbal/clang_tidy/tests/insert_includes_test_header.h" +#include "clang_tidy/tests/insert_includes_test_header.h" #include <set> #include <vector> @@ -313,14 +323,14 @@ void foo() { })"; EXPECT_EQ(PostCode, runCheckOnCode<CXXSystemIncludeInserterCheck>( - PreCode, "devtools/cymbal/clang_tidy/tests/" + PreCode, "clang_tidy/tests/" "insert_includes_test_header.cc", 1)); } TEST(IncludeInserterTest, InsertCXXSystemIncludeBetweenCXXSystemIncludes) { const char *PreCode = R"( -#include "devtools/cymbal/clang_tidy/tests/insert_includes_test_header.h" +#include "clang_tidy/tests/insert_includes_test_header.h" #include <map> #include <vector> @@ -331,7 +341,7 @@ void foo() { int a = 0; })"; const char *PostCode = R"( -#include "devtools/cymbal/clang_tidy/tests/insert_includes_test_header.h" +#include "clang_tidy/tests/insert_includes_test_header.h" #include <map> #include <set> @@ -344,14 +354,14 @@ void foo() { })"; EXPECT_EQ(PostCode, runCheckOnCode<CXXSystemIncludeInserterCheck>( - PreCode, "devtools/cymbal/clang_tidy/tests/" + PreCode, "clang_tidy/tests/" "insert_includes_test_header.cc", 1)); } TEST(IncludeInserterTest, InsertCXXSystemIncludeAfterMainFileInclude) { const char *PreCode = R"( -#include "devtools/cymbal/clang_tidy/tests/insert_includes_test_header.h" +#include "clang_tidy/tests/insert_includes_test_header.h" #include "path/to/a/header.h" @@ -359,7 +369,7 @@ void foo() { int a = 0; })"; const char *PostCode = R"( -#include "devtools/cymbal/clang_tidy/tests/insert_includes_test_header.h" +#include "clang_tidy/tests/insert_includes_test_header.h" #include <set> @@ -370,14 +380,14 @@ void foo() { })"; EXPECT_EQ(PostCode, runCheckOnCode<CXXSystemIncludeInserterCheck>( - PreCode, "devtools/cymbal/clang_tidy/tests/" + PreCode, "clang_tidy/tests/" "insert_includes_test_header.cc", 1)); } TEST(IncludeInserterTest, InsertCXXSystemIncludeAfterCSystemInclude) { const char *PreCode = R"( -#include "devtools/cymbal/clang_tidy/tests/insert_includes_test_header.h" +#include "clang_tidy/tests/insert_includes_test_header.h" #include <stdlib.h> @@ -387,7 +397,7 @@ void foo() { int a = 0; })"; const char *PostCode = R"( -#include "devtools/cymbal/clang_tidy/tests/insert_includes_test_header.h" +#include "clang_tidy/tests/insert_includes_test_header.h" #include <stdlib.h> @@ -400,7 +410,7 @@ void foo() { })"; EXPECT_EQ(PostCode, runCheckOnCode<CXXSystemIncludeInserterCheck>( - PreCode, "devtools/cymbal/clang_tidy/tests/" + PreCode, "clang_tidy/tests/" "insert_includes_test_header.cc", 1)); } @@ -408,3 +418,5 @@ void foo() { } // namespace } // namespace tidy } // namespace clang + +#endif
\ No newline at end of file |