Skip to content

rule_test does not use tags since bazel 0.27 #8723

Closed

Description

@guibou

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) and release 0.26.1- (@non-git) on nixos
  • release 0.27.0 and release 0.26.1 on debian.

If bazel info release returns "development version" or "(@Non-Git)", tell us how you built Bazel.

Used the one from nixos.

Activity

  1. guibou commented on Jun 26, 2019

    @guibou
    ContributorAuthor

    Some informations:

    commit 77b9875 introduced test_rule suffixed by _impl. If I'm running bazel with -- -//:test-bar_impl to ignore the _impl rule, I don't have the build failure.

  2. added a commit that references this issue on Jun 26, 2019
    1571ecb
  3. added
    untriaged
    on Jul 1, 2019
  4. added
    P1
    on Jul 2, 2019
  5. laurentlb commented on Jul 2, 2019

    @laurentlb
    Contributor

    Broken by 76583ee

  6. laszlocsomor commented on Jul 3, 2019

    @laszlocsomor
    Contributor

    Thanks for the repro and culprit identification.

    With Bazel 0.27.0 rule_test became a macro, expanded to two rules: sh_test and _rule_test_rule. The culprit is, the sh_test gets all the **kwargs (including tags) but the other rule doesn't.

    @laurentlb : do you think we need a patch release with this fix?

  7. removed
    untriaged
    on Jul 3, 2019
  8. guibou commented on Jul 3, 2019

    @guibou
    ContributorAuthor

    Thank you for your work on that.

    I'm closing the PR opened 7 days ago (#8724) in favor of #8784.

  9. laszlocsomor commented on Jul 3, 2019

    @laszlocsomor
    Contributor

    You're welcome.
    I didn't notice your PR, sorry about that.

  10. 1 remaining item

  11. added a commit that references this issue on Jul 16, 2019
  12. added a commit that references this issue on Jul 19, 2019
  13. added a commit that references this issue on Aug 5, 2019
  14. added a commit that references this issue on Aug 28, 2019
  15. added a commit that references this issue on Aug 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P1type: bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions