Skip to content

Commit 0e265e3

Browse files
committed
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
1 parent 16506d7 commit 0e265e3

File tree

9 files changed

+25
-15
lines changed

9 files changed

+25
-15
lines changed

clang/unittests/AST/Language.h renamed to clang/include/clang/Testing/CommandLineArgs.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
//===------ unittest/AST/Language.h - AST unit test support ---------------===//
1+
//===--- CommandLineArgs.h ------------------------------------------------===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.
55
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
//
77
//===----------------------------------------------------------------------===//
88
//
9-
// This file defines language options for AST unittests.
9+
// This file defines language options for Clang unittests.
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
#ifndef LLVM_CLANG_UNITTESTS_AST_LANGUAGE_H
14-
#define LLVM_CLANG_UNITTESTS_AST_LANGUAGE_H
13+
#ifndef LLVM_CLANG_TESTING_COMMANDLINEARGS_H
14+
#define LLVM_CLANG_TESTING_COMMANDLINEARGS_H
1515

16-
#include <vector>
1716
#include <string>
17+
#include <vector>
1818

1919
namespace clang {
2020

clang/include/clang/module.modulemap

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,12 @@ module Clang_StaticAnalyzer_Frontend {
152152
module * { export * }
153153
}
154154

155+
module Clang_Testing {
156+
requires cplusplus
157+
umbrella "Testing"
158+
module * { export * }
159+
}
160+
155161
module Clang_Tooling {
156162
requires cplusplus umbrella "Tooling" module * { export * }
157163
// FIXME: Exclude these headers to avoid pulling all of the AST matchers

clang/lib/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,4 @@ if(CLANG_ENABLE_STATIC_ANALYZER)
2424
add_subdirectory(StaticAnalyzer)
2525
endif()
2626
add_subdirectory(Format)
27+
add_subdirectory(Testing)

clang/lib/Testing/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
set(LLVM_LINK_COMPONENTS
2+
Support
3+
)
4+
5+
add_clang_library(clangTesting
6+
CommandLineArgs.cpp
7+
)

clang/unittests/AST/Language.cpp renamed to clang/lib/Testing/CommandLineArgs.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
1-
//===------ unittest/AST/Language.cpp - AST unit test support -------------===//
1+
//===--- CommandLineArgs.cpp ----------------------------------------------===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.
55
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
//
77
//===----------------------------------------------------------------------===//
8-
//
9-
// This file defines language options for AST unittests.
10-
//
11-
//===----------------------------------------------------------------------===//
128

13-
#include "Language.h"
9+
#include "clang/Testing/CommandLineArgs.h"
1410
#include "llvm/Support/ErrorHandling.h"
1511

1612
namespace clang {

clang/unittests/AST/ASTImporterFixtures.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919
#include "clang/AST/ASTImporter.h"
2020
#include "clang/AST/ASTImporterSharedState.h"
2121
#include "clang/Frontend/ASTUnit.h"
22+
#include "clang/Testing/CommandLineArgs.h"
2223
#include "llvm/Support/Error.h"
2324
#include "llvm/Support/ErrorHandling.h"
2425

2526
#include "DeclMatcher.h"
26-
#include "Language.h"
2727

2828
#include <sstream>
2929

clang/unittests/AST/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ add_clang_unittest(ASTTests
2626
DeclTest.cpp
2727
EvaluateAsRValueTest.cpp
2828
ExternalASTSourceTest.cpp
29-
Language.cpp
3029
NamedDeclPrinterTest.cpp
3130
RecursiveASTVisitorTest.cpp
3231
SizelessTypesTest.cpp
@@ -42,6 +41,7 @@ clang_target_link_libraries(ASTTests
4241
clangBasic
4342
clangFrontend
4443
clangSerialization
44+
clangTesting
4545
clangTooling
4646
)
4747

clang/unittests/AST/MatchVerifier.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
#include "clang/AST/ASTContext.h"
2222
#include "clang/ASTMatchers/ASTMatchFinder.h"
2323
#include "clang/ASTMatchers/ASTMatchers.h"
24+
#include "clang/Testing/CommandLineArgs.h"
2425
#include "clang/Tooling/Tooling.h"
25-
#include "Language.h"
2626
#include "gtest/gtest.h"
2727

2828
namespace clang {

clang/unittests/AST/StructuralEquivalenceTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
#include "clang/AST/ASTStructuralEquivalence.h"
33
#include "clang/ASTMatchers/ASTMatchers.h"
44
#include "clang/Frontend/ASTUnit.h"
5+
#include "clang/Testing/CommandLineArgs.h"
56
#include "clang/Tooling/Tooling.h"
67
#include "llvm/Support/Host.h"
78

8-
#include "Language.h"
99
#include "DeclMatcher.h"
1010

1111
#include "gtest/gtest.h"

0 commit comments

Comments
 (0)