Skip to content

Commit

Permalink
support clippy aspect in unit tests as well
Browse files Browse the repository at this point in the history
Unit tests with a 'crate = ...' argument have no rust_srcs, so
clippy was not running for them.
  • Loading branch information
dae committed Dec 30, 2020
1 parent c7a408a commit 0c25a25
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions rust/private/clippy.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,17 @@ def _clippy_aspect_impl(target, ctx):
if CrateInfo not in target:
return []
rust_srcs = _rust_sources(target, ctx.rule)
if rust_srcs == []:
return []

toolchain = find_toolchain(ctx)
crate_info = target[CrateInfo]
root = crate_root_src(ctx.rule.attr, rust_srcs, crate_info.type)

if crate_info.is_test:
root = crate_info.root
else:
if rust_srcs == []:
# nothing to do
return []
root = crate_root_src(ctx.rule.attr, rust_srcs, crate_info.type)

dep_info, build_info = collect_deps(
ctx.label,
Expand Down

0 comments on commit 0c25a25

Please sign in to comment.