Handling both mstest args and runsettings options after --
This commit is contained in:
parent
8d86e14d44
commit
245727183c
4 changed files with 42 additions and 28 deletions
|
@ -52,5 +52,7 @@
|
|||
Logs are written to the provided file.";
|
||||
|
||||
public const string CmdNoBuildDescription = @"Do not build project before testing.";
|
||||
|
||||
public const string RunSettingsArgsHelpText = @"Any extra options that should be passed to MSBuild or adapter. See 'dotnet msbuild -h' and 'dotnet vstest --help' for available options.";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,8 @@ namespace Microsoft.DotNet.Tools.Test
|
|||
FullName = LocalizableStrings.AppFullName,
|
||||
Description = LocalizableStrings.AppDescription,
|
||||
HandleRemainingArguments = true,
|
||||
ArgumentSeparatorHelpText = HelpMessageStrings.MSBuildAdditionalArgsHelpText
|
||||
ArgumentSeparatorHelpText = LocalizableStrings.RunSettingsArgsHelpText,
|
||||
AllowArgumentSeparator = true
|
||||
};
|
||||
|
||||
cmd.HelpOption("-h|--help");
|
||||
|
@ -165,13 +166,16 @@ namespace Microsoft.DotNet.Tools.Test
|
|||
msbuildArgs.Add(argRoot.Value);
|
||||
}
|
||||
|
||||
// Add remaining arguments that the parser did not understand,
|
||||
// Get runsetings options specified after --
|
||||
if (cmd.RemainingArguments != null && cmd.RemainingArguments.Count > 0)
|
||||
{
|
||||
var arr = GetSemiColonEscapedArgs(cmd.RemainingArguments);
|
||||
msbuildArgs.Add(string.Format("/p:VSTestCLIRunSettings=\"{0}\"", string.Join(";", arr)));
|
||||
var runSettingsOptions = GetRunSettingsOptions(cmd.RemainingArguments);
|
||||
msbuildArgs.Add(string.Format("/p:VSTestCLIRunSettings=\"{0}\"", string.Join(";", runSettingsOptions)));
|
||||
}
|
||||
|
||||
// Add remaining arguments that the parser did not understand,
|
||||
msbuildArgs.AddRange(cmd.RemainingArguments);
|
||||
|
||||
return new MSBuildForwardingApp(msbuildArgs).Execute();
|
||||
});
|
||||
|
||||
|
@ -247,26 +251,34 @@ namespace Microsoft.DotNet.Tools.Test
|
|||
return projectFiles[0];
|
||||
}
|
||||
|
||||
private static string[] GetSemiColonEscapedArgs(List<string> args)
|
||||
private static string[] GetRunSettingsOptions(List<string> remainingArgs)
|
||||
{
|
||||
int counter = 0;
|
||||
string[] array = new string[args.Count];
|
||||
List<string> runsettingsArgs = new List<string>();
|
||||
List<string> argsToRemove = new List<string>();
|
||||
|
||||
foreach (string arg in args)
|
||||
foreach (string arg in remainingArgs)
|
||||
{
|
||||
if (arg.IndexOf(";") != -1)
|
||||
// MSBuild args starts with /, runsettings args starts with letter.
|
||||
if (char.IsLetter(arg[0]))
|
||||
{
|
||||
array[counter] = arg.Replace(";", "%3b");
|
||||
runsettingsArgs.Add(GetSemiColonEsacpedstring(arg));
|
||||
argsToRemove.Add(arg);
|
||||
}
|
||||
else
|
||||
{
|
||||
array[counter] = arg;
|
||||
}
|
||||
|
||||
counter++;
|
||||
}
|
||||
|
||||
return array;
|
||||
foreach (string arg in argsToRemove)
|
||||
{
|
||||
remainingArgs.Remove(arg);
|
||||
}
|
||||
|
||||
return runsettingsArgs.ToArray();
|
||||
}
|
||||
|
||||
private static string GetSemiColonEsacpedstring(string arg)
|
||||
{
|
||||
return string.IsNullOrEmpty(arg) ? arg : arg.Replace(";", "%3b");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,8 +24,8 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
|||
""BPackage"" : ""1.0.0""
|
||||
}
|
||||
}");
|
||||
|
||||
EmitsPackageReferences(mockProj, Tuple.Create("APackage", "1.0.0-preview", ""), Tuple.Create("BPackage", "1.0.0", ""));
|
||||
|
||||
EmitsPackageReferences(mockProj, Tuple.Create("APackage", "1.0.0-preview", ""), Tuple.Create("BPackage", "1.0.0", ""));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -158,8 +158,8 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
|||
""BPackage"" : ""1.0.0""
|
||||
}
|
||||
}");
|
||||
|
||||
EmitsToolReferences(mockProj, Tuple.Create("APackage", "1.0.0-preview"), Tuple.Create("BPackage", "1.0.0"));
|
||||
|
||||
EmitsToolReferences(mockProj, Tuple.Create("APackage", "1.0.0-preview"), Tuple.Create("BPackage", "1.0.0"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -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-20161227-02" &&
|
||||
i.GetMetadataWithName("Version").Value == "15.0.0-preview-20161024-02" &&
|
||||
i.GetMetadataWithName("Version").ExpressedAsAttribute));
|
||||
|
||||
mockProj.Items.Should().NotContain(
|
||||
|
@ -281,19 +281,19 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
|||
}");
|
||||
|
||||
mockProj.Items.Should().ContainSingle(
|
||||
i => (i.Include == "Microsoft.NET.Test.Sdk" &&
|
||||
i => (i.Include == "Microsoft.NET.Test.Sdk" &&
|
||||
i.ItemType == "PackageReference" &&
|
||||
i.GetMetadataWithName("Version").Value == "15.0.0-preview-20161227-02") &&
|
||||
i.GetMetadataWithName("Version").Value == "15.0.0-preview-20161024-02") &&
|
||||
i.GetMetadataWithName("Version").ExpressedAsAttribute);
|
||||
|
||||
mockProj.Items.Should().ContainSingle(
|
||||
i => (i.Include == "xunit" &&
|
||||
i => (i.Include == "xunit" &&
|
||||
i.ItemType == "PackageReference" &&
|
||||
i.GetMetadataWithName("Version").Value == "2.2.0-beta4-build3444" &&
|
||||
i.GetMetadataWithName("Version").ExpressedAsAttribute));
|
||||
|
||||
mockProj.Items.Should().ContainSingle(
|
||||
i => (i.Include == "xunit.runner.visualstudio" &&
|
||||
i => (i.Include == "xunit.runner.visualstudio" &&
|
||||
i.ItemType == "PackageReference" &&
|
||||
i.GetMetadataWithName("Version").Value == "2.2.0-beta4-build1194" &&
|
||||
i.GetMetadataWithName("Version").ExpressedAsAttribute));
|
||||
|
@ -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-20161227-02" &&
|
||||
i.GetMetadataWithName("Version").Value == "15.0.0-preview-20161024-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-20161227-02" &&
|
||||
i.GetMetadataWithName("Version").Value == "15.0.0-preview-20161024-02" &&
|
||||
i.GetMetadataWithName("Version").ExpressedAsAttribute));
|
||||
|
||||
mockProj.Items.Should().ContainSingle(
|
||||
|
|
|
@ -167,7 +167,7 @@ namespace Microsoft.DotNet.Cli.Test.Tests
|
|||
// Call test with logger enable
|
||||
CommandResult result = new DotnetTestCommand()
|
||||
.WithWorkingDirectory(testProjectDirectory)
|
||||
.ExecuteWithCapturedOutput(" --logger \"trx;logfilename=custom.trx\" -- RunConfiguration.ResultsDirectory=" + trxLoggerDirectory);
|
||||
.ExecuteWithCapturedOutput("--logger \"trx;logfilename=custom.trx\" -- RunConfiguration.ResultsDirectory=" + trxLoggerDirectory);
|
||||
|
||||
// Verify
|
||||
String[] trxFiles = Directory.GetFiles(trxLoggerDirectory, "*.trx");
|
||||
|
|
Loading…
Add table
Reference in a new issue