Fix 4508: CLI verbs that call into msbuild should control their output (#4719)
* Fix 4508: CLI verbs that call into msbuild should control their output * fix failing tests + tiny bufix in dotnet test
This commit is contained in:
parent
43df9a170d
commit
7a3bc96f75
11 changed files with 128 additions and 5 deletions
|
@ -31,5 +31,73 @@ namespace Microsoft.DotNet.Cli.MSBuild.IntegrationTests
|
|||
.Execute(command)
|
||||
.Should().Pass();
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("build")]
|
||||
[InlineData("clean")]
|
||||
[InlineData("pack")]
|
||||
[InlineData("publish")]
|
||||
public void When_dotnet_command_invokes_msbuild_with_no_args_verbosity_is_set_to_minimum(string command)
|
||||
{
|
||||
var testInstance = TestAssets.Get("MSBuildIntegration")
|
||||
.CreateInstance(identifier: command)
|
||||
.WithSourceFiles();
|
||||
|
||||
var cmd = new DotnetCommand()
|
||||
.WithWorkingDirectory(testInstance.Root)
|
||||
.ExecuteWithCapturedOutput(command);
|
||||
cmd.Should().Pass();
|
||||
cmd.StdOut.Should().NotContain("Message with normal importance");
|
||||
// sanity check
|
||||
cmd.StdOut.Should().Contain("Message with high importance");
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("build")]
|
||||
[InlineData("clean")]
|
||||
[InlineData("pack")]
|
||||
[InlineData("publish")]
|
||||
[InlineData("test")]
|
||||
public void When_dotnet_command_invokes_msbuild_with_diag_verbosity_Then_arg_is_passed(string command)
|
||||
{
|
||||
var testInstance = TestAssets.Get("MSBuildIntegration")
|
||||
.CreateInstance(identifier: command)
|
||||
.WithSourceFiles();
|
||||
|
||||
var cmd = new DotnetCommand()
|
||||
.WithWorkingDirectory(testInstance.Root)
|
||||
.ExecuteWithCapturedOutput($"{command} -v diag");
|
||||
cmd.Should().Pass();
|
||||
cmd.StdOut.Should().Contain("Message with low importance");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void When_dotnet_test_invokes_msbuild_with_no_args_verbosity_is_set_to_quiet()
|
||||
{
|
||||
string command = "test";
|
||||
var testInstance = TestAssets.Get("MSBuildIntegration")
|
||||
.CreateInstance(identifier: command)
|
||||
.WithSourceFiles();
|
||||
|
||||
var cmd = new DotnetCommand()
|
||||
.WithWorkingDirectory(testInstance.Root)
|
||||
.ExecuteWithCapturedOutput(command);
|
||||
cmd.Should().Pass();
|
||||
cmd.StdOut.Should().NotContain("Message with high importance");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void When_dotnet_msbuild_command_is_invoked_with_non_msbuild_switch_Then_it_fails()
|
||||
{
|
||||
string command = "msbuild";
|
||||
var testInstance = TestAssets.Get("MSBuildIntegration")
|
||||
.CreateInstance(identifier: command)
|
||||
.WithSourceFiles();
|
||||
|
||||
var cmd = new DotnetCommand()
|
||||
.WithWorkingDirectory(testInstance.Root)
|
||||
.ExecuteWithCapturedOutput($"{command} -v diag");
|
||||
cmd.ExitCode.Should().NotBe(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue