Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion command.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ def _command_impl(ctx):

expansion_targets = ctx.attr.data

env = {}
if RunEnvironmentInfo in command:
env.update(command[RunEnvironmentInfo].environment)
env.update(ctx.attr.environment)

str_env = [
"export %s=%s" % (
k,
Expand All @@ -63,7 +68,7 @@ def _command_impl(ctx):
targets = expansion_targets,
),
)
for k, v in ctx.attr.environment.items()
for k, v in env.items()
]
str_args = [
"%s" % _expand_and_quote(ctx = ctx, attr = "arguments", string = v, targets = expansion_targets)
Expand Down
6 changes: 6 additions & 0 deletions tests/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,11 @@ custom_executable(
name = "validate_custom_executable_rule_env",
)

command(
name = "command_custom_executable_rule_env",
command = ":validate_custom_executable_rule_env",
)

multirun(
name = "multirun_custom_executable_rule_env",
commands = [":validate_custom_executable_rule_env"],
Expand Down Expand Up @@ -265,6 +270,7 @@ sh_test(
name = "test",
srcs = ["test.sh"],
data = [
":command_custom_executable_rule_env",
":default_pwd_cmd",
":echo_and_fail_cmd",
":hello",
Expand Down
3 changes: 3 additions & 0 deletions tests/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ $script
script=$(rlocation rules_multirun/tests/multirun_custom_executable_rule_env.bash)
$script

script=$(rlocation rules_multirun/tests/command_custom_executable_rule_env.bash)
$script

script="$(rlocation rules_multirun/tests/multirun_parallel.bash)"
parallel_output="$($script)"
if [[ -n "$parallel_output" ]]; then
Expand Down