Skip to content

Commit fe1a098

Browse files
Ioan Budeameta-codesync[bot]
authored andcommitted
Add supports_test_execution_caching attribute to python test
Summary: Add an attribute for turning on test execution caching. It's turned off everywhere and will just let us experiment a little bit. The caching is for RE executions only (no DICE caching), so it is safe. Reviewed By: IanChilds Differential Revision: D95567733 fbshipit-source-id: 16849b3d44fa430d25e74fa0f23dbc9ea0083ebb
1 parent dba29c2 commit fe1a098

4 files changed

Lines changed: 4 additions & 0 deletions

File tree

decls/python_rules.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ def _python_test_attrs():
140140
test_attrs["_test_main"] = attrs.source(default = "prelude//python/tools:__test_main__.py")
141141
test_attrs["implicit_test_library"] = attrs.option(attrs.dep(providers = [PythonLibraryInfo]), default = None)
142142
test_attrs["safer_lazy_imports"] = attrs.bool(default = False) # TODO(T240038931) When enabling lazy imports by default, remove this line
143+
test_attrs["supports_test_execution_caching"] = attrs.bool(default = False)
143144
test_attrs.update(re_test_common.test_args())
144145
return test_attrs
145146

python/compute_providers.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,6 @@ def compute_test_providers(ctx: AnalysisContext, exe: PexProviders) -> list[Prov
5656
run_from_project_root = re_executor != None,
5757
use_project_relative_paths = re_executor != None,
5858
network_access = getattr(ctx.attrs, "network_access", None),
59+
supports_test_execution_caching = ctx.attrs.supports_test_execution_caching,
5960
),
6061
) + [make_default_info(exe)]

python/python_needed_coverage_test.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ def python_needed_coverage_test_impl(ctx: AnalysisContext) -> list[Provider]:
5656
# the cell root (e.g. fbcode root).
5757
run_from_project_root = re_executor != None,
5858
use_project_relative_paths = re_executor != None,
59+
supports_test_execution_caching = ctx.attrs.supports_test_execution_caching,
5960
),
6061
) + [
6162
DefaultInfo(),

rules_impl.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,7 @@ _python_extra_attributes = {
476476
env = attrs.dict(key = attrs.string(), value = attrs.arg(), sorted = False, default = {}),
477477
labels = attrs.list(attrs.string(), default = []),
478478
needed_coverage = attrs.list(attrs.tuple(attrs.int(), attrs.dep(), attrs.option(attrs.string())), default = []),
479+
supports_test_execution_caching = attrs.bool(default = False),
479480
test = attrs.dep(providers = [ExternalRunnerTestInfo]),
480481
**(re_test_common.test_args() | buck.inject_test_env_arg()),
481482
),

0 commit comments

Comments
 (0)