From ea85555a97acf3d0346d470c138c468062a436f8 Mon Sep 17 00:00:00 2001 From: Peter Huene Date: Mon, 27 Nov 2017 23:03:33 -0800 Subject: [PATCH] Add verbosity option to run command. This commit adds the verbosity option to the run command. This will be used in tests for visibility into what the run command is doing. The default verbosity is unaffected. Fixes issue #7932. --- .../commands/dotnet-run/RunCommandParser.cs | 3 ++- .../GivenDotnetRunRunsCsProj.cs | 22 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/dotnet/commands/dotnet-run/RunCommandParser.cs b/src/dotnet/commands/dotnet-run/RunCommandParser.cs index a89a4dc3d..5685b467f 100644 --- a/src/dotnet/commands/dotnet-run/RunCommandParser.cs +++ b/src/dotnet/commands/dotnet-run/RunCommandParser.cs @@ -51,7 +51,8 @@ namespace Microsoft.DotNet.Cli "--no-build", LocalizableStrings.CommandOptionNoBuildDescription, Accept.NoArguments()), - CommonOptions.NoRestoreOption() + CommonOptions.NoRestoreOption(), + CommonOptions.VerbosityOption() }); } } \ No newline at end of file diff --git a/test/dotnet-run.Tests/GivenDotnetRunRunsCsProj.cs b/test/dotnet-run.Tests/GivenDotnetRunRunsCsProj.cs index c55c70800..052cd9c35 100644 --- a/test/dotnet-run.Tests/GivenDotnetRunRunsCsProj.cs +++ b/test/dotnet-run.Tests/GivenDotnetRunRunsCsProj.cs @@ -518,5 +518,27 @@ namespace Microsoft.DotNet.Cli.Run.Tests .And.HaveStdOutContaining("(NO MESSAGE)") .And.HaveStdErrContaining(string.Format(LocalizableStrings.RunCommandExceptionCouldNotApplyLaunchSettings, LocalizableStrings.DefaultLaunchProfileDisplayName, "").Trim()); } + + [Fact] + public void ItRunsWithTheSpecifiedVerbosity() + { + var testAppName = "MSBuildTestApp"; + var testInstance = TestAssets.Get(testAppName) + .CreateInstance() + .WithSourceFiles(); + + var result = new RunCommand() + .WithWorkingDirectory( testInstance.Root.FullName) + .ExecuteWithCapturedOutput("-v:n"); + + result.Should().Pass() + .And.HaveStdOutContaining("Hello World!"); + + if (!DotnetUnderTest.IsLocalized()) + { + result.Should().HaveStdOutContaining("Restore") + .And.HaveStdOutContaining("CoreCompile"); + } + } } }