Added support for passing runsettings options through command line after --
This commit is contained in:
parent
10f52d9a15
commit
8d86e14d44
5 changed files with 78 additions and 11 deletions
|
@ -98,7 +98,7 @@
|
||||||
|
|
||||||
<!-- Workaround for https://github.com/dotnet/sdk/issues/115 -->
|
<!-- Workaround for https://github.com/dotnet/sdk/issues/115 -->
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<HackFilesToCopy Include="$(NuGetPackagesDir)\microsoft.build.runtime\$(CLI_MSBuild_Version)\contentFiles\any\netcoreapp1.0\**;$(NuGetPackagesDir)\microsoft.codeanalysis.build.tasks\2.0.0-beta6-60922-08\contentFiles\any\any\**;$(NuGetPackagesDir)\microsoft.testplatform.cli\$(CLI_TestPlatform_Version)\contentFiles\any\any\**" />
|
<HackFilesToCopy Include="$(NuGetPackagesDir)\microsoft.build.runtime\$(CLI_MSBuild_Version)\contentFiles\any\netcoreapp1.0\**;$(NuGetPackagesDir)\microsoft.codeanalysis.build.tasks\2.0.0-beta6-60922-08\contentFiles\any\any\**;$(NuGetPackagesDir)\microsoft.testplatform.cli\$(CLI_TestPlatform_Version)\contentFiles\any\any\**" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Copy SourceFiles="@(HackFilesToCopy)"
|
<Copy SourceFiles="@(HackFilesToCopy)"
|
||||||
DestinationFiles="@(HackFilesToCopy->'$(SdkOutputDirectory)/%(RecursiveDir)%(Filename)%(Extension)')" />
|
DestinationFiles="@(HackFilesToCopy->'$(SdkOutputDirectory)/%(RecursiveDir)%(Filename)%(Extension)')" />
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
public const string CmdLoggerOption = "LoggerUri/FriendlyName";
|
public const string CmdLoggerOption = "LoggerUri/FriendlyName";
|
||||||
|
|
||||||
public const string CmdLoggerDescription = @"Specify a logger for test results.
|
public const string CmdLoggerDescription = @"Specify a logger for test results.
|
||||||
Example: --logger:trx";
|
Example: --logger ""trx[;LogFileName=<Defaults to unique file name>]""";
|
||||||
|
|
||||||
public const string CmdConfiguration = "CONFIGURATION";
|
public const string CmdConfiguration = "CONFIGURATION";
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ namespace Microsoft.DotNet.Tools.Test
|
||||||
FullName = LocalizableStrings.AppFullName,
|
FullName = LocalizableStrings.AppFullName,
|
||||||
Description = LocalizableStrings.AppDescription,
|
Description = LocalizableStrings.AppDescription,
|
||||||
HandleRemainingArguments = true,
|
HandleRemainingArguments = true,
|
||||||
ArgumentSeparatorHelpText = HelpMessageStrings.MSBuildAdditionalArgsHelpText
|
ArgumentSeparatorHelpText = HelpMessageStrings.MSBuildAdditionalArgsHelpText
|
||||||
};
|
};
|
||||||
|
|
||||||
cmd.HelpOption("-h|--help");
|
cmd.HelpOption("-h|--help");
|
||||||
|
@ -116,7 +116,7 @@ namespace Microsoft.DotNet.Tools.Test
|
||||||
|
|
||||||
if (loggerOption.HasValue())
|
if (loggerOption.HasValue())
|
||||||
{
|
{
|
||||||
msbuildArgs.Add($"/p:VSTestLogger={string.Join(";", loggerOption.Values)}");
|
msbuildArgs.Add($"/p:VSTestLogger={string.Join(";", GetSemiColonEscapedArgs(loggerOption.Values))}");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (configurationOption.HasValue())
|
if (configurationOption.HasValue())
|
||||||
|
@ -155,7 +155,7 @@ namespace Microsoft.DotNet.Tools.Test
|
||||||
|
|
||||||
string defaultproject = GetSingleTestProjectToRunTestIfNotProvided(argRoot.Value, cmd.RemainingArguments);
|
string defaultproject = GetSingleTestProjectToRunTestIfNotProvided(argRoot.Value, cmd.RemainingArguments);
|
||||||
|
|
||||||
if(!string.IsNullOrEmpty(defaultproject))
|
if (!string.IsNullOrEmpty(defaultproject))
|
||||||
{
|
{
|
||||||
msbuildArgs.Add(defaultproject);
|
msbuildArgs.Add(defaultproject);
|
||||||
}
|
}
|
||||||
|
@ -166,7 +166,11 @@ namespace Microsoft.DotNet.Tools.Test
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add remaining arguments that the parser did not understand,
|
// Add remaining arguments that the parser did not understand,
|
||||||
msbuildArgs.AddRange(cmd.RemainingArguments);
|
if (cmd.RemainingArguments != null && cmd.RemainingArguments.Count > 0)
|
||||||
|
{
|
||||||
|
var arr = GetSemiColonEscapedArgs(cmd.RemainingArguments);
|
||||||
|
msbuildArgs.Add(string.Format("/p:VSTestCLIRunSettings=\"{0}\"", string.Join(";", arr)));
|
||||||
|
}
|
||||||
|
|
||||||
return new MSBuildForwardingApp(msbuildArgs).Execute();
|
return new MSBuildForwardingApp(msbuildArgs).Execute();
|
||||||
});
|
});
|
||||||
|
@ -242,5 +246,27 @@ namespace Microsoft.DotNet.Tools.Test
|
||||||
|
|
||||||
return projectFiles[0];
|
return projectFiles[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static string[] GetSemiColonEscapedArgs(List<string> args)
|
||||||
|
{
|
||||||
|
int counter = 0;
|
||||||
|
string[] array = new string[args.Count];
|
||||||
|
|
||||||
|
foreach (string arg in args)
|
||||||
|
{
|
||||||
|
if (arg.IndexOf(";") != -1)
|
||||||
|
{
|
||||||
|
array[counter] = arg.Replace(";", "%3b");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
array[counter] = arg;
|
||||||
|
}
|
||||||
|
|
||||||
|
counter++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return array;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -250,7 +250,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
||||||
mockProj.Items.Should().ContainSingle(
|
mockProj.Items.Should().ContainSingle(
|
||||||
i => (i.Include == "Microsoft.NET.Test.Sdk" &&
|
i => (i.Include == "Microsoft.NET.Test.Sdk" &&
|
||||||
i.ItemType == "PackageReference" &&
|
i.ItemType == "PackageReference" &&
|
||||||
i.GetMetadataWithName("Version").Value == "15.0.0-preview-20161024-02" &&
|
i.GetMetadataWithName("Version").Value == "15.0.0-preview-20161227-02" &&
|
||||||
i.GetMetadataWithName("Version").ExpressedAsAttribute));
|
i.GetMetadataWithName("Version").ExpressedAsAttribute));
|
||||||
|
|
||||||
mockProj.Items.Should().NotContain(
|
mockProj.Items.Should().NotContain(
|
||||||
|
@ -283,7 +283,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
||||||
mockProj.Items.Should().ContainSingle(
|
mockProj.Items.Should().ContainSingle(
|
||||||
i => (i.Include == "Microsoft.NET.Test.Sdk" &&
|
i => (i.Include == "Microsoft.NET.Test.Sdk" &&
|
||||||
i.ItemType == "PackageReference" &&
|
i.ItemType == "PackageReference" &&
|
||||||
i.GetMetadataWithName("Version").Value == "15.0.0-preview-20161024-02") &&
|
i.GetMetadataWithName("Version").Value == "15.0.0-preview-20161227-02") &&
|
||||||
i.GetMetadataWithName("Version").ExpressedAsAttribute);
|
i.GetMetadataWithName("Version").ExpressedAsAttribute);
|
||||||
|
|
||||||
mockProj.Items.Should().ContainSingle(
|
mockProj.Items.Should().ContainSingle(
|
||||||
|
@ -325,7 +325,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
||||||
mockProj.Items.Should().ContainSingle(
|
mockProj.Items.Should().ContainSingle(
|
||||||
i => (i.Include == "Microsoft.NET.Test.Sdk" &&
|
i => (i.Include == "Microsoft.NET.Test.Sdk" &&
|
||||||
i.ItemType == "PackageReference" &&
|
i.ItemType == "PackageReference" &&
|
||||||
i.GetMetadataWithName("Version").Value == "15.0.0-preview-20161024-02" &&
|
i.GetMetadataWithName("Version").Value == "15.0.0-preview-20161227-02" &&
|
||||||
i.GetMetadataWithName("Version").ExpressedAsAttribute));
|
i.GetMetadataWithName("Version").ExpressedAsAttribute));
|
||||||
|
|
||||||
mockProj.Items.Should().ContainSingle(
|
mockProj.Items.Should().ContainSingle(
|
||||||
|
@ -364,7 +364,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
||||||
mockProj.Items.Should().ContainSingle(
|
mockProj.Items.Should().ContainSingle(
|
||||||
i => (i.Include == "Microsoft.NET.Test.Sdk" &&
|
i => (i.Include == "Microsoft.NET.Test.Sdk" &&
|
||||||
i.ItemType == "PackageReference" &&
|
i.ItemType == "PackageReference" &&
|
||||||
i.GetMetadataWithName("Version").Value == "15.0.0-preview-20161024-02" &&
|
i.GetMetadataWithName("Version").Value == "15.0.0-preview-20161227-02" &&
|
||||||
i.GetMetadataWithName("Version").ExpressedAsAttribute));
|
i.GetMetadataWithName("Version").ExpressedAsAttribute));
|
||||||
|
|
||||||
mockProj.Items.Should().ContainSingle(
|
mockProj.Items.Should().ContainSingle(
|
||||||
|
|
|
@ -101,7 +101,7 @@ namespace Microsoft.DotNet.Cli.Test.Tests
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void TestWillCreateTrxLogger()
|
public void TestWillCreateTrxLogger()
|
||||||
{
|
{
|
||||||
// Copy VSTestDotNetCore project in output directory of project dotnet-vstest.Tests
|
// Copy VSTestDotNetCore project in output directory of project dotnet-vstest.Tests
|
||||||
string testAppName = "VSTestDotNetCore";
|
string testAppName = "VSTestDotNetCore";
|
||||||
TestInstance testInstance = TestAssetsManager.CreateTestInstance(testAppName);
|
TestInstance testInstance = TestAssetsManager.CreateTestInstance(testAppName);
|
||||||
|
@ -140,6 +140,47 @@ namespace Microsoft.DotNet.Cli.Test.Tests
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void ItCreatesTrxReportInTheSpecifiedResultsDirectory()
|
||||||
|
{
|
||||||
|
// Copy VSTestDotNetCore project in output directory of project dotnet-vstest.Tests
|
||||||
|
string testAppName = "VSTestDotNetCore";
|
||||||
|
TestInstance testInstance = TestAssetsManager.CreateTestInstance(testAppName);
|
||||||
|
|
||||||
|
string testProjectDirectory = testInstance.TestRoot;
|
||||||
|
|
||||||
|
// Restore project VSTestDotNetCore
|
||||||
|
new RestoreCommand()
|
||||||
|
.WithWorkingDirectory(testProjectDirectory)
|
||||||
|
.Execute()
|
||||||
|
.Should()
|
||||||
|
.Pass();
|
||||||
|
|
||||||
|
string trxLoggerDirectory = Path.Combine(testProjectDirectory, "ResultsDirectory");
|
||||||
|
|
||||||
|
// Delete trxLoggerDirectory if it exist
|
||||||
|
if (Directory.Exists(trxLoggerDirectory))
|
||||||
|
{
|
||||||
|
Directory.Delete(trxLoggerDirectory, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Call test with logger enable
|
||||||
|
CommandResult result = new DotnetTestCommand()
|
||||||
|
.WithWorkingDirectory(testProjectDirectory)
|
||||||
|
.ExecuteWithCapturedOutput(" --logger \"trx;logfilename=custom.trx\" -- RunConfiguration.ResultsDirectory=" + trxLoggerDirectory);
|
||||||
|
|
||||||
|
// Verify
|
||||||
|
String[] trxFiles = Directory.GetFiles(trxLoggerDirectory, "*.trx");
|
||||||
|
Assert.Equal(1, trxFiles.Length);
|
||||||
|
result.StdOut.Should().Contain(trxFiles[0]);
|
||||||
|
|
||||||
|
// Cleanup trxLoggerDirectory if it exist
|
||||||
|
if (Directory.Exists(trxLoggerDirectory))
|
||||||
|
{
|
||||||
|
Directory.Delete(trxLoggerDirectory, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[Fact(Skip = "https://github.com/dotnet/cli/issues/5035")]
|
[Fact(Skip = "https://github.com/dotnet/cli/issues/5035")]
|
||||||
public void ItBuildsAndTestsAppWhenRestoringToSpecificDirectory()
|
public void ItBuildsAndTestsAppWhenRestoringToSpecificDirectory()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue