Move command line parsing into try/catch for test.

If invalid parameters are specified in `dotnet test`, the CLI does not
catch exceptions that can be thrown such as when specifying `-r` without
a runtime.

Fixes 3084.
This commit is contained in:
Kevin Jones 2016-05-19 11:02:56 -04:00
parent 4711f5983f
commit 99d8853ef0
2 changed files with 16 additions and 2 deletions

View file

@ -26,10 +26,10 @@ namespace Microsoft.DotNet.Tools.Test
var dotnetTestParams = new DotnetTestParams();
dotnetTestParams.Parse(args);
try
{
dotnetTestParams.Parse(args);
if (dotnetTestParams.Help)
{
return 0;

View file

@ -25,5 +25,19 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
.And
.HaveStdErrContaining("dotnet restore");
}
[Fact]
public void It_fails_correctly_with_invalid_runtime_parameter()
{
var instance = TestAssetsManager.CreateTestInstance(Path.Combine("ProjectsWithTests", "NetCoreAppOnlyProject"));
new DotnetTestCommand()
.WithLockFiles()
.ExecuteWithCapturedOutput(instance.TestRoot)
.Should()
.Fail()
.And
.HaveStdErrContaining("Missing value for option 'runtime'");
}
}
}