Skip to content

Commit f212375

Browse files
authored
Merge all runfiles of @bazel_tools//tools/bash/runfiles (#489)
As `@bazel_tools//tools/bash/runfiles` is now an alias to `@rules_shell//shell/runfiles` with Bazel@HEAD, consumers must properly merge all its runfiles rather than assuming that the `sh_library` target just consists of a single file. Work towards bazelbuild/examples#557 (comment)
1 parent 15f3584 commit f212375

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lint/lint_test.bzl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ def _test_impl(ctx):
5858
bin = ctx.actions.declare_file("{}.lint_test.sh".format(ctx.label.name))
5959
asserts = [_write_assert(ctx, src[OutputGroupInfo].rules_lint_human) for src in ctx.attr.srcs]
6060

61+
runfiles = ctx.runfiles(transitive_files = depset(transitive = [src[OutputGroupInfo].rules_lint_human for src in ctx.attr.srcs]))
62+
runfiles = runfiles.merge(ctx.attr._runfiles_lib[DefaultInfo].default_runfiles)
63+
6164
ctx.actions.expand_template(
6265
template = ctx.file._bin,
6366
output = bin,
@@ -66,7 +69,7 @@ def _test_impl(ctx):
6669
)
6770
return [DefaultInfo(
6871
executable = bin,
69-
runfiles = ctx.runfiles([ctx.file._runfiles_lib], transitive_files = depset(transitive = [src[OutputGroupInfo].rules_lint_human for src in ctx.attr.srcs])),
72+
runfiles = runfiles,
7073
)]
7174

7275
def lint_test(aspect):
@@ -75,7 +78,7 @@ def lint_test(aspect):
7578
attrs = {
7679
"srcs": attr.label_list(doc = "*_library targets", aspects = [aspect]),
7780
"_bin": attr.label(default = ":lint_test.sh", allow_single_file = True, executable = True, cfg = "exec"),
78-
"_runfiles_lib": attr.label(default = "@bazel_tools//tools/bash/runfiles", allow_single_file = True),
81+
"_runfiles_lib": attr.label(default = "@bazel_tools//tools/bash/runfiles"),
7982
},
8083
test = True,
8184
)

0 commit comments

Comments
 (0)