I wish to run bazel build :...all
command and skip test
rules and targets. Is this possible?
I can conceive of two ways to distinguish the tests, either by their type (cc_test in my case), or by pattern-matching on the name, as the project I'm working in suffixes all test rules/targets with "_test".
Please, refrain from making comments telling me that I should always build and run tests upon compilation, unless Bazel actually makes it technically impossible to use "all" wildcard and also filter out all tests. We have a tiered system where builds and tests are all run together, and then after success, another system just builds the minimum artifacts.
There is bazel query. It's quite powerful so I advise to read through the documentation page to design the query command precisely. To quickly answer your concrete question, I think this will work for you:
bazel query '//... except kind(.*test, //...)' | xargs bazel build
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With