Skip to content

How to build all buildable targets and test all testable targets #4257

@alexeagle

Description

@alexeagle

I want to "build and test all the things" on my CI.

bazel test ... is bad because it doesn't build a target unless some test depends on it. (probably surprising to new users)

bazel build ... && bazel test ... is bad because the first test doesn't start running until the slowest build target is built

At Google we give up on this, and use build_test (alluded to at https://docs.bazel.build/versions/master/be/functions.html#load) which is a special test target that always passes, but consumes the files from some given deps, forcing those deps to build, and thus making the test either fail with a build error, or pass. But I think this is bad because it's easy to forget to create a build_test for some target, and we shouldn't expect everyone to be ever-watchful for that gotcha.

Is there some other way I don't know of?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions