From 0e265e315784b4e47f984f8ed9fb7586130bacdc Mon Sep 17 00:00:00 2001 From: Dmitri Gribenko Date: Fri, 29 May 2020 16:47:23 +0200 Subject: [PATCH] Move unittest helpers to a shared location Summary: unittests/AST/Language.h defines some helpers that we would like to reuse in other tests, for example, in tests for syntax trees. Reviewers: sammccall Reviewed By: sammccall Subscribers: mgorny, martong, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D80792 --- .../AST/Language.h => include/clang/Testing/CommandLineArgs.h} | 10 +++++----- clang/include/clang/module.modulemap | 6 ++++++ clang/lib/CMakeLists.txt | 1 + clang/lib/Testing/CMakeLists.txt | 7 +++++++ .../AST/Language.cpp => lib/Testing/CommandLineArgs.cpp} | 8 ++------ clang/unittests/AST/ASTImporterFixtures.h | 2 +- clang/unittests/AST/CMakeLists.txt | 2 +- clang/unittests/AST/MatchVerifier.h | 2 +- clang/unittests/AST/StructuralEquivalenceTest.cpp | 2 +- 9 files changed, 25 insertions(+), 15 deletions(-) rename clang/{unittests/AST/Language.h => include/clang/Testing/CommandLineArgs.h} (76%) create mode 100644 clang/lib/Testing/CMakeLists.txt rename clang/{unittests/AST/Language.cpp => lib/Testing/CommandLineArgs.cpp} (83%) diff --git a/clang/unittests/AST/Language.h b/clang/include/clang/Testing/CommandLineArgs.h similarity index 76% rename from clang/unittests/AST/Language.h rename to clang/include/clang/Testing/CommandLineArgs.h index da200ec..0d2267f 100644 --- a/clang/unittests/AST/Language.h +++ b/clang/include/clang/Testing/CommandLineArgs.h @@ -1,4 +1,4 @@ -//===------ unittest/AST/Language.h - AST unit test support ---------------===// +//===--- CommandLineArgs.h ------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -6,15 +6,15 @@ // //===----------------------------------------------------------------------===// // -// This file defines language options for AST unittests. +// This file defines language options for Clang unittests. // //===----------------------------------------------------------------------===// -#ifndef LLVM_CLANG_UNITTESTS_AST_LANGUAGE_H -#define LLVM_CLANG_UNITTESTS_AST_LANGUAGE_H +#ifndef LLVM_CLANG_TESTING_COMMANDLINEARGS_H +#define LLVM_CLANG_TESTING_COMMANDLINEARGS_H -#include #include +#include namespace clang { diff --git a/clang/include/clang/module.modulemap b/clang/include/clang/module.modulemap index 15f891c..7549ff2 100644 --- a/clang/include/clang/module.modulemap +++ b/clang/include/clang/module.modulemap @@ -152,6 +152,12 @@ module Clang_StaticAnalyzer_Frontend { module * { export * } } +module Clang_Testing { + requires cplusplus + umbrella "Testing" + module * { export * } +} + module Clang_Tooling { requires cplusplus umbrella "Tooling" module * { export * } // FIXME: Exclude these headers to avoid pulling all of the AST matchers diff --git a/clang/lib/CMakeLists.txt b/clang/lib/CMakeLists.txt index 0c03f59..c2b6a5a 100644 --- a/clang/lib/CMakeLists.txt +++ b/clang/lib/CMakeLists.txt @@ -24,3 +24,4 @@ if(CLANG_ENABLE_STATIC_ANALYZER) add_subdirectory(StaticAnalyzer) endif() add_subdirectory(Format) +add_subdirectory(Testing) diff --git a/clang/lib/Testing/CMakeLists.txt b/clang/lib/Testing/CMakeLists.txt new file mode 100644 index 0000000..4a8d436 --- /dev/null +++ b/clang/lib/Testing/CMakeLists.txt @@ -0,0 +1,7 @@ +set(LLVM_LINK_COMPONENTS + Support + ) + +add_clang_library(clangTesting + CommandLineArgs.cpp + ) diff --git a/clang/unittests/AST/Language.cpp b/clang/lib/Testing/CommandLineArgs.cpp similarity index 83% rename from clang/unittests/AST/Language.cpp rename to clang/lib/Testing/CommandLineArgs.cpp index 3dd9659..58a61da 100644 --- a/clang/unittests/AST/Language.cpp +++ b/clang/lib/Testing/CommandLineArgs.cpp @@ -1,16 +1,12 @@ -//===------ unittest/AST/Language.cpp - AST unit test support -------------===// +//===--- CommandLineArgs.cpp ----------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// -// -// This file defines language options for AST unittests. -// -//===----------------------------------------------------------------------===// -#include "Language.h" +#include "clang/Testing/CommandLineArgs.h" #include "llvm/Support/ErrorHandling.h" namespace clang { diff --git a/clang/unittests/AST/ASTImporterFixtures.h b/clang/unittests/AST/ASTImporterFixtures.h index 619c3f5..4fbceef 100644 --- a/clang/unittests/AST/ASTImporterFixtures.h +++ b/clang/unittests/AST/ASTImporterFixtures.h @@ -19,11 +19,11 @@ #include "clang/AST/ASTImporter.h" #include "clang/AST/ASTImporterSharedState.h" #include "clang/Frontend/ASTUnit.h" +#include "clang/Testing/CommandLineArgs.h" #include "llvm/Support/Error.h" #include "llvm/Support/ErrorHandling.h" #include "DeclMatcher.h" -#include "Language.h" #include diff --git a/clang/unittests/AST/CMakeLists.txt b/clang/unittests/AST/CMakeLists.txt index 5d9ff5b..2e750ac 100644 --- a/clang/unittests/AST/CMakeLists.txt +++ b/clang/unittests/AST/CMakeLists.txt @@ -26,7 +26,6 @@ add_clang_unittest(ASTTests DeclTest.cpp EvaluateAsRValueTest.cpp ExternalASTSourceTest.cpp - Language.cpp NamedDeclPrinterTest.cpp RecursiveASTVisitorTest.cpp SizelessTypesTest.cpp @@ -42,6 +41,7 @@ clang_target_link_libraries(ASTTests clangBasic clangFrontend clangSerialization + clangTesting clangTooling ) diff --git a/clang/unittests/AST/MatchVerifier.h b/clang/unittests/AST/MatchVerifier.h index 9daf4ce..865b03a 100644 --- a/clang/unittests/AST/MatchVerifier.h +++ b/clang/unittests/AST/MatchVerifier.h @@ -21,8 +21,8 @@ #include "clang/AST/ASTContext.h" #include "clang/ASTMatchers/ASTMatchFinder.h" #include "clang/ASTMatchers/ASTMatchers.h" +#include "clang/Testing/CommandLineArgs.h" #include "clang/Tooling/Tooling.h" -#include "Language.h" #include "gtest/gtest.h" namespace clang { diff --git a/clang/unittests/AST/StructuralEquivalenceTest.cpp b/clang/unittests/AST/StructuralEquivalenceTest.cpp index cadcc45..3cb4afed 100644 --- a/clang/unittests/AST/StructuralEquivalenceTest.cpp +++ b/clang/unittests/AST/StructuralEquivalenceTest.cpp @@ -2,10 +2,10 @@ #include "clang/AST/ASTStructuralEquivalence.h" #include "clang/ASTMatchers/ASTMatchers.h" #include "clang/Frontend/ASTUnit.h" +#include "clang/Testing/CommandLineArgs.h" #include "clang/Tooling/Tooling.h" #include "llvm/Support/Host.h" -#include "Language.h" #include "DeclMatcher.h" #include "gtest/gtest.h" -- 2.7.4