bazel icon indicating copy to clipboard operation
bazel copied to clipboard

`test_tag_filter` should imply `build_tag_filter` in `bazel test` command

Open ghost opened this issue 6 years ago • 4 comments

Description of the problem / feature request:

Right now, the somewhat innocent looking command

$ bazel test //... --test_tag_filters=my-specific-tag

builds far more than it needs to to run the specified test.

As far as I can tell, this is because bazel is interpreting the test command as

$ bazel build [label] [options]
$ bazel test [label] [options]

and since the first part of that ignores --test_tag_filters, the above innocent-looking command expands to

$ bazel build //...
$ bazel test //... --test_tag_filters=my-specific-tag

This is very counter-intuitive.

I suggest that the build part of a bazel test command use the same analysis as the test part of that command, so only the required test targets (and their dependencies) are built.

Feature requests: what underlying problem are you trying to solve with this feature?

Fixing counter-intuitive command-line behaviour, reducing accidentally very long builds.

What operating system are you running Bazel on?

Ubuntu 18.04

What's the output of bazel info release?

$ bazel info release
release 0.23.2

ghost avatar May 22 '19 10:05 ghost

Does the flag --build_tests_only work to make Bazel behave as you expect in this case?

janakdr avatar Apr 20 '20 14:04 janakdr

Perhaps --test_tag_filters should imply use of build_tests_only. OR.... perhaps bazel test should imply build_tests_only, so that if you actually want to build everything, you' would have to add --nobuild_tests_only. That seems like reasonable behavior, but I'm sure that would upset someones process.

aiuto avatar Apr 21 '20 01:04 aiuto

Another interesting related note is how //... doesn't include manual targets but $(bazel query //...) does and --test_tag_filters=-manual isn't enough to prevent building manual targets.

dmivankov avatar Jun 03 '22 12:06 dmivankov

Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 1+ years. It will be closed in the next 90 days unless any other activity occurs. If you think this issue is still relevant and should stay open, please post any comment here and the issue will no longer be marked as stale.

github-actions[bot] avatar Feb 17 '24 01:02 github-actions[bot]

This issue has been automatically closed due to inactivity. If you're still interested in pursuing this, please post @bazelbuild/triage in a comment here and we'll take a look. Thanks!

github-actions[bot] avatar May 17 '24 01:05 github-actions[bot]