From 92125f8ea1963b31efcc486d4fa721d26734b9ab Mon Sep 17 00:00:00 2001 From: lberki Date: Tue, 6 Feb 2018 07:32:07 -0800 Subject: Remove ShutdownBlazeServerException in favor of indicating that the server should be shut down in BlazeCommandResult. RELNOTES: None. PiperOrigin-RevId: 184678994 --- .../BlazeCommandDispatcherRcoptionsTest.java | 22 +++++++++------------- .../build/lib/runtime/CommandInterruptionTest.java | 3 +-- .../commands/CleanCommandRecommendsAsyncTest.java | 3 +-- 3 files changed, 11 insertions(+), 17 deletions(-) (limited to 'src/test/java/com/google/devtools/build/lib') 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 3162ddf558..0d9e7ba8fd 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 @@ -27,8 +27,6 @@ import com.google.devtools.build.lib.analysis.ServerDirectories; import com.google.devtools.build.lib.analysis.config.BuildConfiguration; import com.google.devtools.build.lib.analysis.config.FragmentOptions; import com.google.devtools.build.lib.cmdline.Label; -import com.google.devtools.build.lib.runtime.BlazeCommandDispatcher.LockingMode; -import com.google.devtools.build.lib.runtime.BlazeCommandDispatcher.ShutdownBlazeServerException; import com.google.devtools.build.lib.testutil.Scratch; import com.google.devtools.build.lib.testutil.TestConstants; import com.google.devtools.build.lib.util.ExitCode; @@ -81,8 +79,7 @@ public class BlazeCommandDispatcherRcoptionsTest { private static class ReportNumCommand implements BlazeCommand { @Override - public BlazeCommandResult exec(CommandEnvironment env, OptionsProvider options) - throws ShutdownBlazeServerException { + public BlazeCommandResult exec(CommandEnvironment env, OptionsProvider options) { FooOptions fooOptions = options.getOptions(FooOptions.class); env.getReporter().getOutErr().printOut("" + fooOptions.numOption); return BlazeCommandResult.exitCode(ExitCode.SUCCESS); @@ -101,8 +98,7 @@ public class BlazeCommandDispatcherRcoptionsTest { private static class ReportAllCommand implements BlazeCommand { @Override - public BlazeCommandResult exec(CommandEnvironment env, OptionsProvider options) - throws ShutdownBlazeServerException { + public BlazeCommandResult exec(CommandEnvironment env, OptionsProvider options) { FooOptions fooOptions = options.getOptions(FooOptions.class); env.getReporter() .getOutErr() @@ -173,7 +169,7 @@ public class BlazeCommandDispatcherRcoptionsTest { List cmdLine = Lists.newArrayList("reportnum"); cmdLine.addAll(blazercOpts); - dispatch.exec(cmdLine, LockingMode.ERROR_OUT, "test", outErr); + dispatch.exec(cmdLine, "test", outErr); String out = outErr.outAsLatin1(); assertWithMessage("Common options should be used").that(out).isEqualTo("99"); } @@ -190,7 +186,7 @@ public class BlazeCommandDispatcherRcoptionsTest { List cmdLine = Lists.newArrayList("reportnum"); cmdLine.addAll(blazercOpts); - dispatch.exec(cmdLine, LockingMode.ERROR_OUT, "test", outErr); + dispatch.exec(cmdLine, "test", outErr); String out = outErr.outAsLatin1(); assertWithMessage("Specific options should dominate common options").that(out).isEqualTo("42"); } @@ -207,7 +203,7 @@ public class BlazeCommandDispatcherRcoptionsTest { List cmdLine = Lists.newArrayList("reportnum"); cmdLine.addAll(blazercOpts); - dispatch.exec(cmdLine, LockingMode.ERROR_OUT, "test", outErr); + dispatch.exec(cmdLine, "test", outErr); String out = outErr.outAsLatin1(); assertWithMessage("Specific options should dominate common options").that(out).isEqualTo("42"); } @@ -225,7 +221,7 @@ public class BlazeCommandDispatcherRcoptionsTest { List cmdLine = Lists.newArrayList("reportall"); cmdLine.addAll(blazercOpts); - dispatch.exec(cmdLine, LockingMode.ERROR_OUT, "test", outErr); + dispatch.exec(cmdLine, "test", outErr); String out = outErr.outAsLatin1(); assertWithMessage("Options should get accumulated over different rc files") .that(out) @@ -246,7 +242,7 @@ public class BlazeCommandDispatcherRcoptionsTest { List cmdLine = Lists.newArrayList("reportall"); cmdLine.addAll(blazercOpts); - dispatch.exec(cmdLine, LockingMode.ERROR_OUT, "test", outErr); + dispatch.exec(cmdLine, "test", outErr); String out = outErr.outAsLatin1(); assertWithMessage("The more specific rc-file should override").that(out).isEqualTo("99 foo"); } @@ -265,7 +261,7 @@ public class BlazeCommandDispatcherRcoptionsTest { List cmdLine = Lists.newArrayList("reportall"); cmdLine.addAll(blazercOpts); - dispatch.exec(cmdLine, LockingMode.ERROR_OUT, "test", outErr); + dispatch.exec(cmdLine, "test", outErr); String out = outErr.outAsLatin1(); assertWithMessage("The more specific rc-file should override irrespective of name") .that(out) @@ -295,7 +291,7 @@ public class BlazeCommandDispatcherRcoptionsTest { List orderedOpts = ImmutableList.copyOf(Iterables.concat(e)); cmdLine.addAll(orderedOpts); - dispatch.exec(cmdLine, LockingMode.ERROR_OUT, "test", outErr); + dispatch.exec(cmdLine, "test", outErr); String out = outErr.outAsLatin1(); assertWithMessage(String.format( "The more specific option should override, irrespective of source file or order. %s", 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 8f2da8aa44..adf8a56775 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 @@ -140,9 +140,8 @@ public final class CommandInterruptionTest { ImmutableList.of( "snooze", expectInterruption ? "--expect_interruption" : "--noexpect_interruption"), - BlazeCommandDispatcher.LockingMode.ERROR_OUT, "CommandInterruptionTest", - OutErr.SYSTEM_OUT_ERR); + OutErr.SYSTEM_OUT_ERR).getExitCode().getNumericExitCode(); } catch (Exception throwable) { if (commandStateHandoff.isDone()) { commandStateHandoff.get().completeWithFailure(throwable); diff --git a/src/test/java/com/google/devtools/build/lib/runtime/commands/CleanCommandRecommendsAsyncTest.java b/src/test/java/com/google/devtools/build/lib/runtime/commands/CleanCommandRecommendsAsyncTest.java index bfa2b907de..7c0006caaa 100644 --- a/src/test/java/com/google/devtools/build/lib/runtime/commands/CleanCommandRecommendsAsyncTest.java +++ b/src/test/java/com/google/devtools/build/lib/runtime/commands/CleanCommandRecommendsAsyncTest.java @@ -21,7 +21,6 @@ import com.google.devtools.build.lib.analysis.ConfiguredRuleClassProvider; import com.google.devtools.build.lib.analysis.ServerDirectories; import com.google.devtools.build.lib.analysis.config.BuildConfiguration; import com.google.devtools.build.lib.runtime.BlazeCommandDispatcher; -import com.google.devtools.build.lib.runtime.BlazeCommandDispatcher.LockingMode; import com.google.devtools.build.lib.runtime.BlazeModule; import com.google.devtools.build.lib.runtime.BlazeRuntime; import com.google.devtools.build.lib.runtime.BlazeServerStartupOptions; @@ -104,7 +103,7 @@ public class CleanCommandRecommendsAsyncTest { runtime.initWorkspace(directories, /* binTools= */ null); BlazeCommandDispatcher dispatcher = new BlazeCommandDispatcher(runtime, new CleanCommand(os)); - dispatcher.exec(commandLine, LockingMode.ERROR_OUT, "test", outErr); + dispatcher.exec(commandLine, "test", outErr); String output = outErr.toString(); if (expectSuggestion) { -- cgit v1.2.3