[clang] 0e265e3 - Move unittest helpers to a shared location

Dmitri Gribenko via cfe-commits cfe-commits at lists.llvm.org
Fri May 29 07:53:07 PDT 2020


Author: Dmitri Gribenko
Date: 2020-05-29T16:47:33+02:00
New Revision: 0e265e315784b4e47f984f8ed9fb7586130bacdc

URL: https://github.com/llvm/llvm-project/commit/0e265e315784b4e47f984f8ed9fb7586130bacdc
DIFF: https://github.com/llvm/llvm-project/commit/0e265e315784b4e47f984f8ed9fb7586130bacdc.diff

LOG: 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

Added: 
    clang/include/clang/Testing/CommandLineArgs.h
    clang/lib/Testing/CMakeLists.txt
    clang/lib/Testing/CommandLineArgs.cpp

Modified: 
    clang/include/clang/module.modulemap
    clang/lib/CMakeLists.txt
    clang/unittests/AST/ASTImporterFixtures.h
    clang/unittests/AST/CMakeLists.txt
    clang/unittests/AST/MatchVerifier.h
    clang/unittests/AST/StructuralEquivalenceTest.cpp

Removed: 
    clang/unittests/AST/Language.cpp
    clang/unittests/AST/Language.h


################################################################################
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 da200ec8719f..0d2267f63ac5 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 <vector>
 #include <string>
+#include <vector>
 
 namespace clang {
 

diff  --git a/clang/include/clang/module.modulemap b/clang/include/clang/module.modulemap
index 15f891c15340..7549ff2e3bcd 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 0c03f5972b09..c2b6a5a4d5d4 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 000000000000..4a8d436aab66
--- /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 3dd9659fc00e..58a61dade2ea 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 619c3f590be4..4fbceef39384 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 <sstream>
 

diff  --git a/clang/unittests/AST/CMakeLists.txt b/clang/unittests/AST/CMakeLists.txt
index 5d9ff5b97dbd..2e750ac9ea92 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 9daf4ce39010..865b03a7e80e 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 cadcc45c5885..3cb4afedd4db 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"


        


More information about the cfe-commits mailing list