diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRulesModule.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRulesModule.java index c0f45ad7737f93..e81c216068ab4c 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRulesModule.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRulesModule.java @@ -17,7 +17,6 @@ import com.google.common.collect.ImmutableList; import com.google.devtools.build.lib.analysis.BlazeDirectories; import com.google.devtools.build.lib.analysis.ConfiguredRuleClassProvider; -import com.google.devtools.build.lib.analysis.config.BuildOptions; import com.google.devtools.build.lib.bazel.rules.cpp.BazelCppRuleClasses; import com.google.devtools.build.lib.bazel.rules.sh.BazelShRuleClasses; import com.google.devtools.build.lib.remote.options.RemoteOptions; @@ -44,9 +43,9 @@ import java.io.IOException; /** Module implementing the rule set of Bazel. */ -public class BazelRulesModule extends BlazeModule { +public final class BazelRulesModule extends BlazeModule { /** This is where deprecated options go to die. */ - public static class GraveyardOptions extends OptionsBase { + public static final class GraveyardOptions extends OptionsBase { @Option( name = "incompatible_load_python_rules_from_bzl", defaultValue = "false", @@ -535,12 +534,6 @@ public void workspaceInit( CcSkyframeFdoSupportValue.SKYFUNCTION, new CcSkyframeFdoSupportFunction(directories)); } - @Override - public BuildOptions getDefaultBuildOptions(BlazeRuntime blazeRuntime) { - return BuildOptions.getDefaultBuildOptionsForFragments( - blazeRuntime.getRuleClassProvider().getConfigurationOptions()); - } - @Override public Iterable> getCommandOptions(Command command) { return "build".equals(command.name()) diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BUILD b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BUILD index 1792046cd36cb4..fc1d4584e6341e 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BUILD +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BUILD @@ -63,7 +63,6 @@ java_library( "//src/main/java/com/google/devtools/build/lib/packages", "//src/main/java/com/google/devtools/build/lib/rules/cpp", "//src/main/java/com/google/devtools/build/lib/rules/java:java-compilation", - "//src/main/java/com/google/devtools/build/lib/rules/java:java-rules", "//src/main/java/com/google/devtools/build/lib/shell", "//src/main/java/com/google/devtools/build/lib/skyframe/serialization/autocodec", "//src/main/java/com/google/devtools/build/lib/util", diff --git a/src/main/java/com/google/devtools/build/lib/bugreport/BUILD b/src/main/java/com/google/devtools/build/lib/bugreport/BUILD index bc8e2aa24da149..723e2593a2b256 100644 --- a/src/main/java/com/google/devtools/build/lib/bugreport/BUILD +++ b/src/main/java/com/google/devtools/build/lib/bugreport/BUILD @@ -19,7 +19,6 @@ java_library( "//src/main/java/com/google/devtools/build/lib/util:custom_exit_code_publisher", "//src/main/java/com/google/devtools/build/lib/util:custom_failure_detail_publisher", "//src/main/java/com/google/devtools/build/lib/util:detailed_exit_code", - "//src/main/java/com/google/devtools/build/lib/util:exit_code", "//src/main/java/com/google/devtools/build/lib/util:logging", "//third_party:flogger", "//third_party:guava", diff --git a/src/main/java/com/google/devtools/build/lib/buildtool/SkyframeBuilder.java b/src/main/java/com/google/devtools/build/lib/buildtool/SkyframeBuilder.java index 8d48b77ce295b9..5dab8d3c782e44 100644 --- a/src/main/java/com/google/devtools/build/lib/buildtool/SkyframeBuilder.java +++ b/src/main/java/com/google/devtools/build/lib/buildtool/SkyframeBuilder.java @@ -211,7 +211,6 @@ public void buildArtifacts( options, actionCacheChecker, topDownActionCache, - null, topLevelArtifactContext); detailedExitCode = processResult( @@ -253,7 +252,7 @@ public void buildArtifacts( *
  • {@code null}, if {@code result} had no errors *
  • {@code e} if result had errors and one of them specified a {@link DetailedExitCode} value * {@code e} - *
  • a {@link DetailedExitCode} with {@link Code.NON_ACTION_EXECUTION_FAILURE} if result had + *
  • a {@link DetailedExitCode} with {@link Code#NON_ACTION_EXECUTION_FAILURE} if result had * errors but none specified a {@link DetailedExitCode} value * * diff --git a/src/main/java/com/google/devtools/build/lib/exec/BUILD b/src/main/java/com/google/devtools/build/lib/exec/BUILD index 6156860b73767e..268defdc80bac2 100644 --- a/src/main/java/com/google/devtools/build/lib/exec/BUILD +++ b/src/main/java/com/google/devtools/build/lib/exec/BUILD @@ -222,8 +222,6 @@ java_library( srcs = ["SpawnExecException.java"], deps = [ "//src/main/java/com/google/devtools/build/lib/actions", - "//src/main/java/com/google/devtools/build/lib/util:detailed_exit_code", - "//src/main/java/com/google/devtools/build/lib/util:exit_code", "//src/main/protobuf:failure_details_java_proto", "//third_party:guava", ], diff --git a/src/main/java/com/google/devtools/build/lib/profiler/BUILD b/src/main/java/com/google/devtools/build/lib/profiler/BUILD index 13afb45d222d05..b2147dbff5f42a 100644 --- a/src/main/java/com/google/devtools/build/lib/profiler/BUILD +++ b/src/main/java/com/google/devtools/build/lib/profiler/BUILD @@ -58,10 +58,7 @@ java_library( ]), deps = [ ":profiler", - "//src/main/java/com/google/devtools/build/lib/events", "//src/main/java/com/google/devtools/build/lib/util", - "//src/main/java/com/google/devtools/build/lib/util:var_int", - "//src/main/java/com/google/devtools/build/lib/vfs", "//third_party:auto_value", "//third_party:gson", "//third_party:guava", diff --git a/src/main/java/com/google/devtools/build/lib/profiler/memory/BUILD b/src/main/java/com/google/devtools/build/lib/profiler/memory/BUILD index 62a315ee2a77bd..20971cd749a8aa 100644 --- a/src/main/java/com/google/devtools/build/lib/profiler/memory/BUILD +++ b/src/main/java/com/google/devtools/build/lib/profiler/memory/BUILD @@ -25,7 +25,6 @@ java_library( "//src/main/java/com/google/devtools/build/lib/vfs", "//src/main/java/com/google/devtools/common/options", "//src/main/java/net/starlark/java/eval", - "//src/main/java/net/starlark/java/syntax", "//third_party/allocation_instrumenter", ], ) diff --git a/src/main/java/com/google/devtools/build/lib/remote/merkletree/BUILD b/src/main/java/com/google/devtools/build/lib/remote/merkletree/BUILD index 2eec7bf4928ebb..f63fa0e7e6c2ab 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/merkletree/BUILD +++ b/src/main/java/com/google/devtools/build/lib/remote/merkletree/BUILD @@ -18,7 +18,6 @@ java_library( "//src/main/java/com/google/devtools/build/lib/actions:artifacts", "//src/main/java/com/google/devtools/build/lib/actions:file_metadata", "//src/main/java/com/google/devtools/build/lib/profiler", - "//src/main/java/com/google/devtools/build/lib/remote/common", "//src/main/java/com/google/devtools/build/lib/remote/util", "//src/main/java/com/google/devtools/build/lib/vfs", "//src/main/java/com/google/devtools/build/lib/vfs:pathfragment", diff --git a/src/main/java/com/google/devtools/build/lib/rules/apple/swift/BUILD b/src/main/java/com/google/devtools/build/lib/rules/apple/swift/BUILD index 11a5c00dfd95fb..c821449dd2e48e 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/apple/swift/BUILD +++ b/src/main/java/com/google/devtools/build/lib/rules/apple/swift/BUILD @@ -17,8 +17,6 @@ java_library( "//src/main/java/com/google/devtools/build/lib/analysis:config/build_options", "//src/main/java/com/google/devtools/build/lib/analysis:config/fragment", "//src/main/java/com/google/devtools/build/lib/analysis:config/fragment_options", - "//src/main/java/com/google/devtools/build/lib/analysis:config/fragment_provider", - "//src/main/java/com/google/devtools/build/lib/analysis:config/invalid_configuration_exception", "//src/main/java/com/google/devtools/build/lib/concurrent", "//src/main/java/com/google/devtools/build/lib/starlarkbuildapi/apple", "//src/main/java/com/google/devtools/common/options", diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/proto/BUILD b/src/main/java/com/google/devtools/build/lib/rules/cpp/proto/BUILD index 4c55c3d8137404..5dc0c2ecc8cb08 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/proto/BUILD +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/proto/BUILD @@ -29,7 +29,6 @@ java_library( "//src/main/java/com/google/devtools/build/lib/cmdline", "//src/main/java/com/google/devtools/build/lib/collect/nestedset", "//src/main/java/com/google/devtools/build/lib/packages", - "//src/main/java/com/google/devtools/build/lib/packages/semantics", "//src/main/java/com/google/devtools/build/lib/rules/cpp", "//src/main/java/com/google/devtools/build/lib/rules/proto", "//src/main/java/com/google/devtools/build/lib/skyframe:configured_target_and_data", diff --git a/src/main/java/com/google/devtools/build/lib/rules/genquery/BUILD b/src/main/java/com/google/devtools/build/lib/rules/genquery/BUILD index 47bb1d9140782c..2f01f5eead8264 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/genquery/BUILD +++ b/src/main/java/com/google/devtools/build/lib/rules/genquery/BUILD @@ -24,8 +24,6 @@ java_library( "//src/main/java/com/google/devtools/build/lib/analysis:config/core_options", "//src/main/java/com/google/devtools/build/lib/analysis:config/fragment", "//src/main/java/com/google/devtools/build/lib/analysis:config/fragment_options", - "//src/main/java/com/google/devtools/build/lib/analysis:config/fragment_provider", - "//src/main/java/com/google/devtools/build/lib/analysis:config/invalid_configuration_exception", "//src/main/java/com/google/devtools/build/lib/analysis:configured_target", "//src/main/java/com/google/devtools/build/lib/analysis:rule_definition_environment", "//src/main/java/com/google/devtools/build/lib/cmdline", diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/BUILD b/src/main/java/com/google/devtools/build/lib/rules/objc/BUILD index c3307d264cafc4..39208e05743cb4 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/BUILD +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/BUILD @@ -36,7 +36,6 @@ java_library( "//src/main/java/com/google/devtools/build/lib/analysis:config/transitions/split_transition", "//src/main/java/com/google/devtools/build/lib/analysis:config/transitions/transition_factory", "//src/main/java/com/google/devtools/build/lib/analysis:configured_target", - "//src/main/java/com/google/devtools/build/lib/analysis:file_provider", "//src/main/java/com/google/devtools/build/lib/analysis:platform_options", "//src/main/java/com/google/devtools/build/lib/analysis:rule_definition_environment", "//src/main/java/com/google/devtools/build/lib/analysis:test/instrumented_files_info", diff --git a/src/main/java/com/google/devtools/build/lib/rules/proto/BUILD b/src/main/java/com/google/devtools/build/lib/rules/proto/BUILD index bd3120d43e52f2..bc2ab0f16a20fa 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/proto/BUILD +++ b/src/main/java/com/google/devtools/build/lib/rules/proto/BUILD @@ -33,10 +33,7 @@ java_library( "//src/main/java/com/google/devtools/build/lib/analysis:config/execution_transition_factory", "//src/main/java/com/google/devtools/build/lib/analysis:config/fragment", "//src/main/java/com/google/devtools/build/lib/analysis:config/fragment_options", - "//src/main/java/com/google/devtools/build/lib/analysis:config/fragment_provider", - "//src/main/java/com/google/devtools/build/lib/analysis:config/invalid_configuration_exception", "//src/main/java/com/google/devtools/build/lib/analysis:configured_target", - "//src/main/java/com/google/devtools/build/lib/analysis:file_provider", "//src/main/java/com/google/devtools/build/lib/analysis:rule_definition_environment", "//src/main/java/com/google/devtools/build/lib/analysis:transitive_info_collection", "//src/main/java/com/google/devtools/build/lib/analysis:transitive_info_provider", @@ -45,7 +42,6 @@ java_library( "//src/main/java/com/google/devtools/build/lib/collect/nestedset", "//src/main/java/com/google/devtools/build/lib/concurrent", "//src/main/java/com/google/devtools/build/lib/packages", - "//src/main/java/com/google/devtools/build/lib/packages/semantics", "//src/main/java/com/google/devtools/build/lib/skyframe/serialization/autocodec", "//src/main/java/com/google/devtools/build/lib/starlarkbuildapi", "//src/main/java/com/google/devtools/build/lib/starlarkbuildapi/proto", @@ -54,7 +50,6 @@ java_library( "//src/main/java/com/google/devtools/build/lib/vfs", "//src/main/java/com/google/devtools/build/lib/vfs:pathfragment", "//src/main/java/com/google/devtools/common/options", - "//src/main/java/net/starlark/java/syntax", "//third_party:auto_value", "//third_party:guava", "//third_party:jsr305", diff --git a/src/main/java/com/google/devtools/build/lib/runtime/BlazeModule.java b/src/main/java/com/google/devtools/build/lib/runtime/BlazeModule.java index 5ad34a9984bb3f..1e7a9b1df1da28 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/BlazeModule.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/BlazeModule.java @@ -258,15 +258,6 @@ public Iterable> getCommonCommandOptions() { return ImmutableList.of(); } - /** - * Returns an instance of BuildOptions to be used to create {@link - * BuildOptions.OptionsDiffForReconstruction} with. Only one installed Module should override - * this. - */ - public BuildOptions getDefaultBuildOptions(BlazeRuntime runtime) { - return null; - } - /** * Called after Bazel analyzes the build's top-level targets. This is called once per build if * --analyze is enabled. Modules can override this to perform extra checks on analysis results. diff --git a/src/main/java/com/google/devtools/build/lib/runtime/BlazeRuntime.java b/src/main/java/com/google/devtools/build/lib/runtime/BlazeRuntime.java index 1516f5414068f7..0f07d1e24639e6 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/BlazeRuntime.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/BlazeRuntime.java @@ -128,6 +128,7 @@ import java.util.List; import java.util.Locale; import java.util.Map; +import java.util.Objects; import java.util.Optional; import java.util.UUID; import java.util.concurrent.Future; @@ -237,7 +238,7 @@ private BlazeRuntime( retainedHeapLimiter = RetainedHeapLimiter.create(bugReporter); CommandNameCache.CommandNameCacheInstance.INSTANCE.setCommandNameCache( - new CommandNameCacheImpl(getCommandMap())); + new CommandNameCacheImpl(commandMap)); this.productName = productName; this.buildEventArtifactUploaderFactoryMap = buildEventArtifactUploaderFactoryMap; this.authHeadersProviderMap = @@ -253,8 +254,7 @@ public BlazeWorkspace initWorkspace(BlazeDirectories directories, BinTools binTo for (BlazeModule module : blazeModules) { module.workspaceInit(this, directories, builder); } - this.workspace = - builder.build(this, packageFactory, ruleClassProvider, eventBusExceptionHandler); + this.workspace = builder.build(this, packageFactory, eventBusExceptionHandler); return workspace; } @@ -287,7 +287,7 @@ private void addCommand(BlazeCommand command) { } @VisibleForTesting - public final void overrideCommands(Iterable commands) { + public void overrideCommands(Iterable commands) { commandMap.clear(); for (BlazeCommand command : commands) { addCommand(command); @@ -301,7 +301,7 @@ public InvocationPolicy getModuleInvocationPolicy() { private BuildEventArtifactUploader newUploader( CommandEnvironment env, String buildEventUploadStrategy) throws IOException { - return getBuildEventArtifactUploaderFactoryMap().select(buildEventUploadStrategy).create(env); + return buildEventArtifactUploaderFactoryMap.select(buildEventUploadStrategy).create(env); } /** Configure profiling based on the provided options. */ @@ -452,7 +452,7 @@ public ActionKeyContext getActionKeyContext() { /** The directory in which blaze stores the server state - that is, the socket file and a log. */ private Path getServerDirectory() { - return getWorkspace().getDirectories().getOutputBase().getChild("server"); + return workspace.getDirectories().getOutputBase().getChild("server"); } /** @@ -490,25 +490,6 @@ public Iterable getBlazeModules() { return blazeModules; } - public BuildOptions getDefaultBuildOptions() { - BuildOptions options = null; - for (BlazeModule module : blazeModules) { - BuildOptions optionsFromModule = module.getDefaultBuildOptions(this); - if (optionsFromModule != null) { - if (options == null) { - options = optionsFromModule; - } else { - throw new IllegalArgumentException( - "Two or more bazel modules contained default build options."); - } - } - } - if (options == null) { - throw new IllegalArgumentException("No default build options specified in any Bazel module"); - } - return options; - } - /** * Returns the first module that is an instance of a given class or interface. * @@ -860,10 +841,10 @@ static CommandLineOptions splitStartupOptions(Iterable modules, Str } private static InterruptSignalHandler captureSigint() { - final Thread mainThread = Thread.currentThread(); - final AtomicInteger numInterrupts = new AtomicInteger(); + Thread mainThread = Thread.currentThread(); + AtomicInteger numInterrupts = new AtomicInteger(); - final Runnable interruptWatcher = + Runnable interruptWatcher = () -> { int count = 0; // Not an actual infinite loop because it's run in a daemon thread. @@ -912,9 +893,7 @@ private static int batchMain(Iterable modules, String[] args) { runtime = newRuntime(modules, commandLineOptions.getStartupArgs(), null); policy = InvocationPolicyParser.parsePolicy( - runtime - .getStartupOptionsProvider() - .getOptions(BlazeServerStartupOptions.class) + runtime.startupOptionsProvider.getOptions(BlazeServerStartupOptions.class) .invocationPolicy); } catch (OptionsParsingException e) { OutErr.SYSTEM_OUT_ERR.printErrLn(e.getMessage()); @@ -944,7 +923,7 @@ private static int batchMain(Iterable modules, String[] args) { OutErr.SYSTEM_OUT_ERR, LockingMode.ERROR_OUT, "batch client", - runtime.getClock().currentTimeMillis(), + runtime.clock.currentTimeMillis(), Optional.of(startupOptionsFromCommandLine.build()), /*commandExtensions=*/ ImmutableList.of()); if (result.getExecRequest() == null) { @@ -1024,13 +1003,13 @@ private static int serverMain(Iterable modules, OutErr outErr, Stri BlazeCommandDispatcher dispatcher = new BlazeCommandDispatcher(runtime, serverPid); BlazeServerStartupOptions startupOptions = - runtime.getStartupOptionsProvider().getOptions(BlazeServerStartupOptions.class); + runtime.startupOptionsProvider.getOptions(BlazeServerStartupOptions.class); RPCServer rpcServer = GrpcServerImpl.create( dispatcher, shutdownHooks, pidFileWatcher, - runtime.getClock(), + runtime.clock, startupOptions.commandPort, runtime.getServerDirectory(), serverPid, @@ -1598,8 +1577,8 @@ public Builder setActionKeyContext(ActionKeyContext actionKeyContext) { private static PackageSettings getPackageSettings(List blazeModules) { List packageSettingss = blazeModules.stream() - .map(module -> module.getPackageSettings()) - .filter(settings -> settings != null) + .map(BlazeModule::getPackageSettings) + .filter(Objects::nonNull) .collect(toImmutableList()); Preconditions.checkState( packageSettingss.size() <= 1, "more than one module defines a PackageSettings"); @@ -1609,8 +1588,8 @@ private static PackageSettings getPackageSettings(List blazeModules private static PackageValidator getPackageValidator(List blazeModules) { List packageValidators = blazeModules.stream() - .map(module -> module.getPackageValidator()) - .filter(validator -> validator != null) + .map(BlazeModule::getPackageValidator) + .filter(Objects::nonNull) .collect(toImmutableList()); Preconditions.checkState( packageValidators.size() <= 1, "more than one module defined a PackageValidator"); @@ -1622,7 +1601,7 @@ private static PackageOverheadEstimator getPackageOverheadEstimator( List packageOverheadEstimators = blazeModules.stream() .map(BlazeModule::getPackageOverheadEstimator) - .filter(estimator -> estimator != null) + .filter(Objects::nonNull) .collect(toImmutableList()); Preconditions.checkState( packageOverheadEstimators.size() <= 1, @@ -1641,7 +1620,7 @@ private static PackageLoadingListener getPackageLoadingListener( .map( module -> module.getPackageLoadingListener(packageBuilderHelper, ruleClassProvider, fs)) - .filter(validator -> validator != null) + .filter(Objects::nonNull) .collect(toImmutableList()); return PackageLoadingListener.create(listeners); } diff --git a/src/main/java/com/google/devtools/build/lib/runtime/WorkspaceBuilder.java b/src/main/java/com/google/devtools/build/lib/runtime/WorkspaceBuilder.java index 1d9ff084c964e7..0a46692b05b36e 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/WorkspaceBuilder.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/WorkspaceBuilder.java @@ -18,7 +18,6 @@ import com.google.common.collect.ImmutableMap; import com.google.common.eventbus.SubscriberExceptionHandler; import com.google.devtools.build.lib.analysis.BlazeDirectories; -import com.google.devtools.build.lib.analysis.ConfiguredRuleClassProvider; import com.google.devtools.build.lib.analysis.WorkspaceStatusAction; import com.google.devtools.build.lib.exec.BinTools; import com.google.devtools.build.lib.packages.PackageFactory; @@ -63,12 +62,10 @@ public final class WorkspaceBuilder { BlazeWorkspace build( BlazeRuntime runtime, PackageFactory packageFactory, - ConfiguredRuleClassProvider ruleClassProvider, SubscriberExceptionHandler eventBusExceptionHandler) throws AbruptExitException { // Set default values if none are set. if (skyframeExecutorFactory == null) { - skyframeExecutorFactory = - new SequencedSkyframeExecutorFactory(runtime.getDefaultBuildOptions()); + skyframeExecutorFactory = new SequencedSkyframeExecutorFactory(); } SkyframeExecutor skyframeExecutor = diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/BUILD b/src/main/java/com/google/devtools/build/lib/skyframe/BUILD index ade05efb9b5058..9485ec4970f680 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/BUILD +++ b/src/main/java/com/google/devtools/build/lib/skyframe/BUILD @@ -1113,7 +1113,6 @@ java_library( "//src/main/java/com/google/devtools/build/lib/pkgcache", "//src/main/java/com/google/devtools/build/skyframe", "//src/main/java/com/google/devtools/build/skyframe:skyframe-objects", - "//third_party:flogger", "//third_party:guava", "//third_party:jsr305", ], @@ -2449,7 +2448,6 @@ java_library( "//src/main/java/com/google/devtools/build/lib/cmdline", "//src/main/java/com/google/devtools/build/lib/concurrent", "//src/main/java/com/google/devtools/build/lib/pkgcache", - "//src/main/java/com/google/devtools/build/lib/supplier", "//src/main/java/com/google/devtools/build/lib/vfs:pathfragment", "//src/main/java/com/google/devtools/build/skyframe:skyframe-objects", "//third_party:guava", diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/SequencedSkyframeExecutor.java b/src/main/java/com/google/devtools/build/lib/skyframe/SequencedSkyframeExecutor.java index 806f2d620b86d0..cf5918f094646f 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/SequencedSkyframeExecutor.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/SequencedSkyframeExecutor.java @@ -36,7 +36,6 @@ import com.google.devtools.build.lib.analysis.ConfiguredTarget; import com.google.devtools.build.lib.analysis.ConfiguredTargetValue; import com.google.devtools.build.lib.analysis.WorkspaceStatusAction.Factory; -import com.google.devtools.build.lib.analysis.config.BuildOptions; import com.google.devtools.build.lib.analysis.configuredtargets.RuleConfiguredTarget; import com.google.devtools.build.lib.bugreport.BugReporter; import com.google.devtools.build.lib.buildtool.BuildRequestOptions; @@ -172,7 +171,6 @@ private SequencedSkyframeExecutor( ImmutableList buildFilesByPriority, ExternalPackageHelper externalPackageHelper, ActionOnIOExceptionReadingBuildFile actionOnIOExceptionReadingBuildFile, - BuildOptions defaultBuildOptions, @Nullable ManagedDirectoriesKnowledge managedDirectoriesKnowledge, BugReporter bugReporter) { super( @@ -192,7 +190,6 @@ private SequencedSkyframeExecutor( actionOnIOExceptionReadingBuildFile, /*shouldUnblockCpuWorkWhenFetchingDeps=*/ false, GraphInconsistencyReceiver.THROWING, - defaultBuildOptions, new PackageProgressReceiver(), new ConfiguredTargetProgressReceiver(), managedDirectoriesKnowledge, @@ -301,11 +298,9 @@ protected void invalidate(Predicate pred) { recordingDiffer.invalidate(Iterables.filter(memoizingEvaluator.getValues().keySet(), pred)); } - /** - * Sets the packages that should be treated as deleted and ignored. - */ + /** Sets the packages that should be treated as deleted and ignored. */ @Override - @VisibleForTesting // productionVisibility = Visibility.PRIVATE + @VisibleForTesting // productionVisibility = Visibility.PRIVATE public void setDeletedPackages(Iterable pkgs) { ImmutableSet newDeletedPackagesSet = ImmutableSet.copyOf(pkgs); @@ -330,7 +325,7 @@ public void handleDiffsForTesting(ExtendedEventHandler eventHandler) dropConfiguredTargetsNow(eventHandler); super.lastAnalysisDiscarded = false; } - handleDiffs(eventHandler, /*checkOutputFiles=*/false, OptionsProvider.EMPTY); + handleDiffs(eventHandler, /*checkOutputFiles=*/ false, OptionsProvider.EMPTY); } @Nullable @@ -416,8 +411,7 @@ private void invalidateCachedWorkspacePathsStates() { private void handleClientEnvironmentChanges() { // Remove deleted client environmental variables. Iterable deletedKeys = - Sets.difference(previousClientEnvironment, clientEnv.get().keySet()) - .stream() + Sets.difference(previousClientEnvironment, clientEnv.get().keySet()).stream() .map(ClientEnvironmentFunction::key) .collect(ImmutableList.toImmutableList()); recordingDiffer.invalidate(deletedKeys); @@ -471,8 +465,7 @@ private void handleDiffsWithMissingDiffInformation( boolean managedDirectoriesChanged, int fsvcThreads) throws InterruptedException { - ExternalFilesKnowledge externalFilesKnowledge = - externalFilesHelper.getExternalFilesKnowledge(); + ExternalFilesKnowledge externalFilesKnowledge = externalFilesHelper.getExternalFilesKnowledge(); if (pathEntriesWithoutDiffInformation.isEmpty() && Iterables.isEmpty(customDirtinessCheckers) && ((!externalFilesKnowledge.anyOutputFilesSeen || !checkOutputFiles) @@ -594,22 +587,22 @@ private static void logDiffInfo( int numWithoutNewValues, Map changedWithNewValue) { int numModified = changedWithNewValue.size() + numWithoutNewValues; - StringBuilder result = new StringBuilder("DiffAwareness found ") - .append(numModified) - .append(" modified source files and directory listings"); + StringBuilder result = + new StringBuilder("DiffAwareness found ") + .append(numModified) + .append(" modified source files and directory listings"); if (!Iterables.isEmpty(pathEntries)) { result.append(" for "); result.append(Joiner.on(", ").join(pathEntries)); } if (numModified > 0) { - Iterable allModifiedKeys = Iterables.concat(changedWithoutNewValue, - changedWithNewValue.keySet()); + Iterable allModifiedKeys = + Iterables.concat(changedWithoutNewValue, changedWithNewValue.keySet()); Iterable trimmed = Iterables.limit(allModifiedKeys, MAX_NUMBER_OF_CHANGED_KEYS_TO_LOG); - result.append(": ") - .append(Joiner.on(", ").join(trimmed)); + result.append(": ").append(Joiner.on(", ").join(trimmed)); if (numModified > MAX_NUMBER_OF_CHANGED_KEYS_TO_LOG) { result.append(", ..."); @@ -762,30 +755,29 @@ public List getRuleStats(ExtendedEventHandler eventHandler) { SkyFunctionName functionName = key.functionName(); if (value instanceof RuleConfiguredTargetValue) { RuleConfiguredTargetValue ctValue = (RuleConfiguredTargetValue) value; - ConfiguredTarget configuredTarget = ctValue.getConfiguredTarget(); - if (configuredTarget instanceof RuleConfiguredTarget) { - - Rule rule; - try { - rule = - (Rule) getPackageManager().getTarget(eventHandler, configuredTarget.getLabel()); - } catch (NoSuchPackageException | NoSuchTargetException | InterruptedException e) { - throw new IllegalStateException( - "Failed to get Rule target from package when calculating stats.", e); - } - RuleClass ruleClass = rule.getRuleClassObject(); - RuleStat ruleStat = - ruleStats.computeIfAbsent( - ruleClass.getKey(), k -> new RuleStat(k, ruleClass.getName(), true)); - ruleStat.addRule(ctValue.getNumActions()); + ConfiguredTarget configuredTarget = ctValue.getConfiguredTarget(); + if (configuredTarget instanceof RuleConfiguredTarget) { + + Rule rule; + try { + rule = (Rule) getPackageManager().getTarget(eventHandler, configuredTarget.getLabel()); + } catch (NoSuchPackageException | NoSuchTargetException | InterruptedException e) { + throw new IllegalStateException( + "Failed to get Rule target from package when calculating stats.", e); } - } else if (functionName.equals(SkyFunctions.ASPECT)) { - AspectValue aspectValue = (AspectValue) value; - AspectClass aspectClass = aspectValue.getAspect().getAspectClass(); + RuleClass ruleClass = rule.getRuleClassObject(); RuleStat ruleStat = ruleStats.computeIfAbsent( - aspectClass.getKey(), k -> new RuleStat(k, aspectClass.getName(), false)); - ruleStat.addRule(aspectValue.getNumActions()); + ruleClass.getKey(), k -> new RuleStat(k, ruleClass.getName(), true)); + ruleStat.addRule(ctValue.getNumActions()); + } + } else if (functionName.equals(SkyFunctions.ASPECT)) { + AspectValue aspectValue = (AspectValue) value; + AspectClass aspectClass = aspectValue.getAspect().getAspectClass(); + RuleStat ruleStat = + ruleStats.computeIfAbsent( + aspectClass.getKey(), k -> new RuleStat(k, aspectClass.getName(), false)); + ruleStat.addRule(aspectValue.getNumActions()); } } return new ArrayList<>(ruleStats.values()); @@ -933,8 +925,10 @@ public void deleteOldNodes(long versionWindowForDirtyGc) { @Override public void dumpPackages(PrintStream out) { - Iterable packageSkyKeys = Iterables.filter(memoizingEvaluator.getValues().keySet(), - SkyFunctions.isSkyFunction(SkyFunctions.PACKAGE)); + Iterable packageSkyKeys = + Iterables.filter( + memoizingEvaluator.getValues().keySet(), + SkyFunctions.isSkyFunction(SkyFunctions.PACKAGE)); out.println(Iterables.size(packageSkyKeys) + " packages"); for (SkyKey packageSkyKey : packageSkyKeys) { Package pkg = ((PackageValue) memoizingEvaluator.getValues().get(packageSkyKey)).getPackage(); @@ -1034,7 +1028,6 @@ public static final class Builder { FileSystem fileSystem; BlazeDirectories directories; ActionKeyContext actionKeyContext; - BuildOptions defaultBuildOptions; private CrossRepositoryLabelViolationStrategy crossRepositoryLabelViolationStrategy; private ImmutableList buildFilesByPriority; private ExternalPackageHelper externalPackageHelper; @@ -1058,7 +1051,6 @@ public SequencedSkyframeExecutor build() { Preconditions.checkNotNull(fileSystem); Preconditions.checkNotNull(directories); Preconditions.checkNotNull(actionKeyContext); - Preconditions.checkNotNull(defaultBuildOptions); Preconditions.checkNotNull(crossRepositoryLabelViolationStrategy); Preconditions.checkNotNull(buildFilesByPriority); Preconditions.checkNotNull(externalPackageHelper); @@ -1082,7 +1074,6 @@ public SequencedSkyframeExecutor build() { buildFilesByPriority, externalPackageHelper, actionOnIOExceptionReadingBuildFile, - defaultBuildOptions, managedDirectoriesKnowledge, bugReporter); skyframeExecutor.init(); @@ -1109,11 +1100,6 @@ public Builder setActionKeyContext(ActionKeyContext actionKeyContext) { return this; } - public Builder setDefaultBuildOptions(BuildOptions defaultBuildOptions) { - this.defaultBuildOptions = defaultBuildOptions; - return this; - } - public Builder setIgnoredPackagePrefixesFunction(SkyFunction ignoredPackagePrefixesFunction) { this.ignoredPackagePrefixesFunction = ignoredPackagePrefixesFunction; return this; diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/SequencedSkyframeExecutorFactory.java b/src/main/java/com/google/devtools/build/lib/skyframe/SequencedSkyframeExecutorFactory.java index 568583a8d03163..42220a36ba39e3 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/SequencedSkyframeExecutorFactory.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/SequencedSkyframeExecutorFactory.java @@ -17,7 +17,6 @@ import com.google.devtools.build.lib.actions.ActionKeyContext; import com.google.devtools.build.lib.analysis.BlazeDirectories; import com.google.devtools.build.lib.analysis.WorkspaceStatusAction.Factory; -import com.google.devtools.build.lib.analysis.config.BuildOptions; import com.google.devtools.build.lib.bugreport.BugReporter; import com.google.devtools.build.lib.packages.PackageFactory; import com.google.devtools.build.lib.vfs.FileSystem; @@ -25,16 +24,8 @@ import com.google.devtools.build.skyframe.SkyFunctionName; import javax.annotation.Nullable; -/** - * A factory of SkyframeExecutors that returns SequencedSkyframeExecutor. - */ -public class SequencedSkyframeExecutorFactory implements SkyframeExecutorFactory { - - private final BuildOptions defaultBuildOptions; - - public SequencedSkyframeExecutorFactory(BuildOptions defaultBuildOptions) { - this.defaultBuildOptions = defaultBuildOptions; - } +/** A factory of SkyframeExecutors that returns SequencedSkyframeExecutor. */ +public final class SequencedSkyframeExecutorFactory implements SkyframeExecutorFactory { @Override public SkyframeExecutor create( @@ -53,7 +44,6 @@ public SkyframeExecutor create( .setFileSystem(fileSystem) .setDirectories(directories) .setActionKeyContext(actionKeyContext) - .setDefaultBuildOptions(defaultBuildOptions) .setWorkspaceStatusActionFactory(workspaceStatusActionFactory) .setDiffAwarenessFactories(diffAwarenessFactories) .setExtraSkyFunctions(extraSkyFunctions) diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java b/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java index 02f4638342c615..8dc1f1e4f76aed 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java @@ -221,7 +221,6 @@ import java.util.Optional; import java.util.Set; import java.util.UUID; -import java.util.concurrent.Callable; import java.util.concurrent.Semaphore; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; @@ -362,9 +361,6 @@ public abstract class SkyframeExecutor implements WalkableGraphFactory, Configur private final boolean shouldUnblockCpuWorkWhenFetchingDeps; - // TODO(b/185778053): This isn't needed anymore. Just use the fragments from ruleClassProvider. - private final BuildOptions defaultBuildOptions; - private PerBuildSyscallCache perBuildSyscallCache; private int lastConcurrencyLevel = -1; @@ -423,7 +419,6 @@ protected SkyframeExecutor( ActionOnIOExceptionReadingBuildFile actionOnIOExceptionReadingBuildFile, boolean shouldUnblockCpuWorkWhenFetchingDeps, GraphInconsistencyReceiver graphInconsistencyReceiver, - BuildOptions defaultBuildOptions, @Nullable PackageProgressReceiver packageProgress, @Nullable ConfiguredTargetProgressReceiver configuredTargetProgress, @Nullable ManagedDirectoriesKnowledge managedDirectoriesKnowledge, @@ -453,7 +448,6 @@ protected SkyframeExecutor( this.extraSkyFunctions = extraSkyFunctions; this.ruleClassProvider = (ConfiguredRuleClassProvider) pkgFactory.getRuleClassProvider(); - this.defaultBuildOptions = defaultBuildOptions; this.skyframeActionExecutor = new SkyframeActionExecutor( actionKeyContext, @@ -1270,7 +1264,7 @@ protected Differencer.Diff getDiff( int fsvcThreads) throws InterruptedException { if (modifiedSourceFiles.isEmpty()) { - return new ImmutableDiff(ImmutableList.of(), ImmutableMap.of()); + return new ImmutableDiff(ImmutableList.of(), ImmutableMap.of()); } // TODO(bazel-team): change ModifiedFileSet to work with RootedPaths instead of PathFragments. Collection dirtyFileStateSkyKeys = @@ -1313,7 +1307,7 @@ protected Differencer.Diff getDiff( // Invalidate the directory listing for the path's parent directory if the change was // relevant (e.g. path turned from a symlink into a directory) OR if we don't have enough // information to determine it was irrelevant. - boolean changedType = false; + boolean changedType; if (newValue == null) { changedType = true; } else if (oldValue != null) { @@ -1385,9 +1379,10 @@ public void preparePackageLoading( if (!packageOptions.enforceConfigSettingVisibility) { setConfigSettingVisibilityPolicty(ConfigSettingVisibilityPolicy.LEGACY_OFF); } else { - setConfigSettingVisibilityPolicty(packageOptions.configSettingPrivateDefaultVisibility - ? ConfigSettingVisibilityPolicy.DEFAULT_STANDARD - : ConfigSettingVisibilityPolicy.DEFAULT_PUBLIC); + setConfigSettingVisibilityPolicty( + packageOptions.configSettingPrivateDefaultVisibility + ? ConfigSettingVisibilityPolicy.DEFAULT_STANDARD + : ConfigSettingVisibilityPolicy.DEFAULT_PUBLIC); } StarlarkSemantics starlarkSemantics = getEffectiveStarlarkSemantics(buildLanguageOptions); @@ -1605,7 +1600,6 @@ public EvaluationResult runExclusiveTest( OptionsProvider options, ActionCacheChecker actionCacheChecker, TopDownActionCache topDownActionCache, - @Nullable EvaluationProgressReceiver executionProgressReceiver, TopLevelArtifactContext topLevelArtifactContext) throws InterruptedException { checkActive(); @@ -1712,11 +1706,6 @@ EvaluationResult targetPatterns( return buildDriver.evaluate(patternSkyKeys, evaluationContext); } - @VisibleForTesting - public BuildOptions getDefaultBuildOptions() { - return defaultBuildOptions; - } - /** * Returns the {@link ConfiguredTargetAndData}s corresponding to the given keys. * @@ -1983,7 +1972,7 @@ private ImmutableList getConfigurations( if (e instanceof NoSuchThingException) { e = new InvalidConfigurationException(((NoSuchThingException) e).getDetailedExitCode(), e); } else if (e == null && !error.getCycleInfo().isEmpty()) { - getCyclesReporter().reportCycles(error.getCycleInfo(), firstError.getKey(), eventHandler); + cyclesReporter.reportCycles(error.getCycleInfo(), firstError.getKey(), eventHandler); e = new InvalidConfigurationException( "cannot load build configuration because of this cycle", Code.CYCLE); @@ -2109,7 +2098,7 @@ private PlatformMappingValue getPlatformMappingValue( return (PlatformMappingValue) evaluationResult.get(platformMappingKey); } - private BuildConfigurationValue.Key toConfigurationKey( + private static BuildConfigurationValue.Key toConfigurationKey( PlatformMappingValue platformMappingValue, FragmentClassSet depFragments, BuildOptions toOption) @@ -2214,9 +2203,7 @@ public BuildConfiguration getConfigurationForTesting( throws InterruptedException, OptionsParsingException, InvalidConfigurationException { SkyKey key = BuildConfigurationValue.keyWithPlatformMapping( - getPlatformMappingValue(eventHandler, options), - fragments, - options); + getPlatformMappingValue(eventHandler, options), fragments, options); BuildConfigurationValue result = (BuildConfigurationValue) evaluate( @@ -2457,9 +2444,7 @@ public Predicate filterActionConflictsForTopLevelArtifacts( @Override public EvaluationResult prepareAndGet( Set roots, EvaluationContext evaluationContext) throws InterruptedException { - EvaluationResult evaluationResult = - buildDriver.evaluate(roots, evaluationContext.getCopyWithKeepGoing(/*keepGoing=*/ true)); - return evaluationResult; + return buildDriver.evaluate(roots, evaluationContext.getCopyWithKeepGoing(/*keepGoing=*/ true)); } /** @@ -2516,21 +2501,13 @@ private ActionAnalysisMetadata getGeneratingAction( *

    For legacy compatibility only. */ public ActionGraph getActionGraph(final ExtendedEventHandler eventHandler) { - return new ActionGraph() { - @Override - public ActionAnalysisMetadata getGeneratingAction(final Artifact artifact) { - try { - return callUninterruptibly( - new Callable() { - @Override - public ActionAnalysisMetadata call() throws InterruptedException { - return SkyframeExecutor.this.getGeneratingAction(eventHandler, artifact); - } - }); - } catch (Exception e) { - throw new IllegalStateException( - "Error getting generating action: " + artifact.prettyPrint(), e); - } + return artifact -> { + try { + return callUninterruptibly( + () -> SkyframeExecutor.this.getGeneratingAction(eventHandler, artifact)); + } catch (Exception e) { + throw new IllegalStateException( + "Error getting generating action: " + artifact.prettyPrint(), e); } }; } @@ -2791,7 +2768,7 @@ CyclesReporter getCyclesReporter() { /** Convenience method with same semantics as {@link CyclesReporter#reportCycles}. */ public void reportCycles( ExtendedEventHandler eventHandler, Iterable cycles, SkyKey topLevelKey) { - getCyclesReporter().reportCycles(cycles, topLevelKey, eventHandler); + cyclesReporter.reportCycles(cycles, topLevelKey, eventHandler); } public void setActionExecutionProgressReportingObjects( @@ -2907,7 +2884,7 @@ private void tryThrowTargetParsingException( exc = new TargetParsingException( "cycles detected during target parsing", TargetPatterns.Code.CYCLE); - getCyclesReporter().reportCycles(errorInfo.getCycleInfo(), key, eventHandler); + cyclesReporter.reportCycles(errorInfo.getCycleInfo(), key, eventHandler); // Fallback: we don't know which patterns failed, specifically, so we report the entire // set as being in error. eventHandler.post(PatternExpandingError.failed(targetPatterns, exc.getMessage())); @@ -2971,7 +2948,7 @@ public PrepareAnalysisPhaseValue prepareAnalysisPhase( ErrorInfo errorInfo = evalResult.getError(key); Exception e = errorInfo.getException(); if (e == null && !errorInfo.getCycleInfo().isEmpty()) { - getCyclesReporter().reportCycles(errorInfo.getCycleInfo(), key, eventHandler); + cyclesReporter.reportCycles(errorInfo.getCycleInfo(), key, eventHandler); e = new InvalidConfigurationException( "cannot load build configuration because of this cycle", Code.CYCLE); @@ -2988,8 +2965,7 @@ public PrepareAnalysisPhaseValue prepareAnalysisPhase( configuredTargetProgress.reset(); } - PrepareAnalysisPhaseValue prepareAnalysisPhaseValue = evalResult.get(key); - return prepareAnalysisPhaseValue; + return evalResult.get(key); } /** A progress receiver to track analysis invalidation and update progress messages. */ 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 c25ad9eecd3dc7..20e4736f44f680 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 @@ -89,7 +89,7 @@ import com.google.devtools.common.options.Options; import com.google.devtools.common.options.OptionsParser; import java.util.Arrays; -import java.util.HashSet; +import java.util.EnumSet; import java.util.Map; import java.util.Optional; import java.util.Set; @@ -126,7 +126,7 @@ public enum Flag { /** Helper class to make it easy to enable and disable flags. */ public static final class FlagBuilder { - private final Set flags = new HashSet<>(); + private final Set flags = EnumSet.noneOf(Flag.class); public FlagBuilder with(Flag flag) { flags.add(flag); @@ -193,8 +193,6 @@ protected SkyframeExecutor createSkyframeExecutor(PackageFactory pkgFactory) { .setFileSystem(fileSystem) .setDirectories(directories) .setActionKeyContext(actionKeyContext) - .setDefaultBuildOptions( - DefaultBuildOptionsForTesting.getDefaultBuildOptionsForTest(ruleClassProvider)) .setWorkspaceStatusActionFactory(workspaceStatusActionFactory) .setExtraSkyFunctions(analysisMock.getSkyFunctions(directories)) .build(); @@ -254,7 +252,7 @@ protected AnalysisMock getAnalysisMock() { return AnalysisMock.get(); } - protected InternalTestExecutionMode getInternalTestExecutionMode() { + protected static InternalTestExecutionMode getInternalTestExecutionMode() { return InternalTestExecutionMode.NORMAL; } @@ -372,9 +370,9 @@ protected AnalysisResult update( packageOptions, buildLanguageOptions, UUID.randomUUID(), - ImmutableMap.of(), + ImmutableMap.of(), new TimestampGranularityMonitor(BlazeClock.instance())); - skyframeExecutor.setActionEnv(ImmutableMap.of()); + skyframeExecutor.setActionEnv(ImmutableMap.of()); skyframeExecutor.invalidateFilesUnderPathForTesting( reporter, ModifiedFileSet.EVERYTHING_MODIFIED, Root.fromPath(rootDirectory)); @@ -414,24 +412,23 @@ protected AnalysisResult update( protected AnalysisResult update( EventBus eventBus, FlagBuilder config, ImmutableList aspects, String... labels) throws Exception { - return update( - eventBus, config, /*explicitTargetPatterns=*/ ImmutableSet.of(), aspects, labels); + return update(eventBus, config, /*explicitTargetPatterns=*/ ImmutableSet.of(), aspects, labels); } protected AnalysisResult update(EventBus eventBus, FlagBuilder config, String... labels) throws Exception { - return update(eventBus, config, /*aspects=*/ ImmutableList.of(), labels); + return update(eventBus, config, /*aspects=*/ ImmutableList.of(), labels); } protected AnalysisResult update(FlagBuilder config, String... labels) throws Exception { - return update(new EventBus(), config, /*aspects=*/ImmutableList.of(), labels); + return update(new EventBus(), config, /*aspects=*/ ImmutableList.of(), labels); } /** * Update the BuildView: syncs the package cache; loads and analyzes the given labels. */ protected AnalysisResult update(String... labels) throws Exception { - return update(new EventBus(), defaultFlags(), /*aspects=*/ImmutableList.of(), labels); + return update(new EventBus(), defaultFlags(), /*aspects=*/ ImmutableList.of(), labels); } protected AnalysisResult update(ImmutableList aspects, String... labels) @@ -594,11 +591,9 @@ protected void assertNumberOfAnalyzedConfigurationsOfTargets( targetsWithCounts.entrySet().stream() .collect( toImmutableMap( - entry -> Label.parseAbsoluteUnchecked(entry.getKey()), - entry -> entry.getValue())); + entry -> Label.parseAbsoluteUnchecked(entry.getKey()), Map.Entry::getValue)); ImmutableMap actual = - expected.keySet().stream() - .collect(toImmutableMap(label -> label, label -> actualSet.count(label))); + expected.keySet().stream().collect(toImmutableMap(label -> label, actualSet::count)); assertThat(actual).containsExactlyEntriesIn(expected); } 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 53a7142b7ec61a..f4b9c194d085c2 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 @@ -316,8 +316,6 @@ public void initializeSkyframeExecutor(boolean doPackageLoadingChecks) throws Ex .setFileSystem(fileSystem) .setDirectories(directories) .setActionKeyContext(actionKeyContext) - .setDefaultBuildOptions( - DefaultBuildOptionsForTesting.getDefaultBuildOptionsForTest(ruleClassProvider)) .setWorkspaceStatusActionFactory(workspaceStatusActionFactory) .setExtraSkyFunctions(analysisMock.getSkyFunctions(directories)) .setManagedDirectoriesKnowledge(getManagedDirectoriesKnowledge()) 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 8affd92bffd87a..b61b64a37dfdfe 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 @@ -91,7 +91,7 @@ public static final class TestOptions extends OptionsBase { @Before public final void initializeSkyframeExecutor() throws Exception { workspace = rootDirectory; - analysisMock = getAnalysisMock(); + analysisMock = AnalysisMock.get(); ConfiguredRuleClassProvider ruleClassProvider = analysisMock.createRuleClassProvider(); PathPackageLocator pkgLocator = @@ -146,8 +146,6 @@ public final void initializeSkyframeExecutor() throws Exception { .setFileSystem(fileSystem) .setDirectories(directories) .setActionKeyContext(actionKeyContext) - .setDefaultBuildOptions( - DefaultBuildOptionsForTesting.getDefaultBuildOptionsForTest(ruleClassProvider)) .setWorkspaceStatusActionFactory(workspaceStatusActionFactory) .setExtraSkyFunctions(analysisMock.getSkyFunctions(directories)) .build(); @@ -174,9 +172,9 @@ public final void initializeSkyframeExecutor() throws Exception { packageOptions, Options.getDefaults(BuildLanguageOptions.class), UUID.randomUUID(), - ImmutableMap.of(), + ImmutableMap.of(), new TimestampGranularityMonitor(BlazeClock.instance())); - skyframeExecutor.setActionEnv(ImmutableMap.of()); + skyframeExecutor.setActionEnv(ImmutableMap.of()); mockToolsConfig = new MockToolsConfig(rootDirectory); analysisMock.setupMockClient(mockToolsConfig); @@ -184,11 +182,7 @@ public final void initializeSkyframeExecutor() throws Exception { buildOptionClasses = ruleClassProvider.getConfigurationOptions(); } - protected AnalysisMock getAnalysisMock() { - return AnalysisMock.get(); - } - - protected void checkError(String expectedMessage, String... options) throws Exception { + protected void checkError(String expectedMessage, String... options) { reporter.removeHandler(failFastHandler); assertThrows(InvalidConfigurationException.class, () -> create(options)); assertContainsEvent(expectedMessage); @@ -228,9 +222,8 @@ protected BuildConfigurationCollection createCollection( parser.getOptions(TestOptions.class).multiCpus); skyframeExecutor.handleDiffsForTesting(reporter); - BuildConfigurationCollection collection = skyframeExecutor.createConfigurations( + return skyframeExecutor.createConfigurations( reporter, BuildOptions.of(buildOptionClasses, parser), multiCpu, false); - return collection; } /** @@ -265,8 +258,8 @@ protected BuildConfiguration createHost(String... args) throws Exception { return createCollection(args).getHostConfiguration(); } - public void assertConfigurationsHaveUniqueOutputDirectories( - BuildConfigurationCollection configCollection) throws Exception { + public static void assertConfigurationsHaveUniqueOutputDirectories( + BuildConfigurationCollection configCollection) { Map outputPaths = new HashMap<>(); for (BuildConfiguration config : configCollection.getTargetConfigurations()) { BuildConfiguration otherConfig = diff --git a/src/test/java/com/google/devtools/build/lib/bazel/rules/android/BUILD b/src/test/java/com/google/devtools/build/lib/bazel/rules/android/BUILD index 42e8d1a5a85a96..954f694c3ba2a4 100644 --- a/src/test/java/com/google/devtools/build/lib/bazel/rules/android/BUILD +++ b/src/test/java/com/google/devtools/build/lib/bazel/rules/android/BUILD @@ -69,7 +69,6 @@ java_test( "//src/main/java/com/google/devtools/build/lib/rules/android", "//src/main/java/com/google/devtools/build/lib/skyframe:configured_target_and_data", "//src/main/java/com/google/devtools/build/lib/vfs", - "//src/test/java/com/google/devtools/build/lib/analysis/util", "//src/test/java/com/google/devtools/build/lib/packages:testutil", "//src/test/java/com/google/devtools/build/lib/rules/android:AndroidBuildViewTestCase", "//src/test/java/com/google/devtools/build/lib/rules/android:AndroidLocalTestTest", diff --git a/src/test/java/com/google/devtools/build/lib/cmdline/BUILD b/src/test/java/com/google/devtools/build/lib/cmdline/BUILD index 00e723a3b6c38c..cfca030825823c 100644 --- a/src/test/java/com/google/devtools/build/lib/cmdline/BUILD +++ b/src/test/java/com/google/devtools/build/lib/cmdline/BUILD @@ -20,7 +20,6 @@ java_library( "//src/main/java/com/google/devtools/build/lib/cmdline:LabelValidator", "//src/main/java/com/google/devtools/build/lib/vfs:pathfragment", "//src/main/java/net/starlark/java/eval", - "//src/main/java/net/starlark/java/syntax", "//src/test/java/com/google/devtools/build/lib/testutil:TestUtils", "//third_party:guava", "//third_party:guava-testlib", diff --git a/src/test/java/com/google/devtools/build/lib/packages/BUILD b/src/test/java/com/google/devtools/build/lib/packages/BUILD index b855dba383c50c..b2cdc904b6b8a4 100644 --- a/src/test/java/com/google/devtools/build/lib/packages/BUILD +++ b/src/test/java/com/google/devtools/build/lib/packages/BUILD @@ -149,7 +149,6 @@ java_library( "//src/main/java/com/google/devtools/build/lib/vfs", "//src/main/java/com/google/devtools/build/lib/vfs:pathfragment", "//src/main/java/com/google/devtools/common/options", - "//src/test/java/com/google/devtools/build/lib/analysis/util:test-build-options", "//src/test/java/com/google/devtools/build/lib/testutil", "//src/test/java/com/google/devtools/build/lib/testutil:SkyframeExecutorTestHelper", "//src/test/java/com/google/devtools/build/lib/testutil:TestConstants", diff --git a/src/test/java/com/google/devtools/build/lib/packages/util/PackageLoadingTestCase.java b/src/test/java/com/google/devtools/build/lib/packages/util/PackageLoadingTestCase.java index c0955b04936890..9c7cb08e84c4f8 100644 --- a/src/test/java/com/google/devtools/build/lib/packages/util/PackageLoadingTestCase.java +++ b/src/test/java/com/google/devtools/build/lib/packages/util/PackageLoadingTestCase.java @@ -22,7 +22,6 @@ import com.google.devtools.build.lib.analysis.ConfiguredRuleClassProvider; import com.google.devtools.build.lib.analysis.RuleDefinition; import com.google.devtools.build.lib.analysis.ServerDirectories; -import com.google.devtools.build.lib.analysis.util.DefaultBuildOptionsForTesting; import com.google.devtools.build.lib.clock.BlazeClock; import com.google.devtools.build.lib.cmdline.Label; import com.google.devtools.build.lib.cmdline.LabelSyntaxException; @@ -50,7 +49,6 @@ import com.google.devtools.build.lib.vfs.Root; import com.google.devtools.common.options.Options; import com.google.devtools.common.options.OptionsParser; -import java.io.IOException; import java.util.List; import java.util.Optional; import java.util.Set; @@ -126,8 +124,6 @@ private SkyframeExecutor createSkyframeExecutor() { .setFileSystem(fileSystem) .setDirectories(directories) .setActionKeyContext(actionKeyContext) - .setDefaultBuildOptions( - DefaultBuildOptionsForTesting.getDefaultBuildOptionsForTest(ruleClassProvider)) .build(); skyframeExecutor.injectExtraPrecomputedValues( ImmutableList.of( @@ -138,7 +134,7 @@ private SkyframeExecutor createSkyframeExecutor() { } protected Iterable getEnvironmentExtensions() { - return ImmutableList.of(); + return ImmutableList.of(); } protected void setUpSkyframe(RuleVisibility defaultVisibility) { @@ -158,9 +154,9 @@ protected void setUpSkyframe(RuleVisibility defaultVisibility) { packageOptions, Options.getDefaults(BuildLanguageOptions.class), UUID.randomUUID(), - ImmutableMap.of(), + ImmutableMap.of(), new TimestampGranularityMonitor(BlazeClock.instance())); - skyframeExecutor.setActionEnv(ImmutableMap.of()); + skyframeExecutor.setActionEnv(ImmutableMap.of()); } private void setUpSkyframe() { @@ -179,9 +175,9 @@ private void setUpSkyframe() { packageOptions, buildLanguageOptions, UUID.randomUUID(), - ImmutableMap.of(), + ImmutableMap.of(), new TimestampGranularityMonitor(BlazeClock.instance())); - skyframeExecutor.setActionEnv(ImmutableMap.of()); + skyframeExecutor.setActionEnv(ImmutableMap.of()); skyframeExecutor.setDeletedPackages(ImmutableSet.copyOf(packageOptions.getDeletedPackages())); } @@ -228,8 +224,6 @@ protected Target getTarget(Label label) * @param ruleName the name of the rule. * @param lines the text of the rule. * @return the rule instance for the created rule. - * @throws IOException - * @throws Exception */ protected Rule scratchRule(String packageName, String ruleName, String... lines) throws Exception { @@ -239,12 +233,13 @@ protected Rule scratchRule(String packageName, String ruleName, String... lines) /** * A Utility method that generates build file rules for tests. + * * @param rule the name of the rule class. * @param name the name of the rule instance. * @param body an array of strings containing the contents of the rule. * @return a string containing the build file rule. */ - protected String genRule(String rule, String name, String... body) { + protected static String genRule(String rule, String name, String... body) { StringBuilder buf = new StringBuilder(); buf.append(rule); buf.append("(name='"); diff --git a/src/test/java/com/google/devtools/build/lib/pkgcache/BUILD b/src/test/java/com/google/devtools/build/lib/pkgcache/BUILD index 5624cedca38f83..500b99dbbdaaf3 100644 --- a/src/test/java/com/google/devtools/build/lib/pkgcache/BUILD +++ b/src/test/java/com/google/devtools/build/lib/pkgcache/BUILD @@ -110,7 +110,6 @@ java_library( "//src/main/java/com/google/devtools/build/lib/vfs:pathfragment", "//src/main/java/com/google/devtools/build/lib/vfs/inmemoryfs", "//src/main/java/com/google/devtools/common/options", - "//src/test/java/com/google/devtools/build/lib/analysis/util:test-build-options", "//src/test/java/com/google/devtools/build/lib/packages:testutil", "//src/test/java/com/google/devtools/build/lib/testutil", "//src/test/java/com/google/devtools/build/lib/testutil:SkyframeExecutorTestHelper", @@ -157,7 +156,6 @@ java_test( "//src/main/java/com/google/devtools/build/lib/actions", "//src/main/java/com/google/devtools/build/lib/analysis:analysis_cluster", "//src/main/java/com/google/devtools/build/lib/analysis:blaze_directories", - "//src/main/java/com/google/devtools/build/lib/analysis:config/build_options", "//src/main/java/com/google/devtools/build/lib/analysis:server_directories", "//src/main/java/com/google/devtools/build/lib/clock", "//src/main/java/com/google/devtools/build/lib/cmdline", @@ -170,7 +168,6 @@ java_test( "//src/main/java/com/google/devtools/build/lib/util/io", "//src/main/java/com/google/devtools/build/lib/vfs", "//src/main/java/com/google/devtools/common/options", - "//src/main/java/net/starlark/java/eval", "//src/main/java/net/starlark/java/syntax", "//src/test/java/com/google/devtools/build/lib/analysis/util", "//src/test/java/com/google/devtools/build/lib/testutil", @@ -202,7 +199,6 @@ java_test( "//src/main/java/com/google/devtools/build/lib/vfs/inmemoryfs", "//src/main/java/com/google/devtools/common/options", "//src/test/java/com/google/devtools/build/lib/analysis/util", - "//src/test/java/com/google/devtools/build/lib/analysis/util:test-build-options", "//src/test/java/com/google/devtools/build/lib/testutil", "//src/test/java/com/google/devtools/build/lib/testutil:SkyframeExecutorTestHelper", "//third_party:guava", @@ -236,7 +232,6 @@ java_library( "//src/main/java/com/google/devtools/build/lib/analysis:analysis_cluster", "//src/main/java/com/google/devtools/build/lib/analysis:blaze_directories", "//src/main/java/com/google/devtools/build/lib/analysis:build_view", - "//src/main/java/com/google/devtools/build/lib/analysis:config/build_options", "//src/main/java/com/google/devtools/build/lib/analysis:server_directories", "//src/main/java/com/google/devtools/build/lib/buildeventstream/proto:build_event_stream_java_proto", "//src/main/java/com/google/devtools/build/lib/cmdline", 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 2f7a516361b3f4..28d8dd959dd05f 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 @@ -23,7 +23,6 @@ import com.google.devtools.build.lib.analysis.ConfiguredRuleClassProvider; import com.google.devtools.build.lib.analysis.ServerDirectories; import com.google.devtools.build.lib.analysis.util.AnalysisMock; -import com.google.devtools.build.lib.analysis.util.DefaultBuildOptionsForTesting; import com.google.devtools.build.lib.cmdline.PackageIdentifier; import com.google.devtools.build.lib.packages.NoSuchPackageException; import com.google.devtools.build.lib.packages.Package; @@ -61,21 +60,19 @@ @RunWith(JUnit4.class) public class BuildFileModificationTest extends FoundationTestCase { - private ManualClock clock = new ManualClock(); - private AnalysisMock analysisMock; - private ConfiguredRuleClassProvider ruleClassProvider; + private final ManualClock clock = new ManualClock(); private SkyframeExecutor skyframeExecutor; private final ActionKeyContext actionKeyContext = new ActionKeyContext(); @Before - public final void disableLogging() throws Exception { + public final void disableLogging() { Logger.getLogger("com.google.devtools").setLevel(Level.SEVERE); } @Before - public final void initializeSkyframeExecutor() throws Exception { - analysisMock = AnalysisMock.get(); - ruleClassProvider = analysisMock.createRuleClassProvider(); + public final void initializeSkyframeExecutor() { + AnalysisMock analysisMock = AnalysisMock.get(); + ConfiguredRuleClassProvider ruleClassProvider = analysisMock.createRuleClassProvider(); BlazeDirectories directories = new BlazeDirectories( new ServerDirectories(outputBase, outputBase, outputBase), @@ -92,8 +89,6 @@ public final void initializeSkyframeExecutor() throws Exception { .setFileSystem(fileSystem) .setDirectories(directories) .setActionKeyContext(actionKeyContext) - .setDefaultBuildOptions( - DefaultBuildOptionsForTesting.getDefaultBuildOptionsForTest(ruleClassProvider)) .setExtraSkyFunctions(analysisMock.getSkyFunctions(directories)) .build(); skyframeExecutor.injectExtraPrecomputedValues( @@ -126,9 +121,9 @@ private void setUpSkyframe( packageOptions, buildLanguageOptions, UUID.randomUUID(), - ImmutableMap.of(), + ImmutableMap.of(), new TimestampGranularityMonitor(clock)); - skyframeExecutor.setActionEnv(ImmutableMap.of()); + skyframeExecutor.setActionEnv(ImmutableMap.of()); skyframeExecutor.setDeletedPackages(ImmutableSet.copyOf(packageOptions.getDeletedPackages())); } diff --git a/src/test/java/com/google/devtools/build/lib/pkgcache/IncrementalLoadingTest.java b/src/test/java/com/google/devtools/build/lib/pkgcache/IncrementalLoadingTest.java index 5d568ece5d2ebf..2f979e99663ddc 100644 --- a/src/test/java/com/google/devtools/build/lib/pkgcache/IncrementalLoadingTest.java +++ b/src/test/java/com/google/devtools/build/lib/pkgcache/IncrementalLoadingTest.java @@ -25,7 +25,6 @@ import com.google.devtools.build.lib.analysis.BlazeDirectories; import com.google.devtools.build.lib.analysis.ConfiguredRuleClassProvider; import com.google.devtools.build.lib.analysis.ServerDirectories; -import com.google.devtools.build.lib.analysis.util.DefaultBuildOptionsForTesting; import com.google.devtools.build.lib.clock.BlazeClock; import com.google.devtools.build.lib.cmdline.Label; import com.google.devtools.build.lib.events.Reporter; @@ -100,7 +99,8 @@ public Collection readdir(PathFragment path, boolean followSymlinks) tester = createTester(fs, clock); } - protected PackageLoadingTester createTester(FileSystem fs, ManualClock clock) throws Exception { + protected static PackageLoadingTester createTester(FileSystem fs, ManualClock clock) + throws Exception { return new PackageLoadingTester(fs, clock); } @@ -423,9 +423,8 @@ public DiffAwareness maybeCreate(Root pathEntry) { private final List changes = new ArrayList<>(); private boolean everythingModified = false; private ModifiedFileSet modifiedFileSet; - private final ActionKeyContext actionKeyContext = new ActionKeyContext(); - public PackageLoadingTester(FileSystem fs, ManualClock clock) throws IOException { + PackageLoadingTester(FileSystem fs, ManualClock clock) throws IOException { this.clock = clock; workspace = fs.getPath("/workspace"); workspace.createDirectory(); @@ -449,9 +448,7 @@ public PackageLoadingTester(FileSystem fs, ManualClock clock) throws IOException .setPkgFactory(pkgFactory) .setFileSystem(fs) .setDirectories(directories) - .setActionKeyContext(actionKeyContext) - .setDefaultBuildOptions( - DefaultBuildOptionsForTesting.getDefaultBuildOptionsForTest(ruleClassProvider)) + .setActionKeyContext(new ActionKeyContext()) .setDiffAwarenessFactories(ImmutableList.of(new ManualDiffAwarenessFactory())) .build(); SkyframeExecutorTestHelper.process(skyframeExecutor); @@ -472,9 +469,9 @@ public PackageLoadingTester(FileSystem fs, ManualClock clock) throws IOException packageOptions, Options.getDefaults(BuildLanguageOptions.class), UUID.randomUUID(), - ImmutableMap.of(), + ImmutableMap.of(), new TimestampGranularityMonitor(BlazeClock.instance())); - skyframeExecutor.setActionEnv(ImmutableMap.of()); + skyframeExecutor.setActionEnv(ImmutableMap.of()); } Path addFile(String fileName, String... content) throws IOException { @@ -489,7 +486,7 @@ Path addFile(String fileName, String... content) throws IOException { currentPath = currentPath.getParentDirectory(); } - FileSystemUtils.createDirectoryAndParents(buildFile.getParentDirectory()); + buildFile.getParentDirectory().createDirectoryAndParents(); FileSystemUtils.writeContentAsLatin1(buildFile, Joiner.on('\n').join(content)); return buildFile; } @@ -497,7 +494,7 @@ Path addFile(String fileName, String... content) throws IOException { void addSymlink(String fileName, String target) throws IOException { Path path = workspace.getRelative(fileName); Preconditions.checkState(!path.exists()); - FileSystemUtils.createDirectoryAndParents(path.getParentDirectory()); + path.getParentDirectory().createDirectoryAndParents(); path.createSymbolicLink(PathFragment.create(target)); changes.add(path); } @@ -562,9 +559,9 @@ void sync() throws InterruptedException, AbruptExitException { packageOptions, Options.getDefaults(BuildLanguageOptions.class), UUID.randomUUID(), - ImmutableMap.of(), + ImmutableMap.of(), new TimestampGranularityMonitor(BlazeClock.instance())); - skyframeExecutor.setActionEnv(ImmutableMap.of()); + skyframeExecutor.setActionEnv(ImmutableMap.of()); skyframeExecutor.invalidateFilesUnderPathForTesting( new Reporter(new EventBus()), modifiedFileSet, Root.fromPath(workspace)); ((SequencedSkyframeExecutor) skyframeExecutor) diff --git a/src/test/java/com/google/devtools/build/lib/pkgcache/LoadingPhaseRunnerTest.java b/src/test/java/com/google/devtools/build/lib/pkgcache/LoadingPhaseRunnerTest.java index acd55b4c4a183f..ee280b0c4ce8bb 100644 --- a/src/test/java/com/google/devtools/build/lib/pkgcache/LoadingPhaseRunnerTest.java +++ b/src/test/java/com/google/devtools/build/lib/pkgcache/LoadingPhaseRunnerTest.java @@ -32,7 +32,6 @@ import com.google.devtools.build.lib.analysis.BuildView; import com.google.devtools.build.lib.analysis.ConfiguredRuleClassProvider; import com.google.devtools.build.lib.analysis.ServerDirectories; -import com.google.devtools.build.lib.analysis.config.BuildOptions; import com.google.devtools.build.lib.analysis.util.AnalysisMock; import com.google.devtools.build.lib.buildeventstream.BuildEventStreamProtos.PatternExpanded.TestSuiteExpansion; import com.google.devtools.build.lib.cmdline.Label; @@ -98,7 +97,7 @@ public static void silenceLogger() { } @Before - public final void createLoadingPhaseTester() throws Exception { + public void createLoadingPhaseTester() throws Exception { tester = new LoadingPhaseTester(); } @@ -1401,20 +1400,12 @@ private static final class LoadingPhaseTester { analysisMock.getPackageFactoryBuilderForTesting(directories).build(ruleClassProvider, fs); PackageOptions options = Options.getDefaults(PackageOptions.class); storedErrors = new StoredEventHandler(); - BuildOptions defaultBuildOptions; - try { - defaultBuildOptions = BuildOptions.of(ImmutableList.of()); - } catch (OptionsParsingException e) { - throw new RuntimeException(e); - } - ActionKeyContext actionKeyContext = new ActionKeyContext(); skyframeExecutor = BazelSkyframeExecutorConstants.newBazelSkyframeExecutorBuilder() .setPkgFactory(pkgFactory) .setFileSystem(fs) .setDirectories(directories) - .setActionKeyContext(actionKeyContext) - .setDefaultBuildOptions(defaultBuildOptions) + .setActionKeyContext(new ActionKeyContext()) .setExtraSkyFunctions(analysisMock.getSkyFunctions(directories)) .build(); SkyframeExecutorTestHelper.process(skyframeExecutor); diff --git a/src/test/java/com/google/devtools/build/lib/pkgcache/PackageLoadingTest.java b/src/test/java/com/google/devtools/build/lib/pkgcache/PackageLoadingTest.java index 2e5fa3a0bacf03..34a1f500e82a4d 100644 --- a/src/test/java/com/google/devtools/build/lib/pkgcache/PackageLoadingTest.java +++ b/src/test/java/com/google/devtools/build/lib/pkgcache/PackageLoadingTest.java @@ -25,7 +25,6 @@ import com.google.devtools.build.lib.analysis.BlazeDirectories; import com.google.devtools.build.lib.analysis.ConfiguredRuleClassProvider; import com.google.devtools.build.lib.analysis.ServerDirectories; -import com.google.devtools.build.lib.analysis.config.BuildOptions; import com.google.devtools.build.lib.analysis.util.AnalysisMock; import com.google.devtools.build.lib.clock.BlazeClock; import com.google.devtools.build.lib.cmdline.Label; @@ -49,7 +48,6 @@ import com.google.devtools.build.lib.vfs.Path; import com.google.devtools.build.lib.vfs.Root; import com.google.devtools.common.options.OptionsParser; -import com.google.devtools.common.options.OptionsParsingException; import java.io.IOException; import java.util.Optional; import java.util.UUID; @@ -63,8 +61,6 @@ @RunWith(JUnit4.class) public class PackageLoadingTest extends FoundationTestCase { - private AnalysisMock analysisMock; - private ConfiguredRuleClassProvider ruleClassProvider; private SkyframeExecutor skyframeExecutor; private final ActionKeyContext actionKeyContext = new ActionKeyContext(); @@ -78,8 +74,8 @@ public final void initializeSkyframeExecutor() throws Exception { * this test performs, and the results compared to SkyFrame's result. */ private void initializeSkyframeExecutor(boolean doPackageLoadingChecks) throws Exception { - analysisMock = AnalysisMock.get(); - ruleClassProvider = analysisMock.createRuleClassProvider(); + AnalysisMock analysisMock = AnalysisMock.get(); + ConfiguredRuleClassProvider ruleClassProvider = analysisMock.createRuleClassProvider(); BlazeDirectories directories = new BlazeDirectories( new ServerDirectories(outputBase, outputBase, outputBase), @@ -91,19 +87,12 @@ private void initializeSkyframeExecutor(boolean doPackageLoadingChecks) throws E if (!doPackageLoadingChecks) { packageFactoryBuilder.disableChecks(); } - BuildOptions defaultBuildOptions; - try { - defaultBuildOptions = BuildOptions.of(ImmutableList.of()); - } catch (OptionsParsingException e) { - throw new RuntimeException(e); - } skyframeExecutor = BazelSkyframeExecutorConstants.newBazelSkyframeExecutorBuilder() .setPkgFactory(packageFactoryBuilder.build(ruleClassProvider, fileSystem)) .setFileSystem(fileSystem) .setDirectories(directories) .setActionKeyContext(actionKeyContext) - .setDefaultBuildOptions(defaultBuildOptions) .setExtraSkyFunctions(analysisMock.getSkyFunctions(directories)) .build(); SkyframeExecutorTestHelper.process(skyframeExecutor); @@ -131,13 +120,13 @@ private void setUpSkyframe( packageOptions, buildLanguageOptions, UUID.randomUUID(), - ImmutableMap.of(), + ImmutableMap.of(), new TimestampGranularityMonitor(BlazeClock.instance())); - skyframeExecutor.setActionEnv(ImmutableMap.of()); + skyframeExecutor.setActionEnv(ImmutableMap.of()); skyframeExecutor.setDeletedPackages(ImmutableSet.copyOf(packageOptions.getDeletedPackages())); } - private OptionsParser parse(String... options) throws Exception { + private static OptionsParser parse(String... options) throws Exception { OptionsParser parser = OptionsParser.builder() .optionsClasses(PackageOptions.class, BuildLanguageOptions.class) @@ -148,11 +137,12 @@ private OptionsParser parse(String... options) throws Exception { return parser; } - private PackageOptions parsePackageOptions(String... options) throws Exception { + private static PackageOptions parsePackageOptions(String... options) throws Exception { return parse(options).getOptions(PackageOptions.class); } - private BuildLanguageOptions parseBuildLanguageOptions(String... options) throws Exception { + private static BuildLanguageOptions parseBuildLanguageOptions(String... options) + throws Exception { return parse(options).getOptions(BuildLanguageOptions.class); } @@ -189,7 +179,7 @@ private void createPkg1() throws IOException { } // Check that a substring is present in an error message. - private void checkGetPackageFails(String packageName, String expectedMessage) throws Exception { + private void checkGetPackageFails(String packageName, String expectedMessage) { NoSuchPackageException e = assertThrows(NoSuchPackageException.class, () -> getPackage(packageName)); assertThat(e).hasMessageThat().contains(expectedMessage); @@ -213,7 +203,7 @@ public void testASTIsNotRetained() throws Exception { } @Test - public void testGetNonexistentPackage() throws Exception { + public void testGetNonexistentPackage() { checkGetPackageFails("not-there", "no such package 'not-there': " + "BUILD file not found"); } diff --git a/src/test/java/com/google/devtools/build/lib/query2/testutil/SkyframeQueryHelper.java b/src/test/java/com/google/devtools/build/lib/query2/testutil/SkyframeQueryHelper.java index ba2bb7bfadb626..c272deba1e5a34 100644 --- a/src/test/java/com/google/devtools/build/lib/query2/testutil/SkyframeQueryHelper.java +++ b/src/test/java/com/google/devtools/build/lib/query2/testutil/SkyframeQueryHelper.java @@ -93,7 +93,6 @@ public abstract class SkyframeQueryHelper extends AbstractQueryHelper { private PackageManager pkgManager; private TargetPatternPreloader targetParser; - private PathFragment relativeWorkingDirectory = PathFragment.EMPTY_FRAGMENT; private boolean blockUniverseEvaluationErrors; protected final ActionKeyContext actionKeyContext = new ActionKeyContext(); @@ -198,7 +197,7 @@ public AbstractBlazeQueryEnvironment getQueryEnvironment() { pkgManager, pkgManager, targetParser, - relativeWorkingDirectory, + /*relativeWorkingDirectory=*/ PathFragment.EMPTY_FRAGMENT, keepGoing, /*strictScope=*/ true, orderedResults, @@ -223,7 +222,7 @@ public ResultAndTargets evaluateQuery(String query) } } - public ResultAndTargets evaluateQuery( + public static ResultAndTargets evaluateQuery( String query, AbstractBlazeQueryEnvironment env) throws QueryException, InterruptedException { AggregateAllOutputFormatterCallback callback = @@ -296,8 +295,8 @@ protected void initTargetPatternEvaluator(ConfiguredRuleClassProvider ruleClassP packageLocator, Options.getDefaults(BuildLanguageOptions.class), UUID.randomUUID(), - ImmutableMap.of(), - ImmutableMap.of(), + ImmutableMap.of(), + ImmutableMap.of(), new TimestampGranularityMonitor(BlazeClock.instance()), OptionsProvider.EMPTY); } catch (InterruptedException | AbruptExitException e) { @@ -324,7 +323,6 @@ protected SkyframeExecutor createSkyframeExecutor(ConfiguredRuleClassProvider ru .setFileSystem(fileSystem) .setDirectories(directories) .setActionKeyContext(actionKeyContext) - .setDefaultBuildOptions(getDefaultBuildOptions(ruleClassProvider)) .setIgnoredPackagePrefixesFunction( new IgnoredPackagePrefixesFunction(ignoredPackagePrefixesFile)) .setExtraSkyFunctions(analysisMock.getSkyFunctions(directories)) diff --git a/src/test/java/com/google/devtools/build/lib/remote/RemoteModuleTest.java b/src/test/java/com/google/devtools/build/lib/remote/RemoteModuleTest.java index 1e0e40a4f21dd4..342c4813dc92bf 100644 --- a/src/test/java/com/google/devtools/build/lib/remote/RemoteModuleTest.java +++ b/src/test/java/com/google/devtools/build/lib/remote/RemoteModuleTest.java @@ -33,7 +33,6 @@ import com.google.common.eventbus.EventBus; import com.google.devtools.build.lib.analysis.BlazeDirectories; import com.google.devtools.build.lib.analysis.ServerDirectories; -import com.google.devtools.build.lib.analysis.config.BuildOptions; import com.google.devtools.build.lib.analysis.config.CoreOptions; import com.google.devtools.build.lib.authandtls.AuthAndTLSOptions; import com.google.devtools.build.lib.authandtls.BasicHttpAuthenticationEncoder; @@ -42,7 +41,6 @@ import com.google.devtools.build.lib.exec.ExecutionOptions; import com.google.devtools.build.lib.pkgcache.PackageOptions; import com.google.devtools.build.lib.remote.options.RemoteOptions; -import com.google.devtools.build.lib.runtime.BlazeModule; import com.google.devtools.build.lib.runtime.BlazeRuntime; import com.google.devtools.build.lib.runtime.BlazeServerStartupOptions; import com.google.devtools.build.lib.runtime.BlazeWorkspace; @@ -110,14 +108,6 @@ private static CommandEnvironment createTestCommandEnvironment(RemoteOptions rem .setServerDirectories(serverDirectories) .setStartupOptionsProvider( OptionsParser.builder().optionsClasses(BlazeServerStartupOptions.class).build()) - .addBlazeModule( - new BlazeModule() { - @Override - public BuildOptions getDefaultBuildOptions(BlazeRuntime runtime) { - return BuildOptions.getDefaultBuildOptionsForFragments( - runtime.getRuleClassProvider().getConfigurationOptions()); - } - }) .build(); BlazeDirectories directories = diff --git a/src/test/java/com/google/devtools/build/lib/repository/BUILD b/src/test/java/com/google/devtools/build/lib/repository/BUILD index 3d7d0522842b5c..13ebbc0db3b066 100644 --- a/src/test/java/com/google/devtools/build/lib/repository/BUILD +++ b/src/test/java/com/google/devtools/build/lib/repository/BUILD @@ -35,7 +35,6 @@ java_library( "//src/main/java/com/google/devtools/build/skyframe", "//src/main/java/com/google/devtools/build/skyframe:skyframe-objects", "//src/main/java/net/starlark/java/eval", - "//src/main/java/net/starlark/java/syntax", "//src/test/java/com/google/devtools/build/lib/analysis/util", "//src/test/java/com/google/devtools/build/skyframe:testutil", "//third_party:auto_value", diff --git a/src/test/java/com/google/devtools/build/lib/rules/BUILD b/src/test/java/com/google/devtools/build/lib/rules/BUILD index 6188408d5657fc..c376bc7edf0a11 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/BUILD +++ b/src/test/java/com/google/devtools/build/lib/rules/BUILD @@ -38,8 +38,6 @@ java_test( "//src/main/java/com/google/devtools/build/lib/analysis:analysis_cluster", "//src/main/java/com/google/devtools/build/lib/analysis:config/build_options", "//src/main/java/com/google/devtools/build/lib/analysis:config/fragment", - "//src/main/java/com/google/devtools/build/lib/analysis:config/fragment_options", - "//src/main/java/com/google/devtools/build/lib/analysis:config/fragment_provider", "//src/main/java/com/google/devtools/build/lib/analysis:configured_target", "//src/main/java/com/google/devtools/build/lib/analysis:file_provider", "//src/main/java/com/google/devtools/build/lib/analysis:licenses_provider", @@ -54,7 +52,6 @@ java_test( "//src/test/java/com/google/devtools/build/lib/testutil", "//src/test/java/com/google/devtools/build/lib/testutil:TestConstants", "//third_party:guava", - "//third_party:jsr305", "//third_party:junit4", "//third_party:truth", ], diff --git a/src/test/java/com/google/devtools/build/lib/rules/android/BUILD b/src/test/java/com/google/devtools/build/lib/rules/android/BUILD index 5b35362a24cea6..8ccf84bae18274 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/android/BUILD +++ b/src/test/java/com/google/devtools/build/lib/rules/android/BUILD @@ -28,7 +28,6 @@ java_test( "//src/main/java/com/google/devtools/build/lib/rules/java:java-compilation", "//src/main/java/com/google/devtools/build/lib/rules/java:java-rules", "//src/test/java/com/google/devtools/build/lib/actions/util", - "//src/test/java/com/google/devtools/build/lib/analysis/util", "//third_party:guava", "//third_party:junit4", "//third_party:truth", @@ -71,7 +70,6 @@ java_test( deps = [ ":AndroidBuildViewTestCase", "//src/main/java/com/google/devtools/build/lib/rules/android", - "//src/test/java/com/google/devtools/build/lib/analysis/util", "//third_party:junit4", "//third_party:truth", ], @@ -192,7 +190,6 @@ java_test( srcs = ["AndroidAssetsTest.java"], deps = [ ":ResourceTestBase", - "//src/main/java/com/google/devtools/build/lib/actions", "//src/main/java/com/google/devtools/build/lib/actions:artifacts", "//src/main/java/com/google/devtools/build/lib/analysis:analysis_cluster", "//src/main/java/com/google/devtools/build/lib/collect/nestedset", diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/BUILD b/src/test/java/com/google/devtools/build/lib/rules/cpp/BUILD index c36ac70b293502..39da78bfd3cf3d 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/cpp/BUILD +++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/BUILD @@ -183,10 +183,8 @@ java_test( srcs = ["CcHostToolchainAliasTest.java"], deps = [ "//src/main/java/com/google/devtools/build/lib/analysis:configured_target", - "//src/main/java/com/google/devtools/build/lib/cmdline", "//src/main/java/com/google/devtools/build/lib/rules/cpp", "//src/test/java/com/google/devtools/build/lib/analysis/util", - "//src/test/java/com/google/devtools/build/lib/packages:testutil", "//third_party:junit4", "//third_party:truth", ], diff --git a/src/test/java/com/google/devtools/build/lib/rules/objc/BUILD b/src/test/java/com/google/devtools/build/lib/rules/objc/BUILD index 81d3447c9ca08e..0f632e5be4531d 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/objc/BUILD +++ b/src/test/java/com/google/devtools/build/lib/rules/objc/BUILD @@ -14,8 +14,13 @@ filegroup( java_test( name = "BazelJ2ObjcLibraryTest", - srcs = ["BazelJ2ObjcLibraryTest.java"], tags = ["no_windows"], + runtime_deps = [":BazelJ2ObjcLibraryTest_lib"], +) + +java_library( + name = "BazelJ2ObjcLibraryTest_lib", + srcs = ["BazelJ2ObjcLibraryTest.java"], deps = [ ":J2ObjcLibraryTest", "//src/main/java/com/google/devtools/build/lib/actions", diff --git a/src/test/java/com/google/devtools/build/lib/rules/python/BUILD b/src/test/java/com/google/devtools/build/lib/rules/python/BUILD index 609423b89f1730..b23910302b9d9f 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/python/BUILD +++ b/src/test/java/com/google/devtools/build/lib/rules/python/BUILD @@ -73,7 +73,6 @@ java_library( "//src/main/java/com/google/devtools/build/lib/analysis:configured_target", "//src/main/java/com/google/devtools/build/lib/rules/python", "//src/test/java/com/google/devtools/build/lib/analysis/util", - "//src/test/java/com/google/devtools/build/lib/packages:testutil", "//third_party:junit4", "//third_party:truth", ], @@ -147,7 +146,6 @@ java_test( name = "PythonVersionSelectTest", srcs = ["PythonVersionSelectTest.java"], deps = [ - "//src/main/java/com/google/devtools/build/lib/actions", "//src/main/java/com/google/devtools/build/lib/actions:artifacts", "//src/main/java/com/google/devtools/build/lib/analysis:file_provider", "//src/main/java/com/google/devtools/build/lib/collect/nestedset", @@ -194,7 +192,6 @@ java_test( "//src/main/java/com/google/devtools/build/lib/analysis:configured_target", "//src/main/java/com/google/devtools/build/lib/rules/python", "//src/main/java/net/starlark/java/eval", - "//src/main/java/net/starlark/java/syntax", "//src/test/java/com/google/devtools/build/lib/analysis/util", "//third_party:junit4", "//third_party:truth", diff --git a/src/test/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcherRcoptionsTest.java b/src/test/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcherRcoptionsTest.java index 214a435e0ebb73..77e8e9f1c757eb 100644 --- a/src/test/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcherRcoptionsTest.java +++ b/src/test/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcherRcoptionsTest.java @@ -22,7 +22,6 @@ import com.google.devtools.build.lib.analysis.BlazeDirectories; import com.google.devtools.build.lib.analysis.ConfiguredRuleClassProvider; import com.google.devtools.build.lib.analysis.ServerDirectories; -import com.google.devtools.build.lib.analysis.config.BuildOptions; import com.google.devtools.build.lib.analysis.config.CoreOptions; import com.google.devtools.build.lib.analysis.config.FragmentOptions; import com.google.devtools.build.lib.testutil.Scratch; @@ -76,12 +75,9 @@ private static class ReportNumCommand implements BlazeCommand { @Override public BlazeCommandResult exec(CommandEnvironment env, OptionsParsingResult options) { FooOptions fooOptions = options.getOptions(FooOptions.class); - env.getReporter().getOutErr().printOut("" + fooOptions.numOption); + env.getReporter().getOutErr().printOut(String.valueOf(fooOptions.numOption)); return BlazeCommandResult.success(); } - - @Override - public void editOptions(OptionsParser optionsParser) {} } @Command( @@ -95,26 +91,18 @@ private static class ReportAllCommand implements BlazeCommand { @Override public BlazeCommandResult exec(CommandEnvironment env, OptionsParsingResult options) { FooOptions fooOptions = options.getOptions(FooOptions.class); - env.getReporter() - .getOutErr() - .printOut("" + fooOptions.numOption + " " + fooOptions.stringOption); + env.getReporter().getOutErr().printOut(fooOptions.numOption + " " + fooOptions.stringOption); return BlazeCommandResult.success(); } - - @Override - public void editOptions(OptionsParser optionsParser) {} } @Command( - name = "reportallinherited", - options = {FooOptions.class}, - shortDescription = "", - help = "", - inherits = ReportAllCommand.class - ) - private static class ReportAllInheritedCommand extends ReportAllCommand { - } - + name = "reportallinherited", + options = {FooOptions.class}, + shortDescription = "", + help = "", + inherits = ReportAllCommand.class) + private static class ReportAllInheritedCommand extends ReportAllCommand {} private final Scratch scratch = new Scratch(); private final RecordingOutErr outErr = new RecordingOutErr(); @@ -150,14 +138,6 @@ public void initializeRuleClasses(ConfiguredRuleClassProvider.Builder builder) { builder.setToolsRepository(TestConstants.TOOLS_REPOSITORY); } }) - .addBlazeModule( - new BlazeModule() { - @Override - public BuildOptions getDefaultBuildOptions(BlazeRuntime runtime) { - return BuildOptions.getDefaultBuildOptionsForFragments( - runtime.getRuleClassProvider().getConfigurationOptions()); - } - }) .build(); BlazeDirectories directories = diff --git a/src/test/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcherTest.java b/src/test/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcherTest.java index 34f60f9a0c638d..6935164925c123 100644 --- a/src/test/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcherTest.java +++ b/src/test/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcherTest.java @@ -18,14 +18,12 @@ import static java.util.Arrays.asList; import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; import com.google.common.eventbus.Subscribe; import com.google.common.testing.GcFinalization; import com.google.common.util.concurrent.SettableFuture; import com.google.devtools.build.lib.analysis.BlazeDirectories; import com.google.devtools.build.lib.analysis.ServerDirectories; -import com.google.devtools.build.lib.analysis.config.BuildOptions; import com.google.devtools.build.lib.bugreport.BugReporter; import com.google.devtools.build.lib.events.Event; import com.google.devtools.build.lib.events.EventKind; @@ -60,7 +58,6 @@ import java.io.PrintStream; import java.lang.ref.WeakReference; import java.util.Arrays; -import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Optional; @@ -79,11 +76,11 @@ @RunWith(JUnit4.class) public class BlazeCommandDispatcherTest { - private Scratch scratch = new Scratch(); + private final Scratch scratch = new Scratch(); private BlazeRuntime runtime; - private RecordingOutErr outErr = new RecordingOutErr(); - private FooCommand foo = new FooCommand(); - private BarCommand bar = new BarCommand(); + private final RecordingOutErr outErr = new RecordingOutErr(); + private final FooCommand foo = new FooCommand(); + private final BarCommand bar = new BarCommand(); private Map clientEnv; private AbruptExitException errorOnAfterCommand; @@ -114,11 +111,6 @@ public void afterCommand() throws AbruptExitException { throw errorOnAfterCommand; } } - - @Override - public BuildOptions getDefaultBuildOptions(BlazeRuntime runtime) { - return BuildOptions.of(ImmutableMap.of()); - } }) .build(); @@ -186,8 +178,6 @@ public BlazeCommandResult exec(CommandEnvironment env, OptionsParsingResult opti } } - @Override - public void editOptions(OptionsParser optionsParser) {} } @Command(name = "bar", shortDescription = "", help = "") @@ -199,8 +189,6 @@ public BlazeCommandResult exec(CommandEnvironment env, OptionsParsingResult opti return BlazeCommandResult.success(); } - @Override - public void editOptions(OptionsParser optionsParser) {} } private abstract static class AnsiTestingCommand implements BlazeCommand { @@ -223,8 +211,6 @@ public BlazeCommandResult exec(CommandEnvironment env, OptionsParsingResult opti return BlazeCommandResult.success(); } - @Override - public void editOptions(OptionsParser optionsParser) {} } @Command(name = "binary", binaryStdOut = true, shortDescription = "", help = "") @@ -232,7 +218,7 @@ private static class BinaryCommand extends AnsiTestingCommand { // Same logic as AsciiCommand, but binary. } - @Command(name = "ascii", binaryStdOut = false, shortDescription = "", help = "") + @Command(name = "ascii", shortDescription = "", help = "") private static class AsciiCommand extends AnsiTestingCommand { // Same logic as BinaryCommand, but not binary. } @@ -444,12 +430,10 @@ public BlazeCommandResult exec(CommandEnvironment env, OptionsParsingResult opti return BlazeCommandResult.success(); } - @Override - public void editOptions(OptionsParser optionsParser) {} } runtime.overrideCommands(ImmutableList.of(new HelpCommand())); BlazeCommandDispatcher dispatch = new BlazeCommandDispatcher(runtime); - BlazeCommandResult result = dispatch.exec(Collections.emptyList(), "test", outErr); + BlazeCommandResult result = dispatch.exec(ImmutableList.of(), "test", outErr); assertThat(result.getExitCode()).isEqualTo(ExitCode.SUCCESS); assertThat(outErr.outAsLatin1()).isEqualTo("This is the help message.\n"); } @@ -590,17 +574,15 @@ public void noMemoryLeakOfReporterThroughSystemOutErr() throws Exception { final class SystemOutErrRetainingCommand implements BlazeCommand { private final PrintStream defaultStdout = System.out; private final PrintStream defaultStderr = System.err; - private PrintStream overriddenStdout; - private PrintStream overriddenStderr; private WeakReference reporterRef; @Override public BlazeCommandResult exec(CommandEnvironment env, OptionsParsingResult options) { - overriddenStdout = System.out; + PrintStream overriddenStdout = System.out; assertThat(overriddenStdout).isNotNull(); assertThat(overriddenStdout).isNotEqualTo(defaultStdout); - overriddenStderr = System.err; + PrintStream overriddenStderr = System.err; assertThat(overriddenStderr).isNotNull(); assertThat(overriddenStderr).isNotEqualTo(defaultStderr); @@ -610,9 +592,6 @@ public BlazeCommandResult exec(CommandEnvironment env, OptionsParsingResult opti return BlazeCommandResult.success(); } - - @Override - public void editOptions(OptionsParser optionsParser) {} } SystemOutErrRetainingCommand cmd = new SystemOutErrRetainingCommand(); @@ -626,7 +605,6 @@ public void editOptions(OptionsParser optionsParser) {} @Command( name = "testcommand", - options = {}, shortDescription = "", help = "") private static class CommandCompleteRecordingCommand implements BlazeCommand { @@ -649,10 +627,5 @@ public BlazeCommandResult exec(CommandEnvironment env, OptionsParsingResult opti env.getEventBus().register(this); return resultSupplier.get(); } - - @Override - public void editOptions(OptionsParser optionsParser) { - // no-op - } } } diff --git a/src/test/java/com/google/devtools/build/lib/runtime/BlazeRuntimeTest.java b/src/test/java/com/google/devtools/build/lib/runtime/BlazeRuntimeTest.java index 8e1040e3c23e8b..c2dabcfd93a4e2 100644 --- a/src/test/java/com/google/devtools/build/lib/runtime/BlazeRuntimeTest.java +++ b/src/test/java/com/google/devtools/build/lib/runtime/BlazeRuntimeTest.java @@ -19,7 +19,6 @@ import com.google.common.eventbus.EventBus; import com.google.devtools.build.lib.analysis.BlazeDirectories; import com.google.devtools.build.lib.analysis.ServerDirectories; -import com.google.devtools.build.lib.analysis.config.BuildOptions; import com.google.devtools.build.lib.exec.BinTools; import com.google.devtools.build.lib.runtime.commands.VersionCommand; import com.google.devtools.build.lib.server.FailureDetails.Crash; @@ -47,11 +46,14 @@ public class BlazeRuntimeTest { @Test - public void optionSplitting() throws Exception { + public void optionSplitting() { BlazeRuntime.CommandLineOptions options = BlazeRuntime.splitStartupOptions( - ImmutableList.of(), - "--install_base=/foo --host_jvm_args=-Xmx1B", "build", "//foo:bar", "--nobuild"); + ImmutableList.of(), + "--install_base=/foo --host_jvm_args=-Xmx1B", + "build", + "//foo:bar", + "--nobuild"); assertThat(options.getStartupArgs()) .isEqualTo(Arrays.asList("--install_base=/foo --host_jvm_args=-Xmx1B")); assertThat(options.getOtherArgs()).isEqualTo(Arrays.asList("build", "//foo:bar", "--nobuild")); @@ -59,9 +61,9 @@ public void optionSplitting() throws Exception { // A regression test to make sure that the 'no' prefix is handled correctly. @Test - public void optionSplittingNoPrefix() throws Exception { - BlazeRuntime.CommandLineOptions options = BlazeRuntime.splitStartupOptions( - ImmutableList.of(), "--nobatch", "build"); + public void optionSplittingNoPrefix() { + BlazeRuntime.CommandLineOptions options = + BlazeRuntime.splitStartupOptions(ImmutableList.of(), "--nobatch", "build"); assertThat(options.getStartupArgs()).isEqualTo(Arrays.asList("--nobatch")); assertThat(options.getOtherArgs()).isEqualTo(Arrays.asList("build")); } @@ -77,13 +79,6 @@ public void crashTest() throws Exception { fs.getPath("/install"), fs.getPath("/output"), fs.getPath("/output_user")); BlazeRuntime runtime = new BlazeRuntime.Builder() - .addBlazeModule( - new BlazeModule() { - @Override - public BuildOptions getDefaultBuildOptions(BlazeRuntime runtime) { - return BuildOptions.builder().build(); - } - }) .setFileSystem(fs) .setProductName("bazel") .setServerDirectories(serverDirectories) @@ -131,13 +126,6 @@ public void resultExtensions() throws Exception { fs.getPath("/install"), fs.getPath("/output"), fs.getPath("/output_user")); BlazeRuntime runtime = new BlazeRuntime.Builder() - .addBlazeModule( - new BlazeModule() { - @Override - public BuildOptions getDefaultBuildOptions(BlazeRuntime runtime) { - return BuildOptions.builder().build(); - } - }) .setFileSystem(fs) .setProductName("bazel") .setServerDirectories(serverDirectories) diff --git a/src/test/java/com/google/devtools/build/lib/runtime/CommandInterruptionTest.java b/src/test/java/com/google/devtools/build/lib/runtime/CommandInterruptionTest.java index 5829488fdab4e6..a4459560c4f8e9 100644 --- a/src/test/java/com/google/devtools/build/lib/runtime/CommandInterruptionTest.java +++ b/src/test/java/com/google/devtools/build/lib/runtime/CommandInterruptionTest.java @@ -22,7 +22,6 @@ import com.google.devtools.build.lib.analysis.BlazeDirectories; import com.google.devtools.build.lib.analysis.ConfiguredRuleClassProvider; import com.google.devtools.build.lib.analysis.ServerDirectories; -import com.google.devtools.build.lib.analysis.config.BuildOptions; import com.google.devtools.build.lib.analysis.config.CoreOptions; import com.google.devtools.build.lib.analysis.test.TestConfiguration; import com.google.devtools.build.lib.server.FailureDetails; @@ -96,11 +95,10 @@ public static class WaitOptions extends OptionsBase { public WaitOptions() {} @Option( - name = "expect_interruption", - documentationCategory = OptionDocumentationCategory.UNCATEGORIZED, - effectTags = {OptionEffectTag.NO_OP}, - defaultValue = "false" - ) + name = "expect_interruption", + documentationCategory = OptionDocumentationCategory.UNCATEGORIZED, + effectTags = {OptionEffectTag.NO_OP}, + defaultValue = "false") public boolean expectInterruption; } @@ -109,11 +107,10 @@ public WaitOptions() {} * interrupted more than --expect_interruptions times while waiting. */ @Command( - name = "snooze", - shortDescription = "", - help = "", - options = {WaitOptions.class} - ) + name = "snooze", + shortDescription = "", + help = "", + options = {WaitOptions.class}) private static final class WaitForCompletionCommand implements BlazeCommand { private final AtomicBoolean isTestShuttingDown; private final AtomicReference> commandStateHandoff; @@ -125,15 +122,13 @@ private static final class WaitForCompletionCommand implements BlazeCommand { @Override public BlazeCommandResult exec(CommandEnvironment env, OptionsParsingResult options) { - CommandState commandState = new CommandState( - env, options.getOptions(WaitOptions.class).expectInterruption, isTestShuttingDown); + CommandState commandState = + new CommandState( + env, options.getOptions(WaitOptions.class).expectInterruption, isTestShuttingDown); commandStateHandoff.getAndSet(null).set(commandState); return BlazeCommandResult.detailedExitCode(commandState.waitForDetailedCodeFromTest()); } - @Override - public void editOptions(OptionsParser optionsParser) {} - /** * Runs an instance of this command on the given executor, waits for it to start and returns a * CommandState which can be used to control and assert on the status of that command. @@ -206,9 +201,7 @@ public DetailedExitCode call() throws Exception { } } - /** - * A remote control allowing the test to control and assert on the WaitForCompletionCommand. - */ + /** A remote control allowing the test to control and assert on the WaitForCompletionCommand. */ private static final class CommandState { private final SettableFuture result; private final CommandEnvironment commandEnvironment; @@ -353,7 +346,8 @@ void assertFinishedWith(DetailedExitCode detailedExitCode) throws InterruptedException, ExecutionException, BrokenBarrierException { synchronizeWithCommand(); assertWithMessage("The command should have been finished, but it was not.") - .that(result.isDone()).isTrue(); + .that(result.isDone()) + .isTrue(); assertThat(Futures.getDone(result)).isEqualTo(detailedExitCode); } @@ -364,7 +358,7 @@ void assertNotFinishedYet() throws InterruptedException, BrokenBarrierException try { throw new AssertionError( "The command should not have been finished, but it finished with exit code " - + result.get()); + + result.get()); } catch (Throwable ex) { throw new AssertionError("The command should not have been finished, but it threw", ex); } @@ -409,14 +403,6 @@ public void initializeRuleClasses(ConfiguredRuleClassProvider.Builder builder) { builder.addConfigurationOptions(TestConfiguration.TestOptions.class); } }) - .addBlazeModule( - new BlazeModule() { - @Override - public BuildOptions getDefaultBuildOptions(BlazeRuntime runtime) { - return BuildOptions.getDefaultBuildOptionsForFragments( - runtime.getRuleClassProvider().getConfigurationOptions()); - } - }) .build(); snooze = new WaitForCompletionCommand(isTestShuttingDown); runtime.overrideCommands(ImmutableList.of(snooze)); diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/CollectPackagesUnderDirectoryTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/CollectPackagesUnderDirectoryTest.java index 2902bc74d7a8f7..0bc6a4df807db7 100644 --- a/src/test/java/com/google/devtools/build/lib/skyframe/CollectPackagesUnderDirectoryTest.java +++ b/src/test/java/com/google/devtools/build/lib/skyframe/CollectPackagesUnderDirectoryTest.java @@ -14,7 +14,6 @@ package com.google.devtools.build.lib.skyframe; import com.google.common.collect.ImmutableMap; -import com.google.devtools.build.lib.analysis.config.BuildOptions; import com.google.devtools.build.lib.packages.BuildFileName; import com.google.devtools.build.skyframe.SkyFunction; import com.google.devtools.build.skyframe.SkyFunctionName; @@ -43,6 +42,6 @@ protected ImmutableMap getExtraSkyFunctions() { @Override protected SkyframeExecutorFactory makeSkyframeExecutorFactory() { - return new SequencedSkyframeExecutorFactory(BuildOptions.builder().build()); + return new SequencedSkyframeExecutorFactory(); } } diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/PrepareDepsOfPatternsFunctionSmartNegationTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/PrepareDepsOfPatternsFunctionSmartNegationTest.java index b025695adb2135..4757999ff45c66 100644 --- a/src/test/java/com/google/devtools/build/lib/skyframe/PrepareDepsOfPatternsFunctionSmartNegationTest.java +++ b/src/test/java/com/google/devtools/build/lib/skyframe/PrepareDepsOfPatternsFunctionSmartNegationTest.java @@ -25,7 +25,6 @@ import com.google.devtools.build.lib.analysis.ConfiguredRuleClassProvider; import com.google.devtools.build.lib.analysis.ServerDirectories; import com.google.devtools.build.lib.analysis.util.AnalysisMock; -import com.google.devtools.build.lib.analysis.util.DefaultBuildOptionsForTesting; import com.google.devtools.build.lib.cmdline.Label; import com.google.devtools.build.lib.cmdline.PackageIdentifier; import com.google.devtools.build.lib.events.Reporter; @@ -90,8 +89,6 @@ public void setUp() throws Exception { .setFileSystem(fileSystem) .setDirectories(directories) .setActionKeyContext(new ActionKeyContext()) - .setDefaultBuildOptions( - DefaultBuildOptionsForTesting.getDefaultBuildOptionsForTest(ruleClassProvider)) .setExtraSkyFunctions(AnalysisMock.get().getSkyFunctions(directories)) .setIgnoredPackagePrefixesFunction( new IgnoredPackagePrefixesFunction( @@ -106,7 +103,7 @@ public void setUp() throws Exception { Options.getDefaults(PackageOptions.class), Options.getDefaults(BuildLanguageOptions.class), UUID.randomUUID(), - ImmutableMap.of(), + ImmutableMap.of(), new TimestampGranularityMonitor(null)); skyframeExecutor.setActionEnv(ImmutableMap.of()); skyframeExecutor.injectExtraPrecomputedValues(