Skip to content

Commit 02144e3

Browse files
committed
Exclude test libraries from clang-tidy
1 parent 1daad06 commit 02144e3

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

cc/defs2.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ def swift_add_library(**kwargs):
298298

299299
is_test_library = level == "test"
300300

301-
kwargs["tags"] = [LIBRARY, "internal" if level == "test" else level] + (["portable"] if portable else []) + kwargs.get("tags", [])
301+
kwargs["tags"] = [LIBRARY, "internal" if level == "test" else level] + (["portable"] if portable else []) + kwargs.get("tags", []) + (["test_library"] if is_test_library else [])
302302
if level == "test":
303303
kwargs["target_compatible_with"] = kwargs.get("target_compatible_with", []) + _test_compatible_with()
304304
else:

clang_tidy/clang_tidy.bzl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
load("@bazel_tools//tools/build_defs/cc:action_names.bzl", "ACTION_NAMES")
22
load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain")
3-
load("//cc:defs.bzl", "BINARY", "LIBRARY")
3+
load("//cc:defs.bzl", "BINARY", "LIBRARY", "TEST_LIBRARY")
44
load("//cc_files:get_cc_files.bzl", "get_cc_srcs")
55

66
def _flatten(input_list):
@@ -150,6 +150,9 @@ def _clang_tidy_aspect_impl(target, ctx):
150150
if not LIBRARY in tags and not BINARY in tags:
151151
return []
152152

153+
if TEST_LIBRARY in tags:
154+
return []
155+
153156
srcs = get_cc_srcs(ctx)
154157

155158
wrapper = ctx.attr._clang_tidy_wrapper.files_to_run

0 commit comments

Comments
 (0)