Skip to content

Commit

Permalink
Use ScopedBlazeProcessHandler when appropriate
Browse files Browse the repository at this point in the history
(cherry picked from commit 930cd0c)
  • Loading branch information
Googler authored and mai93 committed Jul 5, 2023
1 parent bca5578 commit 72dc357
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,10 @@ InputStream runBlazeInfo(
BuildResultHelper buildResultHelper,
BlazeContext context)
throws BuildException;

/** Allows enabling the use of command runner for restricted set of users. */
default boolean shouldUseForLocalTests() {
return false;
default boolean canUseCli() {
return true;
}

/** Get a list of additional build flags. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,5 @@ public class BlazeCommandRunnerExperiments {
public static final BoolExperiment USE_SINGLEJAR_FOR_DEBUGGING =
new BoolExperiment("debug.localtests.singlejar.enable", true);

public static boolean isEnabledForTests(BlazeCommandRunner runner) {
return runner.shouldUseForLocalTests();
}

private BlazeCommandRunnerExperiments() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import com.google.idea.blaze.base.bazel.BuildSystem.BuildInvoker;
import com.google.idea.blaze.base.command.BlazeCommand;
import com.google.idea.blaze.base.command.BlazeCommandName;
import com.google.idea.blaze.base.command.BlazeCommandRunnerExperiments;
import com.google.idea.blaze.base.command.BlazeFlags;
import com.google.idea.blaze.base.command.BlazeInvocationContext;
import com.google.idea.blaze.base.command.buildresult.BuildResultHelper;
Expand Down Expand Up @@ -155,7 +154,9 @@ protected ProcessHandler startProcess() throws ExecutionException {
invoker,
ImmutableList.copyOf(buildResultHelper.getBuildFlags()),
context);

if (invoker.getCommandRunner().canUseCli()) {
return getScopedProcessHandler(project, blazeCommand.build(), workspaceRoot);
}
return isTest()
? getProcessHandlerForTests(
project, invoker, buildResultHelper, blazeCommand, workspaceRoot, context)
Expand Down Expand Up @@ -255,7 +256,7 @@ private ProcessHandler getProcessHandlerForTests(
BlazeContext context)
throws ExecutionException {
BlazeTestResultFinderStrategy testResultFinderStrategy =
BlazeCommandRunnerExperiments.isEnabledForTests(invoker.getCommandRunner())
!invoker.getCommandRunner().canUseCli()
? new BlazeTestResultHolder()
: new LocalBuildEventProtocolTestFinderStrategy(buildResultHelper);
BlazeTestUiSession testUiSession = null;
Expand Down Expand Up @@ -283,7 +284,7 @@ protected ConsoleView createConsole() {
context.addOutputSink(PrintOutput.class, new WritingOutputSink(consoleView));
}
addConsoleFilters(consoleFilters.toArray(new Filter[0]));
return BlazeCommandRunnerExperiments.isEnabledForTests(invoker.getCommandRunner())
return !invoker.getCommandRunner().canUseCli()
? getCommandRunnerProcessHandler(
project,
invoker,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ protected ProcessHandler startProcess() throws ExecutionException {
getConfiguration().getTargetKind());
BlazeTestUiSession testUiSession = null;
if (TargetKindUtil.isLocalTest(getConfiguration().getTargetKind())
&& invoker.getCommandRunner().shouldUseForLocalTests()
&& !invoker.getCommandRunner().canUseCli()
&& getExecutorType().isDebugType()) {
File downloadDir = getDownloadDir();
WorkspaceRoot workspaceRoot =
Expand Down

0 comments on commit 72dc357

Please sign in to comment.