Repository navigation
Closed
Description
Description of the problem / feature request:
Starting from bazel 0.27, a tags attribute on rule_test is not correctly taken into account when filtering with --build_tag_filters.
Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
Create a workspace, with an empty WORKSPACE and the following BUILD file:
load("@bazel_tools//tools/build_rules:test_rules.bzl", "rule_test")
cc_binary(
name = "bar",
srcs = ["foo.cpp"],
deps = ["@chien//:blip"],
tags = ["nop"],
)
rule_test(
name = "test-bar",
generates = ["toto"],
rule = ":bar",
tags = ["nop"],
)
Here, the rule bar is broken because it references @chien which does not exists. The associated rule_test test-bar is broken too, by definition. However both have a tags = ["nop"] attribute, so they should not be runned if filtered using --build_tag_filters=-nop.
It works as expected with bazel 0.26.1:
[nix-shell:~/tweag/rules_haskell/test_bazel027]$ bazel info release
release 0.26.1- (@non-git)
[nix-shell:~/tweag/rules_haskell/test_bazel027]$ bazel build //... --build_tag_filters=-nop
INFO: Analyzed 0 targets (1 packages loaded, 0 targets configured).
INFO: Found 0 targets...
INFO: Elapsed time: 0.077s, Critical Path: 0.00s
INFO: 0 processes.
INFO: Build completed successfully, 1 total action
But fails with bazel 0.27:
[nix-shell:~/tweag/rules_haskell/test_bazel027]$ bazel info release
Starting local Bazel server and connecting to it...
release 0.27.0- (@non-git)
[nix-shell:~/tweag/rules_haskell/test_bazel027]$ bazel build //... --build_tag_filters=-nop
ERROR: /home/guillaume/tweag/rules_haskell/test_bazel027/BUILD.bazel:3:1: no such package '@chien//': The repository '@chien' could not be resolved and referenced by '//:bar'
ERROR: Analysis of target '//:test-bar_impl' failed; build aborted: no such package '@chien//': The repository '@chien' could not be resolved
INFO: Elapsed time: 0.901s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (8 packages loaded, 28 targets configured)
Fetching @local_config_cc; Restarting.
What operating system are you running Bazel on?
Nixos, but I also tried this in a docker container on debian.
What's the output of bazel info release?
release 0.27.0- (@non-git)andrelease 0.26.1- (@non-git)on nixosrelease 0.27.0andrelease 0.26.1on debian.
If bazel info release returns "development version" or "(@Non-Git)", tell us how you built Bazel.
Used the one from nixos.
Activity
guibou commentedon Jun 26, 2019
Some informations:
commit 77b9875 introduced
test_rulesuffixed by_impl. If I'm running bazel with-- -//:test-bar_implto ignore the_implrule, I don't have the build failure.Pass users common attributes (such as `tags`) to rule_test runner
laurentlb commentedon Jul 2, 2019
Broken by 76583ee
laszlocsomor commentedon Jul 3, 2019
Thanks for the repro and culprit identification.
With Bazel 0.27.0
rule_testbecame a macro, expanded to two rules:sh_testand_rule_test_rule. The culprit is, thesh_testgets all the**kwargs(including tags) but the other rule doesn't.@laurentlb : do you think we need a patch release with this fix?
rule_test: apply "tags" to all rules in the macro
guibou commentedon Jul 3, 2019
Thank you for your work on that.
I'm closing the PR opened 7 days ago (#8724) in favor of #8784.
laszlocsomor commentedon Jul 3, 2019
You're welcome.
I didn't notice your PR, sorry about that.
1 remaining item
rule_test: apply "tags" to all rules in the macro
rule_test: apply "tags" to all rules in the macro
Release 0.27.2 (2019-07-10)
Release 0.28.0 (2019-07-10)
rule_test: apply "tags" to all rules in the macro
Release 0.27.2 (2019-07-10)
Release 0.28.0 (2019-07-10)
Release 0.28.0 (2019-07-10)
Bazel 0.28 support
Bazel 0.28 support
Bazel 0.28 support
Release 0.28.1 (2019-07-19)
Release 0.28.1 (2019-07-19)
Release 0.29.0 (2019-08-28)
Release 0.29.0 (2019-08-28)