bazel query to list targets dependent on file

38 Views Asked by At

Given a file name, I would like to determine all *_test rules which depend on that file.

Is there any way to query this information from Bazel, either through bazel query or through some other means?

1

There are 1 best solutions below

3
Brian Silverman On BEST ANSWER

bazel query 'rdeps(tests(//...), //build_tests:gflags.cc)'. tests(//...) gives you all the *_test rules, and rdeps gives you reverse dependencies of its second argument within the first argument.