Skip to content

Commit 6640dac

Browse files
authored
[bazel] Add include-cleaner tests (#111924)
1 parent 2647505 commit 6640dac

File tree

1 file changed

+70
-0
lines changed
  • utils/bazel/llvm-project-overlay/clang-tools-extra/include-cleaner

1 file changed

+70
-0
lines changed

utils/bazel/llvm-project-overlay/clang-tools-extra/include-cleaner/BUILD.bazel

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
# See https://llvm.org/LICENSE.txt for license information.
33
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
44

5+
load("@bazel_skylib//rules:expand_template.bzl", "expand_template")
56
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library")
7+
load("//llvm:lit_test.bzl", "lit_test", "package_path")
68

79
package(
810
default_visibility = ["//visibility:public"],
@@ -61,3 +63,71 @@ cc_binary(
6163
"//llvm:Support",
6264
],
6365
)
66+
67+
cc_test(
68+
name = "unittests",
69+
srcs = glob(["unittests/*.cpp"]),
70+
deps = [
71+
":include_cleaner",
72+
":include_cleaner_internal",
73+
"//clang:ast",
74+
"//clang:basic",
75+
"//clang:format",
76+
"//clang:frontend",
77+
"//clang:lex",
78+
"//clang:serialization",
79+
"//clang:testing",
80+
"//clang:tooling",
81+
"//clang:tooling_inclusions",
82+
"//llvm:Support",
83+
"//llvm:TestingAnnotations",
84+
"//third-party/unittest:gmock",
85+
"//third-party/unittest:gtest",
86+
],
87+
)
88+
89+
LLVM_LIT_PATH_FUNCTION = " " + \
90+
"# Allow generated file to be relocatable.\n" + \
91+
"from pathlib import Path\n" + \
92+
"def path(p):\n" + \
93+
" p = Path(p)\n" + \
94+
" if p.exists: return str(p.resolve())\n" + \
95+
" if not p: return ''\n" + \
96+
" return str((Path(__file__).parent / p).resolve())\n"
97+
98+
LIT_SITE_CFG_IN_HEADER = "# Autogenerated, do not edit." + LLVM_LIT_PATH_FUNCTION
99+
100+
expand_template(
101+
name = "lit_site_cfg_py",
102+
testonly = True,
103+
out = "test/lit.site.cfg.py",
104+
substitutions = {
105+
"@CMAKE_CURRENT_BINARY_DIR@": package_path("//clang-tools-extra/include-cleaner:BUILD") + "/test",
106+
"@CMAKE_CURRENT_SOURCE_DIR@": package_path("//clang-tools-extra/include-cleaner:BUILD") + "/test",
107+
"@CURRENT_TOOLS_DIR@": package_path("//clang-tools-extra/include-cleaner:BUILD"),
108+
"@LIT_SITE_CFG_IN_HEADER@": LIT_SITE_CFG_IN_HEADER,
109+
"@LLVM_LIBS_DIR@": package_path("//llvm:BUILD"),
110+
"@LLVM_LIT_TOOLS_DIR@": package_path("//llvm:BUILD"),
111+
"@LLVM_TOOLS_DIR@": package_path("//llvm:BUILD"),
112+
"@TARGET_TRIPLE@": "",
113+
'"@Python3_EXECUTABLE@"': "sys.executable",
114+
},
115+
template = "test/lit.site.cfg.py.in",
116+
)
117+
118+
[
119+
lit_test(
120+
name = "%s.test" % src,
121+
srcs = [src],
122+
data = glob(["test/Inputs/**/*"]) + [
123+
"test/lit.cfg.py",
124+
"test/lit.site.cfg.py",
125+
":clang-include-cleaner",
126+
"//llvm:FileCheck",
127+
"//llvm:count",
128+
"//llvm:not",
129+
],
130+
args = ["-svv"],
131+
)
132+
for src in glob(["test/*.cpp"])
133+
]

0 commit comments

Comments
 (0)