Adding support for noBuild, output and framework.
This commit is contained in:
parent
579df78466
commit
a8e7df848b
2 changed files with 66 additions and 80 deletions
|
@ -36,67 +36,55 @@ namespace Microsoft.DotNet.Tools.Test3
|
|||
"Settings to use when running tests." + Environment.NewLine,
|
||||
CommandOptionType.SingleValue);
|
||||
|
||||
var testsOption = cmd.Option(
|
||||
"--tests <TestNames>",
|
||||
@"Run tests with names that match the provided values. To provide multiple
|
||||
values, separate them by commas.
|
||||
Examples: --tests:TestMethod1
|
||||
--tests:TestMethod1,testMethod2" + Environment.NewLine,
|
||||
CommandOptionType.SingleValue);
|
||||
|
||||
var testAdapterPathOption = cmd.Option(
|
||||
"--testAdapterPath",
|
||||
@"This makes vstest.console.exe process use custom test adapters
|
||||
from a given path (if any) in the test run.
|
||||
Example --testAdapterPath:<pathToCustomAdapters>" + Environment.NewLine,
|
||||
CommandOptionType.SingleValue);
|
||||
|
||||
var platformOption = cmd.Option(
|
||||
"--platform <PlatformType>",
|
||||
@"Target platform architecture to be used for test execution.
|
||||
Valid values are x86, x64 and ARM." + Environment.NewLine,
|
||||
CommandOptionType.SingleValue);
|
||||
|
||||
var frameworkOption = cmd.Option(
|
||||
"--framework <FrameworkVersion>",
|
||||
@"Target .Net Framework version to be used for test execution.
|
||||
Valid values are "".NETFramework, Version = v4.6"", "".NETCoreApp, Version = v1.0"" etc.
|
||||
Other supported values are Framework35, Framework40 and Framework45" + Environment.NewLine,
|
||||
CommandOptionType.SingleValue);
|
||||
|
||||
var testCaseFilterOption = cmd.Option(
|
||||
"--testCaseFilter <Expression>",
|
||||
@"Run tests that match the given expression.
|
||||
<Expression> is of the format <property>Operator<value>[|&<Expression>]
|
||||
where Operator is one of =, != or ~ (Operator ~ has 'contains'
|
||||
semantics and is applicable for string properties like DisplayName).
|
||||
Parenthesis () can be used to group sub-expressions.
|
||||
Examples: --testCaseFilter:""Priority = 1""
|
||||
--testCaseFilter:""(FullyQualifiedName~Nightly | Name = MyTestMethod)""" + Environment.NewLine,
|
||||
CommandOptionType.SingleValue);
|
||||
|
||||
// TODO tfs publisher text
|
||||
var loggerOption = cmd.Option(
|
||||
"--logger <LoggerUri/FriendlyName>",
|
||||
@"Specify a logger for test results. For example, to log results into a
|
||||
Visual Studio Test Results File(TRX) use --logger:trx" + Environment.NewLine,
|
||||
CommandOptionType.MultipleValue);
|
||||
|
||||
var listTestsOption = cmd.Option(
|
||||
"-lt|--listTests",
|
||||
@"Lists discovered tests" + Environment.NewLine,
|
||||
CommandOptionType.NoValue);
|
||||
|
||||
var parentProcessIdOption = cmd.Option(
|
||||
"--parentProcessId <ParentProcessId>",
|
||||
@"Process Id of the Parent Process responsible for launching current process." + Environment.NewLine,
|
||||
var testCaseFilterOption = cmd.Option(
|
||||
"--testCaseFilter <Expression>",
|
||||
@"Run tests that match the given expression.
|
||||
<Expression> is of the format <property>Operator<value>[|&<Expression>]
|
||||
where Operator is one of =, != or ~ (Operator ~ has 'contains'
|
||||
semantics and is applicable for string properties like DisplayName).
|
||||
Parenthesis () can be used to group sub-expressions.
|
||||
Examples: --testCaseFilter:""Priority = 1""
|
||||
--testCaseFilter:""(FullyQualifiedName~Nightly | Name = MyTestMethod)""" + Environment.NewLine,
|
||||
CommandOptionType.SingleValue);
|
||||
|
||||
var portOption = cmd.Option(
|
||||
"--port <Port>",
|
||||
@"The Port for socket connection and receiving the event messages." + Environment.NewLine,
|
||||
var testAdapterPathOption = cmd.Option(
|
||||
"--testAdapterPath",
|
||||
@"This makes vstest.console.exe process use custom test adapters
|
||||
from a given path (if any) in the test run.
|
||||
Example --testAdapterPath:<pathToCustomAdapters>" + Environment.NewLine,
|
||||
CommandOptionType.SingleValue);
|
||||
|
||||
var loggerOption = cmd.Option(
|
||||
"--logger <LoggerUri/FriendlyName>",
|
||||
@"Specify a logger for test results. For example, to log results into a
|
||||
Visual Studio Test Results File(TRX) use --logger:trx" + Environment.NewLine,
|
||||
CommandOptionType.SingleValue);
|
||||
|
||||
var configurationOption = cmd.Option(
|
||||
"-c|--Configuration <Configuration>",
|
||||
@"Configuration under which to build, i.e. Debug/Release" + Environment.NewLine,
|
||||
CommandOptionType.SingleValue);
|
||||
|
||||
var frameworkOption = cmd.Option(
|
||||
"--framework <FrameworkVersion>",
|
||||
@"Looks for test binaries for a specific framework" + Environment.NewLine,
|
||||
CommandOptionType.SingleValue);
|
||||
|
||||
var outputOption = cmd.Option(
|
||||
"-o|--output <OotputDir>",
|
||||
@"Directory in which to find the binaries to be run" + Environment.NewLine,
|
||||
CommandOptionType.SingleValue);
|
||||
|
||||
var noBuildtOption = cmd.Option(
|
||||
"--noBuild",
|
||||
@"Do not build project before testing." + Environment.NewLine,
|
||||
CommandOptionType.NoValue);
|
||||
|
||||
cmd.OnExecute(() =>
|
||||
{
|
||||
var msbuildArgs = new List<string>()
|
||||
|
@ -112,24 +100,9 @@ namespace Microsoft.DotNet.Tools.Test3
|
|||
msbuildArgs.Add($"/p:VSTestSetting={settingOption.Value()}");
|
||||
}
|
||||
|
||||
if (testsOption.HasValue())
|
||||
if (listTestsOption.HasValue())
|
||||
{
|
||||
msbuildArgs.Add($"/p:VSTestTests={testsOption.Value()}");
|
||||
}
|
||||
|
||||
if (testAdapterPathOption.HasValue())
|
||||
{
|
||||
msbuildArgs.Add($"/p:VSTestTestAdapterPath={testAdapterPathOption.Value()}");
|
||||
}
|
||||
|
||||
if (platformOption.HasValue())
|
||||
{
|
||||
msbuildArgs.Add($"/p:VSTestPlatform={platformOption.Value()}");
|
||||
}
|
||||
|
||||
if (frameworkOption.HasValue())
|
||||
{
|
||||
msbuildArgs.Add($"/p:VSTestFramework={frameworkOption.Value()}");
|
||||
msbuildArgs.Add($"/p:VSTestListTests=true");
|
||||
}
|
||||
|
||||
if (testCaseFilterOption.HasValue())
|
||||
|
@ -137,24 +110,34 @@ namespace Microsoft.DotNet.Tools.Test3
|
|||
msbuildArgs.Add($"/p:VSTestTestCaseFilter={testCaseFilterOption.Value()}");
|
||||
}
|
||||
|
||||
if (testAdapterPathOption.HasValue())
|
||||
{
|
||||
msbuildArgs.Add($"/p:VSTestTestAdapterPath={testAdapterPathOption.Value()}");
|
||||
}
|
||||
|
||||
if (loggerOption.HasValue())
|
||||
{
|
||||
msbuildArgs.Add($"/p:VSTestLogger={string.Join(";", loggerOption.Values)}");
|
||||
}
|
||||
|
||||
if (listTestsOption.HasValue())
|
||||
if (configurationOption.HasValue())
|
||||
{
|
||||
msbuildArgs.Add($"/p:VSTestListTests=true");
|
||||
msbuildArgs.Add($"/p:Configuration={configurationOption.Value()}");
|
||||
}
|
||||
|
||||
if (parentProcessIdOption.HasValue())
|
||||
if (frameworkOption.HasValue())
|
||||
{
|
||||
msbuildArgs.Add($"/p:VSTestParentProcessId={parentProcessIdOption.Value()}");
|
||||
msbuildArgs.Add($"/p:TargetFramework={frameworkOption.Value()}");
|
||||
}
|
||||
|
||||
if (portOption.HasValue())
|
||||
if (outputOption.HasValue())
|
||||
{
|
||||
msbuildArgs.Add($"/p:VSTestPort={portOption.Value()}");
|
||||
msbuildArgs.Add($"/p:OutputPath={outputOption.Value()}");
|
||||
}
|
||||
|
||||
if (noBuildtOption.HasValue())
|
||||
{
|
||||
msbuildArgs.Add($"/p:VSTestNoBuild=true");
|
||||
}
|
||||
|
||||
string defaultproject = GetSingleTestProjectToRunTestIfNotProvided(argRoot.Value, cmd.RemainingArguments);
|
||||
|
@ -164,7 +147,10 @@ namespace Microsoft.DotNet.Tools.Test3
|
|||
msbuildArgs.Add(defaultproject);
|
||||
}
|
||||
|
||||
msbuildArgs.Add(argRoot.Value);
|
||||
if (!string.IsNullOrEmpty(argRoot.Value))
|
||||
{
|
||||
msbuildArgs.Add(argRoot.Value);
|
||||
}
|
||||
|
||||
// Add remaining arguments that the parser did not understand,
|
||||
msbuildArgs.AddRange(cmd.RemainingArguments);
|
||||
|
@ -178,7 +164,7 @@ namespace Microsoft.DotNet.Tools.Test3
|
|||
private static string GetSingleTestProjectToRunTestIfNotProvided(string args, List<string> remainingArguments)
|
||||
{
|
||||
string result = string.Empty;
|
||||
int projectFound = NumberOfTestProjectInRemainingArgs(remainingArguments) + NumberOfTestProjectArgsRoot(args);
|
||||
int projectFound = NumberOfTestProjectInRemainingArgs(remainingArguments) + NumberOfTestProjectInArgsRoot(args);
|
||||
|
||||
if (projectFound > 1)
|
||||
{
|
||||
|
@ -193,7 +179,7 @@ namespace Microsoft.DotNet.Tools.Test3
|
|||
return result;
|
||||
}
|
||||
|
||||
private static int NumberOfTestProjectArgsRoot(string args)
|
||||
private static int NumberOfTestProjectInArgsRoot(string args)
|
||||
{
|
||||
Regex pattern = new Regex(@"^.*\..*proj$");
|
||||
|
||||
|
|
|
@ -28,8 +28,8 @@
|
|||
"Microsoft.CodeAnalysis.Build.Tasks": "2.0.0-beta6-60922-08",
|
||||
"System.Runtime.Serialization.Xml": "4.1.1",
|
||||
"NuGet.Build.Tasks": "3.6.0-beta.1.msbuild.17",
|
||||
"Microsoft.TestPlatform.CLI": "15.0.0-preview-20161003-01",
|
||||
"Microsoft.TestPlatform.Build": "15.0.0-preview-20160928-07"
|
||||
"Microsoft.TestPlatform.CLI": "15.0.0-preview-20161005-01",
|
||||
"Microsoft.TestPlatform.Build": "15.0.0-preview-20161005-01"
|
||||
},
|
||||
"frameworks": {
|
||||
"netcoreapp1.0": {
|
||||
|
|
Loading…
Add table
Reference in a new issue