Merge pull request #3132 from vcsjones/fix-3084
Move command line parsing into try/catch for test.
This commit is contained in:
commit
ed7c79bb48
2 changed files with 41 additions and 2 deletions
|
@ -26,10 +26,10 @@ namespace Microsoft.DotNet.Tools.Test
|
||||||
|
|
||||||
var dotnetTestParams = new DotnetTestParams();
|
var dotnetTestParams = new DotnetTestParams();
|
||||||
|
|
||||||
dotnetTestParams.Parse(args);
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
dotnetTestParams.Parse(args);
|
||||||
|
|
||||||
if (dotnetTestParams.Help)
|
if (dotnetTestParams.Help)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using Microsoft.DotNet.InternalAbstractions;
|
using Microsoft.DotNet.InternalAbstractions;
|
||||||
using Microsoft.DotNet.ProjectModel;
|
using Microsoft.DotNet.ProjectModel;
|
||||||
|
@ -95,6 +96,44 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
|
||||||
result = testCommand.Execute($"{_projectFilePath} -o {_defaultOutputPath} --no-build");
|
result = testCommand.Execute($"{_projectFilePath} -o {_defaultOutputPath} --no-build");
|
||||||
result.Should().Pass();
|
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()
|
private string GetNotSoLongBuildBasePath()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue