Running all dependent tests

1,471 views
Skip to first unread message

glin...@gmail.com

unread,
Jun 6, 2016, 2:22:50 PM6/6/16
to bazel-discuss
Is there something like `bazel test //foo/bar:...`, except it runs all the tests in packages that this package depends on as well?

ie. if foo/bar/BUILD depended on the `//baz` target, we'd like it to be run.

Thanks!
Gary

Kamal Marhubi

unread,
Jun 6, 2016, 3:24:30 PM6/6/16
to glin...@gmail.com, bazel-discuss
You can do this with a query and xargs, something like `bazel query deps(//foo/bar:all) | xargs bazel test`. There may be a way to pass the query directly to test, but I didn't see anything in `bazel help target-syntax`.

--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/f1b00450-e91f-42d0-91da-9c26ca02412b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Damien Martin-guillerez

unread,
Jun 6, 2016, 3:45:46 PM6/6/16
to Kamal Marhubi, glin...@gmail.com, bazel-discuss
If my memory serves me right:

bazel test $(bazel query 'kind(test, deps(//foo/bar:all))')

glin...@gmail.com

unread,
Jun 6, 2016, 4:54:45 PM6/6/16
to bazel-discuss, glin...@gmail.com

Awesome, thanks!

mcfarla...@gmail.com

unread,
Jun 6, 2016, 5:04:31 PM6/6/16
to bazel-discuss, glin...@gmail.com
Similar question: is there a way to run (or list) all tests that depend on a given cc_library? Thanks

Austin Schuh

unread,
Jun 6, 2016, 5:06:18 PM6/6/16
to mcfarla...@gmail.com, bazel-discuss, glin...@gmail.com
Tweak //foo/bar:all and you should be good.  bazel query is very flexible, and the docs have a bunch of examples in them.

Austin

Brian Silverman

unread,
Jun 6, 2016, 5:31:17 PM6/6/16
to Austin Schuh, mcfarla...@gmail.com, bazel-discuss, Gary Linscott
tests(rdeps(//whatever:my_lib)) will get you all the dependent tests.

John McFarlane

unread,
Jun 6, 2016, 8:15:16 PM6/6/16
to Brian Silverman, Austin Schuh, bazel-discuss, Gary Linscott
That's what I was looking for. Thanks!

ittai zeidman

unread,
Jun 7, 2016, 1:22:34 AM6/7/16
to bazel-discuss, bsilve...@gmail.com, austin...@gmail.com, glin...@gmail.com, mcfarla...@gmail.com
May I ask why you're trying to do this?
Trying to understand usage patterns of bazel.

Thanks!

John McFarlane

unread,
Jun 7, 2016, 1:58:03 AM6/7/16
to ittai zeidman, bazel-discuss, bsilve...@gmail.com, austin...@gmail.com, glin...@gmail.com
Sure. I'm working on a particular library target and wanted to test changes to it and the other targets it affects without building everything in the workspace.

ittai zeidman

unread,
Jun 7, 2016, 2:00:05 AM6/7/16
to John McFarlane, bazel-discuss, bsilve...@gmail.com, austin...@gmail.com, glin...@gmail.com
but if you only changed that target and build everything shouldn't you get the same outcome thanks to bazel's DAG?

John McFarlane

unread,
Jun 7, 2016, 10:44:59 AM6/7/16
to ittai zeidman, John McFarlane, bazel-discuss, bsilve...@gmail.com, austin...@gmail.com, glin...@gmail.com
Assuming everything else is built already, yes. But if it isn't, it can be a long wait after you've just puled.

You received this message because you are subscribed to a topic in the Google Groups "bazel-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/bazel-discuss/72rcRgvf29A/unsubscribe.
To unsubscribe from this group and all its topics, send an email to bazel-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/CAOfK4wVU0BKGnAFTrSHz1FP7Td9Et14WSyVrbFi_np_CLu1jMA%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.



--
John McFarlane | Programmer I Zoox.com I +1 206 816 2745

ittai zeidman

unread,
Jun 7, 2016, 1:32:55 PM6/7/16
to John McFarlane, John McFarlane, bazel-discuss, bsilve...@gmail.com, austin...@gmail.com, glin...@gmail.com
I understand.
I'm thinking of the distributed cache solution where if you've pulled the cache is very likely populated.
Thanks for the clarification!
Reply all
Reply to author
Forward
0 new messages