From 580669194f1e8d4084ca227d5660aa03855f088d Mon Sep 17 00:00:00 2001 From: Googler Date: Mon, 14 Aug 2023 16:30:57 -0700 Subject: [PATCH] Starlark exec logic: hard-code test configuration logic for now. See change for the challenges of proper Starlark support. PiperOrigin-RevId: 556946537 Change-Id: Ib155fa07e10f425bd4be81fc6a7cf0497f759d54 --- .../java/com/google/devtools/build/lib/analysis/BUILD | 1 + .../lib/analysis/starlark/FunctionTransitionUtil.java | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/src/main/java/com/google/devtools/build/lib/analysis/BUILD b/src/main/java/com/google/devtools/build/lib/analysis/BUILD index f7cd948fd316f4..c78ea51bd046fa 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/BUILD +++ b/src/main/java/com/google/devtools/build/lib/analysis/BUILD @@ -2442,6 +2442,7 @@ java_library( ":config/optioninfo", ":config/starlark_defined_config_transition", ":config/transitions/configuration_transition", + ":test/test_configuration", "//src/main/java/com/google/devtools/build/lib/cmdline", "//src/main/java/com/google/devtools/build/lib/events", "//src/main/java/com/google/devtools/build/lib/packages", diff --git a/src/main/java/com/google/devtools/build/lib/analysis/starlark/FunctionTransitionUtil.java b/src/main/java/com/google/devtools/build/lib/analysis/starlark/FunctionTransitionUtil.java index 2c81ae3925f423..03bfdb4b72b449 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/starlark/FunctionTransitionUtil.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/starlark/FunctionTransitionUtil.java @@ -32,6 +32,7 @@ import com.google.devtools.build.lib.analysis.config.OptionInfo; import com.google.devtools.build.lib.analysis.config.StarlarkDefinedConfigTransition; import com.google.devtools.build.lib.analysis.config.StarlarkDefinedConfigTransition.ValidationException; +import com.google.devtools.build.lib.analysis.test.TestConfiguration.TestOptions; import com.google.devtools.build.lib.cmdline.Label; import com.google.devtools.build.lib.cmdline.LabelSyntaxException; import com.google.devtools.build.lib.events.Event; @@ -156,6 +157,15 @@ private static BuildOptions maybeGetExecDefaults( // Propagate Starlark options from the source config: // TODO(b/288258583) don't automatically propagate Starlark options. defaultBuilder.addStarlarkOptions(fromOptions.getStarlarkOptions()); + // Hard-code TestConfiguration.getExec() for now, which clones the source options. + // TODO(b/295936652): handle this directly in Starlark. This has two complications: + // 1: --trim_test_configuration means the flags may not exist. Starlark logic needs to handle + // that possibility. + // 2: --runs_per_test has a non-Starlark readable type. + if (fromOptions.contains(TestOptions.class)) { + defaultBuilder.removeFragmentOptions(TestOptions.class); + defaultBuilder.addFragmentOptions(fromOptions.get(TestOptions.class)); + } // Propagate --define values from the source config: // TODO(b/288258583) don't automatically propagate --defines. BuildOptions ans = defaultBuilder.build();