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();