Merge pull request #3132 from vcsjones/fix-3084

Move command line parsing into try/catch for test.
This commit is contained in:
Eric Erhardt 2016-05-20 19:03:32 -05:00
commit ed7c79bb48
2 changed files with 41 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

@ -2,6 +2,7 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
using System.Collections.Generic;
using System.IO;
using Microsoft.DotNet.InternalAbstractions;
using Microsoft.DotNet.ProjectModel;
@ -95,6 +96,44 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
result = testCommand.Execute($"{_projectFilePath} -o {_defaultOutputPath} --no-build");
result.Should().Pass();
}
[Theory]
[MemberData("ArgumentNames")]
public void It_fails_correctly_with_unspecified_arguments_with_long_form(string argument)
{
new DotnetTestCommand()
.ExecuteWithCapturedOutput($"{_projectFilePath} --{argument}")
.Should()
.Fail()
.And
.HaveStdErrContaining($"Missing value for option '{argument}'");
}
[Theory]
[MemberData("ArgumentNames")]
public void It_fails_correctly_with_unspecified_arguments_with_short_form(string argument)
{
new DotnetTestCommand()
.ExecuteWithCapturedOutput($"{_projectFilePath} -{argument[0]}")
.Should()
.Fail()
.And
.HaveStdErrContaining($"Missing value for option '{argument}'");
}
public static IEnumerable<object[]> ArgumentNames
{
get
{
return new[]
{
new object[] { "output" },
new object[] { "configuration" },
new object[] { "runtime" },
new object[] { "build-base-path" }
};
}
}
private string GetNotSoLongBuildBasePath()
{