[llvm] r350171 - [gn build] Make `ninja check-clang` also run Clang's unit tests
Nico Weber via llvm-commits
llvm-commits at lists.llvm.org
Sun Dec 30 16:10:47 PST 2018
Author: nico
Date: Sun Dec 30 16:10:47 2018
New Revision: 350171
URL: http://llvm.org/viewvc/llvm-project?rev=350171&view=rev
Log:
[gn build] Make `ninja check-clang` also run Clang's unit tests
Also add a build file for clang/lib/ASTMatchers/Dynamic, which is only needed
by tests (and clang/tools/extra).
Also make llvm/utils/gn/build/sync_source_lists_from_cmake.py check that every
CMakeLists.txt file below {lld,clang}/unittests has a corresponding BUILD.gn
file, so we notice if new test binaries get added (since the failure mode for
missing GN build files for tests is just the tests silently not running in the
GN build).
Also add a unittest() macro for defining unit test targets, and add a lengthy
comment there about where the unit test binaries go and why.
With this, the build files for //clang are complete.
Differential Revision: https://reviews.llvm.org/D56116
Added:
llvm/trunk/utils/gn/secondary/clang/lib/ASTMatchers/Dynamic/
llvm/trunk/utils/gn/secondary/clang/lib/ASTMatchers/Dynamic/BUILD.gn
llvm/trunk/utils/gn/secondary/clang/unittests/
llvm/trunk/utils/gn/secondary/clang/unittests/AST/
llvm/trunk/utils/gn/secondary/clang/unittests/AST/BUILD.gn
llvm/trunk/utils/gn/secondary/clang/unittests/ASTMatchers/
llvm/trunk/utils/gn/secondary/clang/unittests/ASTMatchers/BUILD.gn
llvm/trunk/utils/gn/secondary/clang/unittests/ASTMatchers/Dynamic/
llvm/trunk/utils/gn/secondary/clang/unittests/ASTMatchers/Dynamic/BUILD.gn
llvm/trunk/utils/gn/secondary/clang/unittests/Analysis/
llvm/trunk/utils/gn/secondary/clang/unittests/Analysis/BUILD.gn
llvm/trunk/utils/gn/secondary/clang/unittests/BUILD.gn
llvm/trunk/utils/gn/secondary/clang/unittests/Basic/
llvm/trunk/utils/gn/secondary/clang/unittests/Basic/BUILD.gn
llvm/trunk/utils/gn/secondary/clang/unittests/CodeGen/
llvm/trunk/utils/gn/secondary/clang/unittests/CodeGen/BUILD.gn
llvm/trunk/utils/gn/secondary/clang/unittests/CrossTU/
llvm/trunk/utils/gn/secondary/clang/unittests/CrossTU/BUILD.gn
llvm/trunk/utils/gn/secondary/clang/unittests/Driver/
llvm/trunk/utils/gn/secondary/clang/unittests/Driver/BUILD.gn
llvm/trunk/utils/gn/secondary/clang/unittests/Format/
llvm/trunk/utils/gn/secondary/clang/unittests/Format/BUILD.gn
llvm/trunk/utils/gn/secondary/clang/unittests/Frontend/
llvm/trunk/utils/gn/secondary/clang/unittests/Frontend/BUILD.gn
llvm/trunk/utils/gn/secondary/clang/unittests/Index/
llvm/trunk/utils/gn/secondary/clang/unittests/Index/BUILD.gn
llvm/trunk/utils/gn/secondary/clang/unittests/Lex/
llvm/trunk/utils/gn/secondary/clang/unittests/Lex/BUILD.gn
llvm/trunk/utils/gn/secondary/clang/unittests/Rename/
llvm/trunk/utils/gn/secondary/clang/unittests/Rename/BUILD.gn
llvm/trunk/utils/gn/secondary/clang/unittests/Rewrite/
llvm/trunk/utils/gn/secondary/clang/unittests/Rewrite/BUILD.gn
llvm/trunk/utils/gn/secondary/clang/unittests/Sema/
llvm/trunk/utils/gn/secondary/clang/unittests/Sema/BUILD.gn
llvm/trunk/utils/gn/secondary/clang/unittests/StaticAnalyzer/
llvm/trunk/utils/gn/secondary/clang/unittests/StaticAnalyzer/BUILD.gn
llvm/trunk/utils/gn/secondary/clang/unittests/Tooling/
llvm/trunk/utils/gn/secondary/clang/unittests/Tooling/BUILD.gn
llvm/trunk/utils/gn/secondary/clang/unittests/libclang/
llvm/trunk/utils/gn/secondary/clang/unittests/libclang/BUILD.gn
llvm/trunk/utils/gn/secondary/llvm/utils/unittest/unittest.gni
Modified:
llvm/trunk/utils/gn/build/BUILDCONFIG.gn
llvm/trunk/utils/gn/build/sync_source_lists_from_cmake.py
llvm/trunk/utils/gn/secondary/clang/test/BUILD.gn
llvm/trunk/utils/gn/secondary/lld/unittests/DriverTests/BUILD.gn
llvm/trunk/utils/gn/secondary/lld/unittests/MachOTests/BUILD.gn
Modified: llvm/trunk/utils/gn/build/BUILDCONFIG.gn
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/build/BUILDCONFIG.gn?rev=350171&r1=350170&r2=350171&view=diff
==============================================================================
--- llvm/trunk/utils/gn/build/BUILDCONFIG.gn (original)
+++ llvm/trunk/utils/gn/build/BUILDCONFIG.gn Sun Dec 30 16:10:47 2018
@@ -2,7 +2,7 @@
# Targets can opt out of a config by removing it from their local configs list.
# If you're adding global flags and don't need targets to be able to opt out,
# add the flags to compiler_defaults, not to a new config.
-_shared_binary_target_configs = [
+shared_binary_target_configs = [
"//llvm/utils/gn/build:compiler_defaults",
"//llvm/utils/gn/build:llvm_code",
"//llvm/utils/gn/build:warn_covered_switch_default",
@@ -10,19 +10,19 @@ _shared_binary_target_configs = [
# Apply that default list to the binary target types.
set_defaults("executable") {
- configs = _shared_binary_target_configs
+ configs = shared_binary_target_configs
}
set_defaults("loadable_module") {
- configs = _shared_binary_target_configs
+ configs = shared_binary_target_configs
}
set_defaults("static_library") {
- configs = _shared_binary_target_configs
+ configs = shared_binary_target_configs
}
set_defaults("shared_library") {
- configs = _shared_binary_target_configs
+ configs = shared_binary_target_configs
}
set_defaults("source_set") {
- configs = _shared_binary_target_configs
+ configs = shared_binary_target_configs
}
if (host_os == "win") {
Modified: llvm/trunk/utils/gn/build/sync_source_lists_from_cmake.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/build/sync_source_lists_from_cmake.py?rev=350171&r1=350170&r2=350171&view=diff
==============================================================================
--- llvm/trunk/utils/gn/build/sync_source_lists_from_cmake.py (original)
+++ llvm/trunk/utils/gn/build/sync_source_lists_from_cmake.py Sun Dec 30 16:10:47 2018
@@ -4,7 +4,11 @@
For each BUILD.gn file in the tree, checks if the list of cpp files in
it is identical to the list of cpp files in the corresponding CMakeLists.txt
-file, and prints the difference if not."""
+file, and prints the difference if not.
+
+Also checks that each CMakeLists.txt file below unittests/ folders that define
+binaries have corresponding BUILD.gn files.
+"""
from __future__ import print_function
@@ -12,7 +16,8 @@ import os
import re
import subprocess
-def main():
+
+def sync_source_lists():
gn_files = subprocess.check_output(
['git', 'ls-files', '*BUILD.gn']).splitlines()
@@ -50,5 +55,24 @@ def main():
print('remove:\n' + '\n'.join(remove))
print()
+
+def sync_unittests():
+ checked = [ 'clang', 'lld' ]
+ for c in checked:
+ for root, _, _ in os.walk(os.path.join(c, 'unittests')):
+ cmake_file = os.path.join(root, 'CMakeLists.txt')
+ if not os.path.exists(cmake_file):
+ continue
+ gn_file = os.path.join('llvm/utils/gn/secondary', root, 'BUILD.gn')
+ if not os.path.exists(gn_file):
+ print('missing GN file %s for unittest CMake file %s' %
+ (gn_file, cmake_file))
+
+
+def main():
+ sync_source_lists()
+ sync_unittests()
+
+
if __name__ == '__main__':
main()
Added: llvm/trunk/utils/gn/secondary/clang/lib/ASTMatchers/Dynamic/BUILD.gn
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/secondary/clang/lib/ASTMatchers/Dynamic/BUILD.gn?rev=350171&view=auto
==============================================================================
--- llvm/trunk/utils/gn/secondary/clang/lib/ASTMatchers/Dynamic/BUILD.gn (added)
+++ llvm/trunk/utils/gn/secondary/clang/lib/ASTMatchers/Dynamic/BUILD.gn Sun Dec 30 16:10:47 2018
@@ -0,0 +1,16 @@
+static_library("Dynamic") {
+ output_name = "clangDynamicASTMatchers"
+ configs += [ "//llvm/utils/gn/build:clang_code" ]
+ deps = [
+ "//clang/lib/AST",
+ "//clang/lib/ASTMatchers",
+ "//clang/lib/Basic",
+ "//llvm/lib/Support",
+ ]
+ sources = [
+ "Diagnostics.cpp",
+ "Parser.cpp",
+ "Registry.cpp",
+ "VariantValue.cpp",
+ ]
+}
Modified: llvm/trunk/utils/gn/secondary/clang/test/BUILD.gn
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/secondary/clang/test/BUILD.gn?rev=350171&r1=350170&r2=350171&view=diff
==============================================================================
--- llvm/trunk/utils/gn/secondary/clang/test/BUILD.gn (original)
+++ llvm/trunk/utils/gn/secondary/clang/test/BUILD.gn Sun Dec 30 16:10:47 2018
@@ -125,6 +125,7 @@ group("test") {
"//clang/tools/clang-rename",
"//clang/tools/diagtool",
"//clang/tools/driver:symlinks",
+ "//clang/unittests",
"//clang/utils/TableGen:clang-tblgen",
"//clang/utils/hmaptool",
"//llvm/tools/llc",
@@ -159,7 +160,6 @@ group("test") {
]
}
- # FIXME: dep on "//clang/unittests" once it exists
# FIXME: clang_build_examples
testonly = true
}
Added: llvm/trunk/utils/gn/secondary/clang/unittests/AST/BUILD.gn
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/secondary/clang/unittests/AST/BUILD.gn?rev=350171&view=auto
==============================================================================
--- llvm/trunk/utils/gn/secondary/clang/unittests/AST/BUILD.gn (added)
+++ llvm/trunk/utils/gn/secondary/clang/unittests/AST/BUILD.gn Sun Dec 30 16:10:47 2018
@@ -0,0 +1,33 @@
+import("//llvm/utils/unittest/unittest.gni")
+
+unittest("ASTTests") {
+ configs += [ "//llvm/utils/gn/build:clang_code" ]
+ deps = [
+ "//clang/lib/AST",
+ "//clang/lib/ASTMatchers",
+ "//clang/lib/Analysis",
+ "//clang/lib/Basic",
+ "//clang/lib/Frontend",
+ "//clang/lib/Tooling",
+ "//llvm/lib/Support",
+ ]
+ sources = [
+ "ASTContextParentMapTest.cpp",
+ "ASTImporterTest.cpp",
+ "ASTTypeTraitsTest.cpp",
+ "ASTVectorTest.cpp",
+ "CommentLexer.cpp",
+ "CommentParser.cpp",
+ "CommentTextTest.cpp",
+ "DataCollectionTest.cpp",
+ "DeclPrinterTest.cpp",
+ "DeclTest.cpp",
+ "EvaluateAsRValueTest.cpp",
+ "ExternalASTSourceTest.cpp",
+ "Language.cpp",
+ "NamedDeclPrinterTest.cpp",
+ "SourceLocationTest.cpp",
+ "StmtPrinterTest.cpp",
+ "StructuralEquivalenceTest.cpp",
+ ]
+}
Added: llvm/trunk/utils/gn/secondary/clang/unittests/ASTMatchers/BUILD.gn
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/secondary/clang/unittests/ASTMatchers/BUILD.gn?rev=350171&view=auto
==============================================================================
--- llvm/trunk/utils/gn/secondary/clang/unittests/ASTMatchers/BUILD.gn (added)
+++ llvm/trunk/utils/gn/secondary/clang/unittests/ASTMatchers/BUILD.gn Sun Dec 30 16:10:47 2018
@@ -0,0 +1,19 @@
+import("//llvm/utils/unittest/unittest.gni")
+
+unittest("ASTMatchersTests") {
+ configs += [ "//llvm/utils/gn/build:clang_code" ]
+ deps = [
+ "//clang/lib/AST",
+ "//clang/lib/ASTMatchers",
+ "//clang/lib/Basic",
+ "//clang/lib/Frontend",
+ "//clang/lib/Tooling",
+ "//llvm/lib/Support",
+ ]
+ sources = [
+ "ASTMatchersInternalTest.cpp",
+ "ASTMatchersNarrowingTest.cpp",
+ "ASTMatchersNodeTest.cpp",
+ "ASTMatchersTraversalTest.cpp",
+ ]
+}
Added: llvm/trunk/utils/gn/secondary/clang/unittests/ASTMatchers/Dynamic/BUILD.gn
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/secondary/clang/unittests/ASTMatchers/Dynamic/BUILD.gn?rev=350171&view=auto
==============================================================================
--- llvm/trunk/utils/gn/secondary/clang/unittests/ASTMatchers/Dynamic/BUILD.gn (added)
+++ llvm/trunk/utils/gn/secondary/clang/unittests/ASTMatchers/Dynamic/BUILD.gn Sun Dec 30 16:10:47 2018
@@ -0,0 +1,19 @@
+import("//llvm/utils/unittest/unittest.gni")
+
+unittest("DynamicASTMatchersTests") {
+ configs += [ "//llvm/utils/gn/build:clang_code" ]
+ deps = [
+ "//clang/lib/AST",
+ "//clang/lib/ASTMatchers",
+ "//clang/lib/ASTMatchers/Dynamic",
+ "//clang/lib/Basic",
+ "//clang/lib/Frontend",
+ "//clang/lib/Tooling",
+ "//llvm/lib/Support",
+ ]
+ sources = [
+ "ParserTest.cpp",
+ "RegistryTest.cpp",
+ "VariantValueTest.cpp",
+ ]
+}
Added: llvm/trunk/utils/gn/secondary/clang/unittests/Analysis/BUILD.gn
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/secondary/clang/unittests/Analysis/BUILD.gn?rev=350171&view=auto
==============================================================================
--- llvm/trunk/utils/gn/secondary/clang/unittests/Analysis/BUILD.gn (added)
+++ llvm/trunk/utils/gn/secondary/clang/unittests/Analysis/BUILD.gn Sun Dec 30 16:10:47 2018
@@ -0,0 +1,19 @@
+import("//llvm/utils/unittest/unittest.gni")
+
+unittest("ClangAnalysisTests") {
+ configs += [ "//llvm/utils/gn/build:clang_code" ]
+ deps = [
+ "//clang/lib/AST",
+ "//clang/lib/ASTMatchers",
+ "//clang/lib/Analysis",
+ "//clang/lib/Basic",
+ "//clang/lib/Frontend",
+ "//clang/lib/Tooling",
+ "//llvm/lib/Support",
+ ]
+ sources = [
+ "CFGTest.cpp",
+ "CloneDetectionTest.cpp",
+ "ExprMutationAnalyzerTest.cpp",
+ ]
+}
Added: llvm/trunk/utils/gn/secondary/clang/unittests/BUILD.gn
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/secondary/clang/unittests/BUILD.gn?rev=350171&view=auto
==============================================================================
--- llvm/trunk/utils/gn/secondary/clang/unittests/BUILD.gn (added)
+++ llvm/trunk/utils/gn/secondary/clang/unittests/BUILD.gn Sun Dec 30 16:10:47 2018
@@ -0,0 +1,35 @@
+import("//clang/lib/StaticAnalyzer/Frontend/enable.gni")
+
+group("unittests") {
+ deps = [
+ "AST:ASTTests",
+ "ASTMatchers:ASTMatchersTests",
+ "ASTMatchers/Dynamic:DynamicASTMatchersTests",
+ "Basic:BasicTests",
+ "CodeGen:ClangCodeGenTests",
+ "CrossTU:CrossTUTests",
+ "Driver:ClangDriverTests",
+ "Format:FormatTests",
+ "Index:IndexTests",
+ "Lex:LexTests",
+ "Rename:ClangRenameTests",
+ "Rewrite:RewriteTests",
+ "Sema:SemaTests",
+ "Tooling:ToolingTests",
+ ]
+ if (clang_enable_static_analyzer) {
+ deps += [
+ "Analysis:ClangAnalysisTests",
+ "Frontend:FrontendTests",
+ "StaticAnalyzer:StaticAnalysisTests",
+ ]
+ }
+ if (host_os != "win") {
+ # FIXME: libclang unit tests are disabled on Windows due
+ # to failures, mostly in libclang.VirtualFileOverlay_*.
+ # FIXME: Also, the executable can't find libclang.dll since that's
+ # in a different directory.
+ deps += [ "libclang:libclangTests" ]
+ }
+ testonly = true
+}
Added: llvm/trunk/utils/gn/secondary/clang/unittests/Basic/BUILD.gn
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/secondary/clang/unittests/Basic/BUILD.gn?rev=350171&view=auto
==============================================================================
--- llvm/trunk/utils/gn/secondary/clang/unittests/Basic/BUILD.gn (added)
+++ llvm/trunk/utils/gn/secondary/clang/unittests/Basic/BUILD.gn Sun Dec 30 16:10:47 2018
@@ -0,0 +1,18 @@
+import("//llvm/utils/unittest/unittest.gni")
+
+unittest("BasicTests") {
+ configs += [ "//llvm/utils/gn/build:clang_code" ]
+ deps = [
+ "//clang/lib/Basic",
+ "//clang/lib/Lex",
+ "//llvm/lib/Support",
+ ]
+ sources = [
+ "CharInfoTest.cpp",
+ "DiagnosticTest.cpp",
+ "FileManagerTest.cpp",
+ "FixedPointTest.cpp",
+ "MemoryBufferCacheTest.cpp",
+ "SourceManagerTest.cpp",
+ ]
+}
Added: llvm/trunk/utils/gn/secondary/clang/unittests/CodeGen/BUILD.gn
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/secondary/clang/unittests/CodeGen/BUILD.gn?rev=350171&view=auto
==============================================================================
--- llvm/trunk/utils/gn/secondary/clang/unittests/CodeGen/BUILD.gn (added)
+++ llvm/trunk/utils/gn/secondary/clang/unittests/CodeGen/BUILD.gn Sun Dec 30 16:10:47 2018
@@ -0,0 +1,21 @@
+import("//llvm/utils/unittest/unittest.gni")
+
+unittest("ClangCodeGenTests") {
+ configs += [ "//llvm/utils/gn/build:clang_code" ]
+ deps = [
+ "//clang/lib/AST",
+ "//clang/lib/Basic",
+ "//clang/lib/CodeGen",
+ "//clang/lib/Frontend",
+ "//clang/lib/Lex",
+ "//clang/lib/Parse",
+ "//llvm/lib/IR",
+ "//llvm/lib/Support",
+ ]
+ sources = [
+ "BufferSourceTest.cpp",
+ "CodeGenExternalTest.cpp",
+ "IncrementalProcessingTest.cpp",
+ "TBAAMetadataTest.cpp",
+ ]
+}
Added: llvm/trunk/utils/gn/secondary/clang/unittests/CrossTU/BUILD.gn
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/secondary/clang/unittests/CrossTU/BUILD.gn?rev=350171&view=auto
==============================================================================
--- llvm/trunk/utils/gn/secondary/clang/unittests/CrossTU/BUILD.gn (added)
+++ llvm/trunk/utils/gn/secondary/clang/unittests/CrossTU/BUILD.gn Sun Dec 30 16:10:47 2018
@@ -0,0 +1,17 @@
+import("//llvm/utils/unittest/unittest.gni")
+
+unittest("CrossTUTests") {
+ configs += [ "//llvm/utils/gn/build:clang_code" ]
+ deps = [
+ "//clang/lib/AST",
+ "//clang/lib/Basic",
+ "//clang/lib/CrossTU",
+ "//clang/lib/Frontend",
+ "//clang/lib/Tooling",
+ "//llvm/lib/Support",
+ "//llvm/lib/Target:TargetsToBuild",
+ ]
+ sources = [
+ "CrossTranslationUnitTest.cpp",
+ ]
+}
Added: llvm/trunk/utils/gn/secondary/clang/unittests/Driver/BUILD.gn
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/secondary/clang/unittests/Driver/BUILD.gn?rev=350171&view=auto
==============================================================================
--- llvm/trunk/utils/gn/secondary/clang/unittests/Driver/BUILD.gn (added)
+++ llvm/trunk/utils/gn/secondary/clang/unittests/Driver/BUILD.gn Sun Dec 30 16:10:47 2018
@@ -0,0 +1,18 @@
+import("//llvm/utils/unittest/unittest.gni")
+
+unittest("ClangDriverTests") {
+ configs += [ "//llvm/utils/gn/build:clang_code" ]
+ deps = [
+ "//clang/lib/Basic",
+ "//clang/lib/Driver",
+ "//llvm/lib/Option",
+ "//llvm/lib/Support",
+ "//llvm/lib/Target:TargetsToBuild",
+ ]
+ sources = [
+ "DistroTest.cpp",
+ "ModuleCacheTest.cpp",
+ "MultilibTest.cpp",
+ "ToolChainTest.cpp",
+ ]
+}
Added: llvm/trunk/utils/gn/secondary/clang/unittests/Format/BUILD.gn
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/secondary/clang/unittests/Format/BUILD.gn?rev=350171&view=auto
==============================================================================
--- llvm/trunk/utils/gn/secondary/clang/unittests/Format/BUILD.gn (added)
+++ llvm/trunk/utils/gn/secondary/clang/unittests/Format/BUILD.gn Sun Dec 30 16:10:47 2018
@@ -0,0 +1,31 @@
+import("//llvm/utils/unittest/unittest.gni")
+
+unittest("FormatTests") {
+ configs += [ "//llvm/utils/gn/build:clang_code" ]
+ deps = [
+ "//clang/lib/Basic",
+ "//clang/lib/Format",
+ "//clang/lib/Frontend",
+ "//clang/lib/Rewrite",
+ "//clang/lib/Tooling/Core",
+ "//llvm/lib/Support",
+ ]
+ sources = [
+ "CleanupTest.cpp",
+ "FormatTest.cpp",
+ "FormatTestComments.cpp",
+ "FormatTestJS.cpp",
+ "FormatTestJava.cpp",
+ "FormatTestObjC.cpp",
+ "FormatTestProto.cpp",
+ "FormatTestRawStrings.cpp",
+ "FormatTestSelective.cpp",
+ "FormatTestTableGen.cpp",
+ "FormatTestTextProto.cpp",
+ "NamespaceEndCommentsFixerTest.cpp",
+ "SortImportsTestJS.cpp",
+ "SortImportsTestJava.cpp",
+ "SortIncludesTest.cpp",
+ "UsingDeclarationsSorterTest.cpp",
+ ]
+}
Added: llvm/trunk/utils/gn/secondary/clang/unittests/Frontend/BUILD.gn
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/secondary/clang/unittests/Frontend/BUILD.gn?rev=350171&view=auto
==============================================================================
--- llvm/trunk/utils/gn/secondary/clang/unittests/Frontend/BUILD.gn (added)
+++ llvm/trunk/utils/gn/secondary/clang/unittests/Frontend/BUILD.gn Sun Dec 30 16:10:47 2018
@@ -0,0 +1,25 @@
+import("//llvm/utils/unittest/unittest.gni")
+
+unittest("FrontendTests") {
+ configs += [ "//llvm/utils/gn/build:clang_code" ]
+ deps = [
+ "//clang/lib/AST",
+ "//clang/lib/Basic",
+ "//clang/lib/CodeGen",
+ "//clang/lib/Frontend",
+ "//clang/lib/FrontendTool",
+ "//clang/lib/Lex",
+ "//clang/lib/Sema",
+ "//llvm/lib/Support",
+ ]
+ sources = [
+ "ASTUnitTest.cpp",
+ "CodeGenActionTest.cpp",
+ "CompilerInstanceTest.cpp",
+ "FixedPointString.cpp",
+ "FrontendActionTest.cpp",
+ "OutputStreamTest.cpp",
+ "PCHPreambleTest.cpp",
+ "ParsedSourceLocationTest.cpp",
+ ]
+}
Added: llvm/trunk/utils/gn/secondary/clang/unittests/Index/BUILD.gn
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/secondary/clang/unittests/Index/BUILD.gn?rev=350171&view=auto
==============================================================================
--- llvm/trunk/utils/gn/secondary/clang/unittests/Index/BUILD.gn (added)
+++ llvm/trunk/utils/gn/secondary/clang/unittests/Index/BUILD.gn Sun Dec 30 16:10:47 2018
@@ -0,0 +1,18 @@
+import("//llvm/utils/unittest/unittest.gni")
+
+unittest("IndexTests") {
+ configs += [ "//llvm/utils/gn/build:clang_code" ]
+ deps = [
+ "//clang/lib/AST",
+ "//clang/lib/Basic",
+ "//clang/lib/Frontend",
+ "//clang/lib/Index",
+ "//clang/lib/Lex",
+ "//clang/lib/Serialization",
+ "//clang/lib/Tooling",
+ "//llvm/lib/Support",
+ ]
+ sources = [
+ "IndexTests.cpp",
+ ]
+}
Added: llvm/trunk/utils/gn/secondary/clang/unittests/Lex/BUILD.gn
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/secondary/clang/unittests/Lex/BUILD.gn?rev=350171&view=auto
==============================================================================
--- llvm/trunk/utils/gn/secondary/clang/unittests/Lex/BUILD.gn (added)
+++ llvm/trunk/utils/gn/secondary/clang/unittests/Lex/BUILD.gn Sun Dec 30 16:10:47 2018
@@ -0,0 +1,20 @@
+import("//llvm/utils/unittest/unittest.gni")
+
+unittest("LexTests") {
+ configs += [ "//llvm/utils/gn/build:clang_code" ]
+ deps = [
+ "//clang/lib/AST",
+ "//clang/lib/Basic",
+ "//clang/lib/Lex",
+ "//clang/lib/Parse",
+ "//clang/lib/Sema",
+ "//llvm/lib/Support",
+ ]
+ sources = [
+ "HeaderMapTest.cpp",
+ "HeaderSearchTest.cpp",
+ "LexerTest.cpp",
+ "PPCallbacksTest.cpp",
+ "PPConditionalDirectiveRecordTest.cpp",
+ ]
+}
Added: llvm/trunk/utils/gn/secondary/clang/unittests/Rename/BUILD.gn
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/secondary/clang/unittests/Rename/BUILD.gn?rev=350171&view=auto
==============================================================================
--- llvm/trunk/utils/gn/secondary/clang/unittests/Rename/BUILD.gn (added)
+++ llvm/trunk/utils/gn/secondary/clang/unittests/Rename/BUILD.gn Sun Dec 30 16:10:47 2018
@@ -0,0 +1,28 @@
+import("//llvm/utils/unittest/unittest.gni")
+
+unittest("ClangRenameTests") {
+ configs += [ "//llvm/utils/gn/build:clang_code" ]
+
+ # We'd like clang/unittests/Tooling/RewriterTestContext.h in the test.
+ include_dirs = [ "../.." ]
+
+ deps = [
+ "//clang/lib/AST",
+ "//clang/lib/ASTMatchers",
+ "//clang/lib/Basic",
+ "//clang/lib/Format",
+ "//clang/lib/Frontend",
+ "//clang/lib/Rewrite",
+ "//clang/lib/Tooling",
+ "//clang/lib/Tooling/Core",
+ "//clang/lib/Tooling/Refactoring",
+ "//llvm/lib/Support",
+ ]
+ sources = [
+ "RenameAliasTest.cpp",
+ "RenameClassTest.cpp",
+ "RenameEnumTest.cpp",
+ "RenameFunctionTest.cpp",
+ "RenameMemberTest.cpp",
+ ]
+}
Added: llvm/trunk/utils/gn/secondary/clang/unittests/Rewrite/BUILD.gn
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/secondary/clang/unittests/Rewrite/BUILD.gn?rev=350171&view=auto
==============================================================================
--- llvm/trunk/utils/gn/secondary/clang/unittests/Rewrite/BUILD.gn (added)
+++ llvm/trunk/utils/gn/secondary/clang/unittests/Rewrite/BUILD.gn Sun Dec 30 16:10:47 2018
@@ -0,0 +1,12 @@
+import("//llvm/utils/unittest/unittest.gni")
+
+unittest("RewriteTests") {
+ configs += [ "//llvm/utils/gn/build:clang_code" ]
+ deps = [
+ "//clang/lib/Rewrite",
+ "//llvm/lib/Support",
+ ]
+ sources = [
+ "RewriteBufferTest.cpp",
+ ]
+}
Added: llvm/trunk/utils/gn/secondary/clang/unittests/Sema/BUILD.gn
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/secondary/clang/unittests/Sema/BUILD.gn?rev=350171&view=auto
==============================================================================
--- llvm/trunk/utils/gn/secondary/clang/unittests/Sema/BUILD.gn (added)
+++ llvm/trunk/utils/gn/secondary/clang/unittests/Sema/BUILD.gn Sun Dec 30 16:10:47 2018
@@ -0,0 +1,18 @@
+import("//llvm/utils/unittest/unittest.gni")
+
+unittest("SemaTests") {
+ configs += [ "//llvm/utils/gn/build:clang_code" ]
+ deps = [
+ "//clang/lib/AST",
+ "//clang/lib/Basic",
+ "//clang/lib/Frontend",
+ "//clang/lib/Parse",
+ "//clang/lib/Sema",
+ "//clang/lib/Tooling",
+ "//llvm/lib/Support",
+ ]
+ sources = [
+ "CodeCompleteTest.cpp",
+ "ExternalSemaSourceTest.cpp",
+ ]
+}
Added: llvm/trunk/utils/gn/secondary/clang/unittests/StaticAnalyzer/BUILD.gn
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/secondary/clang/unittests/StaticAnalyzer/BUILD.gn?rev=350171&view=auto
==============================================================================
--- llvm/trunk/utils/gn/secondary/clang/unittests/StaticAnalyzer/BUILD.gn (added)
+++ llvm/trunk/utils/gn/secondary/clang/unittests/StaticAnalyzer/BUILD.gn Sun Dec 30 16:10:47 2018
@@ -0,0 +1,17 @@
+import("//llvm/utils/unittest/unittest.gni")
+
+unittest("StaticAnalysisTests") {
+ configs += [ "//llvm/utils/gn/build:clang_code" ]
+ deps = [
+ "//clang/lib/Analysis",
+ "//clang/lib/Basic",
+ "//clang/lib/StaticAnalyzer/Core",
+ "//clang/lib/StaticAnalyzer/Frontend",
+ "//clang/lib/Tooling",
+ "//llvm/lib/Support",
+ ]
+ sources = [
+ "AnalyzerOptionsTest.cpp",
+ "RegisterCustomCheckersTest.cpp",
+ ]
+}
Added: llvm/trunk/utils/gn/secondary/clang/unittests/Tooling/BUILD.gn
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/secondary/clang/unittests/Tooling/BUILD.gn?rev=350171&view=auto
==============================================================================
--- llvm/trunk/utils/gn/secondary/clang/unittests/Tooling/BUILD.gn (added)
+++ llvm/trunk/utils/gn/secondary/clang/unittests/Tooling/BUILD.gn Sun Dec 30 16:10:47 2018
@@ -0,0 +1,61 @@
+import("//llvm/utils/unittest/unittest.gni")
+
+unittest("ToolingTests") {
+ configs += [ "//llvm/utils/gn/build:clang_code" ]
+ include_dirs = [ "." ]
+ deps = [
+ "//clang/lib/AST",
+ "//clang/lib/ASTMatchers",
+ "//clang/lib/Basic",
+ "//clang/lib/Format",
+ "//clang/lib/Frontend",
+ "//clang/lib/Lex",
+ "//clang/lib/Rewrite",
+ "//clang/lib/Tooling",
+ "//clang/lib/Tooling/Core",
+ "//clang/lib/Tooling/Refactoring",
+ "//llvm/lib/Support",
+ "//llvm/lib/Target:TargetsToBuild",
+ ]
+ sources = [
+ "ASTSelectionTest.cpp",
+ "CastExprTest.cpp",
+ "CommentHandlerTest.cpp",
+ "CompilationDatabaseTest.cpp",
+ "DiagnosticsYamlTest.cpp",
+ "ExecutionTest.cpp",
+ "FixItTest.cpp",
+ "HeaderIncludesTest.cpp",
+ "LexicallyOrderedRecursiveASTVisitorTest.cpp",
+ "LookupTest.cpp",
+ "QualTypeNamesTest.cpp",
+ "RecursiveASTVisitorTestDeclVisitor.cpp",
+ "RecursiveASTVisitorTestPostOrderVisitor.cpp",
+ "RecursiveASTVisitorTestTypeLocVisitor.cpp",
+ "RecursiveASTVisitorTests/Attr.cpp",
+ "RecursiveASTVisitorTests/CXXBoolLiteralExpr.cpp",
+ "RecursiveASTVisitorTests/CXXMemberCall.cpp",
+ "RecursiveASTVisitorTests/CXXOperatorCallExprTraverser.cpp",
+ "RecursiveASTVisitorTests/Class.cpp",
+ "RecursiveASTVisitorTests/ConstructExpr.cpp",
+ "RecursiveASTVisitorTests/DeclRefExpr.cpp",
+ "RecursiveASTVisitorTests/ImplicitCtor.cpp",
+ "RecursiveASTVisitorTests/InitListExprPostOrder.cpp",
+ "RecursiveASTVisitorTests/InitListExprPostOrderNoQueue.cpp",
+ "RecursiveASTVisitorTests/InitListExprPreOrder.cpp",
+ "RecursiveASTVisitorTests/InitListExprPreOrderNoQueue.cpp",
+ "RecursiveASTVisitorTests/IntegerLiteral.cpp",
+ "RecursiveASTVisitorTests/LambdaDefaultCapture.cpp",
+ "RecursiveASTVisitorTests/LambdaExpr.cpp",
+ "RecursiveASTVisitorTests/NestedNameSpecifiers.cpp",
+ "RecursiveASTVisitorTests/ParenExpr.cpp",
+ "RecursiveASTVisitorTests/TemplateArgumentLocTraverser.cpp",
+ "RecursiveASTVisitorTests/TraversalScope.cpp",
+ "RefactoringActionRulesTest.cpp",
+ "RefactoringCallbacksTest.cpp",
+ "RefactoringTest.cpp",
+ "ReplacementsYamlTest.cpp",
+ "RewriterTest.cpp",
+ "ToolingTest.cpp",
+ ]
+}
Added: llvm/trunk/utils/gn/secondary/clang/unittests/libclang/BUILD.gn
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/secondary/clang/unittests/libclang/BUILD.gn?rev=350171&view=auto
==============================================================================
--- llvm/trunk/utils/gn/secondary/clang/unittests/libclang/BUILD.gn (added)
+++ llvm/trunk/utils/gn/secondary/clang/unittests/libclang/BUILD.gn Sun Dec 30 16:10:47 2018
@@ -0,0 +1,14 @@
+import("//llvm/utils/unittest/unittest.gni")
+
+unittest("libclangTests") {
+ configs += [ "//llvm/utils/gn/build:clang_code" ]
+ deps = [
+ "//clang/tools/libclang",
+ ]
+ sources = [
+ "LibclangTest.cpp",
+ ]
+ if (host_os == "mac") {
+ ldflags = [ "-Wl,-rpath," + rebase_path("$root_out_dir/lib") ]
+ }
+}
Modified: llvm/trunk/utils/gn/secondary/lld/unittests/DriverTests/BUILD.gn
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/secondary/lld/unittests/DriverTests/BUILD.gn?rev=350171&r1=350170&r2=350171&view=diff
==============================================================================
--- llvm/trunk/utils/gn/secondary/lld/unittests/DriverTests/BUILD.gn (original)
+++ llvm/trunk/utils/gn/secondary/lld/unittests/DriverTests/BUILD.gn Sun Dec 30 16:10:47 2018
@@ -1,15 +1,12 @@
-executable("DriverTests") {
- # test/Unit/lit.cfg expects unittests in LLD_BINARY_DIR/unittest
- output_dir = target_out_dir
+import("//llvm/utils/unittest/unittest.gni")
+unittest("DriverTests") {
configs += [ "//llvm/utils/gn/build:lld_code" ]
deps = [
"//lld/lib/Driver",
"//lld/lib/ReaderWriter/MachO",
- "//llvm/utils/unittest/UnitTestMain",
]
sources = [
"DarwinLdDriverTest.cpp",
]
- testonly = true
}
Modified: llvm/trunk/utils/gn/secondary/lld/unittests/MachOTests/BUILD.gn
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/secondary/lld/unittests/MachOTests/BUILD.gn?rev=350171&r1=350170&r2=350171&view=diff
==============================================================================
--- llvm/trunk/utils/gn/secondary/lld/unittests/MachOTests/BUILD.gn (original)
+++ llvm/trunk/utils/gn/secondary/lld/unittests/MachOTests/BUILD.gn Sun Dec 30 16:10:47 2018
@@ -1,13 +1,11 @@
-executable("MachOTests") {
- # test/Unit/lit.cfg expects unittests in LLD_BINARY_DIR/unittest
- output_dir = target_out_dir
+import("//llvm/utils/unittest/unittest.gni")
+unittest("MachOTests") {
configs += [ "//llvm/utils/gn/build:lld_code" ]
deps = [
"//lld/lib/Driver",
"//lld/lib/ReaderWriter/MachO",
"//lld/lib/ReaderWriter/YAML",
- "//llvm/utils/unittest/UnitTestMain",
]
sources = [
"MachONormalizedFileBinaryReaderTests.cpp",
@@ -15,5 +13,4 @@ executable("MachOTests") {
"MachONormalizedFileToAtomsTests.cpp",
"MachONormalizedFileYAMLTests.cpp",
]
- testonly = true
}
Added: llvm/trunk/utils/gn/secondary/llvm/utils/unittest/unittest.gni
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/secondary/llvm/utils/unittest/unittest.gni?rev=350171&view=auto
==============================================================================
--- llvm/trunk/utils/gn/secondary/llvm/utils/unittest/unittest.gni (added)
+++ llvm/trunk/utils/gn/secondary/llvm/utils/unittest/unittest.gni Sun Dec 30 16:10:47 2018
@@ -0,0 +1,44 @@
+# This file defines a template for adding a unittest binary.
+#
+# It's a thin wrapper around GN's built-in executable() target type and
+# accepts the same parameters.
+#
+# Example use:
+#
+# unittest("FormatTest") {
+# sources = [ ... ]
+# ...
+# }
+
+template("unittest") {
+ executable(target_name) {
+ # Foward everything (configs, sources, deps, ...).
+ forward_variables_from(invoker, "*")
+ assert(!defined(invoker.output_dir), "cannot set unittest output_dir")
+ assert(!defined(invoker.testonly), "cannot set unittest testonly")
+
+ # Common settings for all unit tests.
+ # Unit test binaries shouldn't go right in out/gn/bin, for two reasons:
+ # 1. That's where production binaries go.
+ # 2. The CMake build doesn't put the unit tests of all projects (clang,
+ # lld,...) in one directory, so it's not guaranteed that there won't
+ # be name collisions between test binaries from separate projects.
+ # Each lit suite takes an foo_obj_root parameter and puts temporary files
+ # for lit tests at foo_obj_root/test and looks for unit test binaries
+ # below foo_obj_root/unittests. As long as the BUILD.gn files processing
+ # the lit.site.cfg.py.in files match the output dir here, it doesn't
+ # matter all that much where the unit test binaries go, with the weak
+ # constraints that test binaries of different projects should go in
+ # different folders, and that it's not too difficult to manually
+ # run the unit test binary if necessary. Using target_out_dir here
+ # means that //clang/unittests/Format gets its binary in
+ # out/gn/obj/clang/unittests/Format/FormatTests, which seems fine.
+ output_dir = target_out_dir
+ deps += [ "//llvm/utils/unittest/UnitTestMain" ]
+ testonly = true
+ }
+}
+
+set_defaults("unittest") {
+ configs = shared_binary_target_configs
+}
More information about the llvm-commits
mailing list