diff --git a/src/test/java/com/google/devtools/build/lib/analysis/util/AnalysisMock.java b/src/test/java/com/google/devtools/build/lib/analysis/util/AnalysisMock.java index c75b524102a431..aeb658fec85059 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/util/AnalysisMock.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/util/AnalysisMock.java @@ -39,7 +39,6 @@ import com.google.devtools.build.lib.vfs.Path; import com.google.devtools.build.skyframe.SkyFunction; import com.google.devtools.build.skyframe.SkyFunctionName; -import com.google.devtools.common.options.InvocationPolicyEnforcer; import java.io.IOException; import java.lang.reflect.Field; import java.util.List; @@ -74,11 +73,6 @@ public PackageFactoryBuilderWithSkyframeForTesting getPackageFactoryBuilderForTe .setExtraSkyFunctions(getSkyFunctions(directories)); } - @Override - public InvocationPolicyEnforcer getInvocationPolicyEnforcer() { - return new InvocationPolicyEnforcer(TestConstants.TEST_INVOCATION_POLICY); - } - /** * This is called from test setup to create the mock directory layout needed to create the * configuration. @@ -184,11 +178,6 @@ public ConfiguredRuleClassProvider createRuleClassProvider() { return delegate.createRuleClassProvider(); } - @Override - public InvocationPolicyEnforcer getInvocationPolicyEnforcer() { - return delegate.getInvocationPolicyEnforcer(); - } - @Override public boolean isThisBazel() { return delegate.isThisBazel(); diff --git a/src/test/java/com/google/devtools/build/lib/analysis/util/AnalysisTestCase.java b/src/test/java/com/google/devtools/build/lib/analysis/util/AnalysisTestCase.java index d8a37f5c224dab..75b3b6e84188e6 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/util/AnalysisTestCase.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/util/AnalysisTestCase.java @@ -82,7 +82,6 @@ import com.google.devtools.build.lib.vfs.Root; import com.google.devtools.build.lib.vfs.RootedPath; import com.google.devtools.build.skyframe.SkyKey; -import com.google.devtools.common.options.InvocationPolicyEnforcer; import com.google.devtools.common.options.Options; import com.google.devtools.common.options.OptionsParser; import java.util.Arrays; @@ -282,13 +281,12 @@ public final void useConfiguration(String... args) throws Exception { LoadingPhaseThreadsOption.class, LoadingOptions.class), ruleClassProvider.getConfigurationOptions())); - optionsParser.parse(new String[] {"--default_visibility=public", "--cpu=k8", "--host_cpu=k8"}); + optionsParser.parse("--default_visibility=public", "--cpu=k8", "--host_cpu=k8"); + optionsParser.parse(TestConstants.PRODUCT_SPECIFIC_FLAGS); optionsParser.parse(args); if (defaultFlags().contains(Flag.TRIMMED_CONFIGURATIONS)) { optionsParser.parse("--experimental_dynamic_configs=on"); } - InvocationPolicyEnforcer optionsPolicyEnforcer = analysisMock.getInvocationPolicyEnforcer(); - optionsPolicyEnforcer.enforce(optionsParser); buildOptions = ruleClassProvider.createBuildOptions(optionsParser); } diff --git a/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java b/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java index 986a4e5dd771f5..da52e3f82c391f 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java @@ -157,7 +157,6 @@ import com.google.devtools.build.skyframe.ErrorInfo; import com.google.devtools.build.skyframe.MemoizingEvaluator; import com.google.devtools.build.skyframe.SkyFunction; -import com.google.devtools.common.options.InvocationPolicyEnforcer; import com.google.devtools.common.options.Options; import com.google.devtools.common.options.OptionsParser; import com.google.devtools.common.options.OptionsParsingException; @@ -365,10 +364,6 @@ protected final BuildConfigurationCollection createConfigurations( // TODO(juliexxia): when the starlark options parsing work goes in, add type verification here. optionsParser.setStarlarkOptions(skylarkOptions); - InvocationPolicyEnforcer optionsPolicyEnforcer = - getAnalysisMock().getInvocationPolicyEnforcer(); - optionsPolicyEnforcer.enforce(optionsParser); - BuildOptions buildOptions = ruleClassProvider.createBuildOptions(optionsParser); return skyframeExecutor.createConfigurations( reporter, buildOptions, ImmutableSet.of(), false); @@ -518,14 +513,17 @@ protected void invalidatePackages(boolean alsoConfigs) throws InterruptedExcepti */ protected void useConfiguration(ImmutableMap skylarkOptions, String... args) throws Exception { - String[] actualArgs; - actualArgs = Arrays.copyOf(args, args.length + 1); - actualArgs[args.length] = - "--experimental_dynamic_configs=" + Ascii.toLowerCase(configsMode.toString()); - masterConfig = createConfigurations(skylarkOptions, actualArgs); + ImmutableList actualArgs = + ImmutableList.builder() + .addAll(TestConstants.PRODUCT_SPECIFIC_FLAGS) + .add(args) + .add("--experimental_dynamic_configs=" + Ascii.toLowerCase(configsMode.toString())) + .build(); + + masterConfig = createConfigurations(skylarkOptions, actualArgs.toArray(new String[0])); targetConfig = getTargetConfiguration(); targetConfigKey = BuildConfigurationValue.key(targetConfig); - configurationArgs = Arrays.asList(actualArgs); + configurationArgs = actualArgs; createBuildView(); } diff --git a/src/test/java/com/google/devtools/build/lib/analysis/util/ConfigurationTestCase.java b/src/test/java/com/google/devtools/build/lib/analysis/util/ConfigurationTestCase.java index 1eac500a37b525..3b823ee377a2b4 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/util/ConfigurationTestCase.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/util/ConfigurationTestCase.java @@ -52,7 +52,6 @@ import com.google.devtools.build.lib.vfs.Root; import com.google.devtools.build.lib.vfs.RootedPath; import com.google.devtools.common.options.Converters; -import com.google.devtools.common.options.InvocationPolicyEnforcer; import com.google.devtools.common.options.Option; import com.google.devtools.common.options.OptionDocumentationCategory; import com.google.devtools.common.options.OptionEffectTag; @@ -205,9 +204,7 @@ protected BuildConfigurationCollection createCollection(String... args) throws E .add(TestOptions.class) .build()); parser.parse(args); - - InvocationPolicyEnforcer optionsPolicyEnforcer = analysisMock.getInvocationPolicyEnforcer(); - optionsPolicyEnforcer.enforce(parser); + parser.parse(TestConstants.PRODUCT_SPECIFIC_FLAGS); ImmutableSortedSet multiCpu = ImmutableSortedSet.copyOf( parser.getOptions(TestOptions.class).multiCpus); diff --git a/src/test/java/com/google/devtools/build/lib/packages/util/LoadingMock.java b/src/test/java/com/google/devtools/build/lib/packages/util/LoadingMock.java index bba1eb1cdbb178..b10516d8d58a8d 100644 --- a/src/test/java/com/google/devtools/build/lib/packages/util/LoadingMock.java +++ b/src/test/java/com/google/devtools/build/lib/packages/util/LoadingMock.java @@ -18,7 +18,6 @@ import com.google.devtools.build.lib.skyframe.packages.PackageFactoryBuilderWithSkyframeForTesting; import com.google.devtools.build.lib.testutil.TestConstants; import com.google.devtools.build.lib.testutil.TestRuleClassProvider; -import com.google.devtools.common.options.InvocationPolicyEnforcer; /** Create a mock client for the loading phase, as well as a configuration factory. */ public class LoadingMock { @@ -39,8 +38,4 @@ public PackageFactoryBuilderWithSkyframeForTesting getPackageFactoryBuilderForTe public ConfiguredRuleClassProvider createRuleClassProvider() { return TestRuleClassProvider.getRuleClassProvider(); } - - public InvocationPolicyEnforcer getInvocationPolicyEnforcer() { - return new InvocationPolicyEnforcer(TestConstants.TEST_INVOCATION_POLICY); - } } diff --git a/src/test/java/com/google/devtools/build/lib/pkgcache/BuildFileModificationTest.java b/src/test/java/com/google/devtools/build/lib/pkgcache/BuildFileModificationTest.java index 88a746daa07482..e0c36f0a18f9d7 100644 --- a/src/test/java/com/google/devtools/build/lib/pkgcache/BuildFileModificationTest.java +++ b/src/test/java/com/google/devtools/build/lib/pkgcache/BuildFileModificationTest.java @@ -111,7 +111,6 @@ public final void initializeSkyframeExecutor() throws Exception { TestConstants.processSkyframeExecutorForTesting(skyframeExecutor); OptionsParser parser = OptionsParser.newOptionsParser(PackageCacheOptions.class, StarlarkSemanticsOptions.class); - analysisMock.getInvocationPolicyEnforcer().enforce(parser); setUpSkyframe( parser.getOptions(PackageCacheOptions.class), parser.getOptions(StarlarkSemanticsOptions.class)); diff --git a/src/test/java/com/google/devtools/build/lib/pkgcache/PackageCacheTest.java b/src/test/java/com/google/devtools/build/lib/pkgcache/PackageCacheTest.java index d62ee0786993d2..b5ab62c82497b0 100644 --- a/src/test/java/com/google/devtools/build/lib/pkgcache/PackageCacheTest.java +++ b/src/test/java/com/google/devtools/build/lib/pkgcache/PackageCacheTest.java @@ -53,7 +53,6 @@ import com.google.devtools.build.lib.vfs.Path; import com.google.devtools.build.lib.vfs.Root; import com.google.devtools.build.lib.vfs.RootedPath; -import com.google.devtools.common.options.InvocationPolicyEnforcer; import com.google.devtools.common.options.OptionsParser; import com.google.devtools.common.options.OptionsParsingException; import java.io.IOException; @@ -158,13 +157,6 @@ private OptionsParser parse(String... options) throws Exception { parser.parse("--default_visibility=public"); parser.parse(options); - InvocationPolicyEnforcer optionsPolicyEnforcer = analysisMock.getInvocationPolicyEnforcer(); - try { - optionsPolicyEnforcer.enforce(parser); - } catch (OptionsParsingException e) { - throw new IllegalStateException(e); - } - return parser; } diff --git a/src/test/java/com/google/devtools/build/lib/testutil/BlazeTestUtils.java b/src/test/java/com/google/devtools/build/lib/testutil/BlazeTestUtils.java index 6ca14608be887f..4e11da9300cfb8 100644 --- a/src/test/java/com/google/devtools/build/lib/testutil/BlazeTestUtils.java +++ b/src/test/java/com/google/devtools/build/lib/testutil/BlazeTestUtils.java @@ -14,18 +14,16 @@ package com.google.devtools.build.lib.testutil; -import static com.google.common.collect.ImmutableList.toImmutableList; - import com.google.common.base.Joiner; import com.google.common.base.Preconditions; -import com.google.common.collect.Streams; import com.google.devtools.build.lib.cmdline.Label; import com.google.devtools.build.lib.cmdline.LabelSyntaxException; import com.google.devtools.build.lib.vfs.FileSystemUtils; import com.google.devtools.build.lib.vfs.Path; import java.io.File; import java.io.IOException; -import java.util.List; +import java.util.ArrayList; +import java.util.Collections; /** * Some static utility functions for testing Blaze code. In contrast to {@link TestUtils}, these @@ -97,7 +95,15 @@ public static Label convertLabel(Label label) { } } - public static List