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
|
@ -32,7 +32,7 @@
|
|||
public const string CmdLoggerOption = "LoggerUri/FriendlyName";
|
||||
|
||||
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";
|
||||
|
||||
|
|
|
@ -116,7 +116,7 @@ namespace Microsoft.DotNet.Tools.Test
|
|||
|
||||
if (loggerOption.HasValue())
|
||||
{
|
||||
msbuildArgs.Add($"/p:VSTestLogger={string.Join(";", loggerOption.Values)}");
|
||||
msbuildArgs.Add($"/p:VSTestLogger={string.Join(";", GetSemiColonEscapedArgs(loggerOption.Values))}");
|
||||
}
|
||||
|
||||
if (configurationOption.HasValue())
|
||||
|
@ -166,7 +166,11 @@ namespace Microsoft.DotNet.Tools.Test
|
|||
}
|
||||
|
||||
// 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();
|
||||
});
|
||||
|
@ -242,5 +246,27 @@ namespace Microsoft.DotNet.Tools.Test
|
|||
|
||||
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(
|
||||
i => (i.Include == "Microsoft.NET.Test.Sdk" &&
|
||||
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));
|
||||
|
||||
mockProj.Items.Should().NotContain(
|
||||
|
@ -283,7 +283,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
|||
mockProj.Items.Should().ContainSingle(
|
||||
i => (i.Include == "Microsoft.NET.Test.Sdk" &&
|
||||
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);
|
||||
|
||||
mockProj.Items.Should().ContainSingle(
|
||||
|
@ -325,7 +325,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
|||
mockProj.Items.Should().ContainSingle(
|
||||
i => (i.Include == "Microsoft.NET.Test.Sdk" &&
|
||||
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));
|
||||
|
||||
mockProj.Items.Should().ContainSingle(
|
||||
|
@ -364,7 +364,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
|||
mockProj.Items.Should().ContainSingle(
|
||||
i => (i.Include == "Microsoft.NET.Test.Sdk" &&
|
||||
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));
|
||||
|
||||
mockProj.Items.Should().ContainSingle(
|
||||
|
|
|
@ -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")]
|
||||
public void ItBuildsAndTestsAppWhenRestoringToSpecificDirectory()
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue