fedenusy
fedenusy

Reputation: 274

Querying the Bazel cache?

I want to run e2e tests using Bazel.

Each Bazel e2e test rule requires a unique set of external services. For example, some e2e tests might require postgresql, others might require kafka, etc.

I don't want to stand up all these services before every single test run. Instead, I want to query the Bazel cache. If tests already passed and cached results remain valid, I would skip external service setup.

How can I query the Bazel cache to see which of my tests have already passed and won't rerun?

Upvotes: 2

Views: 1070

Answers (1)

Christopher Parsons
Christopher Parsons

Reputation: 337

Provided you keep your Bazel server running, and don't change any dependencies (test files, source files, Bazel target configs), Bazel automatically caches passing tests.

In other words, if I run:

bazel test //foo:bar

The first time, bazel builds and executes the test. If I leave the Bazel server up and rerun

bazel test //foo:bar

...bazel returns rather quickly, and notes that you had a cache hit:

//foo:bar (cached) PASSED in 0.1s

Please let me know if I've misunderstood your question.

Upvotes: 2

Related Questions