bazelbuild / bazel

a fast, scalable, multi-language and extensible build system
https://bazel.build
Apache License 2.0
23.07k stars 4.04k forks source link

Add dependency pruning (unused_inputs_list) to tests #12504

Open pauldraper opened 3 years ago

pauldraper commented 3 years ago

Description of the problem / feature request:

Allow tests to be dependency pruned, for better caching.

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

unused_input_list in actions addresses the problem of over-declared inputs. https://docs.bazel.build/versions/1.2.0/skylark/lib/actions.html#run

Tests have this same problem. Testing performance could be improved if unused inputs could be listed.

A number of testing frameworks have this feature (JS and Go).

Workaround

One workaround to achieve this is to convert tests into actions with unused_input_list, and use bazel build to "test." But this gives up a lot of the ergonomics around bazel test.

comius commented 1 year ago

cc @lberki

lberki commented 1 year ago

I think it's a reasonable addition, although I haven't gamed out all the possible implications in my head.

fmeum commented 6 months ago

I found some references to such a feature in the code (https://cs.opensource.google/bazel/bazel/+/master:src/main/java/com/google/devtools/build/lib/buildeventstream/TestFileNameConstants.java;l=37;drc=38117d4072df3c8d76591b39e36167b9fde66662). Is this available with the Google-internal test runner implementation?

lberki commented 6 months ago

No, it's not that (if we had this feature internally, we'd just open source it!)

It's a way to automatically detect which input files of a test were unused (IIRC by looking at atimes) to facilitate dependency pruning in BUILD files. It doesn't change what Blaze considers the action graph, it's only for diagnostics.