Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bazel Build Command - Is possible to skip "Test" Targets and Rules?

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.

like image 550
solvingJ Avatar asked Mar 08 '23 21:03

solvingJ


1 Answers

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

like image 120
hlopko Avatar answered May 16 '23 08:05

hlopko