Insert Microsoft.TestPlatform.cli for update3 preview1 (#6420)
* Fix test issue failing with PathTooLongIssue (cherry picked from commit 340254f7742201c74ed1a5c349bdca89113bd5dc) * fix for issues: 1) https://github.com/Microsoft/vstest/issues/755 2) https://github.com/Microsoft/vstest/issues/687 3) https://github.com/Microsoft/vstest/issues/737 (cherry picked from commit 0e93b2a5d4734637538781fa5401ed81a31eea0f) * use new version * Update version * Fix pathtoolong issue * Fix test
This commit is contained in:
parent
a551ae77b0
commit
b90b191ef0
16 changed files with 93 additions and 51 deletions
|
@ -2,7 +2,6 @@
|
|||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), testAsset.props))\testAsset.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFrameworks>net46;netcoreapp2.0</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
|
@ -7,7 +7,7 @@
|
|||
<CLI_NETSDK_Version>2.0.0-alpha-20170502-2</CLI_NETSDK_Version>
|
||||
<CLI_NuGet_Version>4.3.0-beta1-2418</CLI_NuGet_Version>
|
||||
<CLI_WEBSDK_Version>1.0.0-rel-20170501-473</CLI_WEBSDK_Version>
|
||||
<CLI_TestPlatform_Version>15.1.0-preview-20170414-04</CLI_TestPlatform_Version>
|
||||
<CLI_TestPlatform_Version>15.3.0-preview-20170502-03</CLI_TestPlatform_Version>
|
||||
<SharedFrameworkVersion>$(CLI_SharedFrameworkVersion)</SharedFrameworkVersion>
|
||||
<SharedHostVersion>$(CLI_SharedFrameworkVersion)</SharedHostVersion>
|
||||
<HostFxrVersion>$(CLI_SharedFrameworkVersion)</HostFxrVersion>
|
||||
|
|
|
@ -37,7 +37,8 @@ namespace Microsoft.DotNet.Tools.Test
|
|||
public const string CmdLoggerOption = "LoggerUri/FriendlyName";
|
||||
|
||||
public const string CmdLoggerDescription = @"Specify a logger for test results.
|
||||
Example: --logger ""trx[;LogFileName=<Defaults to unique file name>]""";
|
||||
Example: --logger ""trx[;LogFileName=<Defaults to unique file name>]""
|
||||
More info on logger arguments support:https://aka.ms/vstest-report";
|
||||
|
||||
public const string CmdConfiguration = "CONFIGURATION";
|
||||
|
||||
|
@ -58,12 +59,22 @@ namespace Microsoft.DotNet.Tools.Test
|
|||
|
||||
public const string CmdNoBuildDescription = @"Do not build project before testing.";
|
||||
|
||||
public const string RunSettingsArgsHelpText = @"Any extra command-line runsettings arguments that should be passed to vstest. See 'dotnet vstest --help' for available options.
|
||||
Example: -- RunConfiguration.ResultsDirectory=""C:\users\user\desktop\Results Directory"" MSTest.DeploymentEnabled=false";
|
||||
|
||||
public const string CmdResultsDirectoryDescription = @"The directory where the test results are going to be placed. The specified directory will be created if it does not exist.
|
||||
Example: --results-directory <PATH_TO_RESULTS_DIRECTORY>";
|
||||
|
||||
public const string CmdPathToResultsDirectory = "PATH_TO_RESULTS_DIRECTORY";
|
||||
|
||||
public const string RunSettingsArgumentsDescription = @"
|
||||
|
||||
RunSettings arguments:
|
||||
Arguments to pass runsettings configurations through commandline. Arguments may be specified as name-value pair of the form [name]=[value] after ""-- "". Note the space after --.
|
||||
Use a space to separate multiple[name] =[value].
|
||||
More info on RunSettings arguments support: https://aka.ms/vstest-runsettings-arguments
|
||||
Example: dotnet test -- MSTest.DeploymentEnabled=false MSTest.MapInconclusiveToFailed=True";
|
||||
|
||||
public const string cmdCollectFriendlyName = "DATA_COLLECTOR_FRIENDLY_NAME";
|
||||
|
||||
public const string cmdCollectDescription = @"Enables data collector for the test run.
|
||||
More info here : https://aka.ms/vstest-collect";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace Microsoft.DotNet.Tools.Test
|
|||
{
|
||||
}
|
||||
|
||||
public static TestCommand FromArgs(string[] args, string msbuildPath=null)
|
||||
public static TestCommand FromArgs(string[] args, string msbuildPath = null)
|
||||
{
|
||||
var msbuildArgs = new List<string>()
|
||||
{
|
||||
|
@ -34,6 +34,7 @@ namespace Microsoft.DotNet.Tools.Test
|
|||
|
||||
var result = parser.ParseFrom("dotnet test", args);
|
||||
|
||||
UpdateRunSettingsArgumentsText();
|
||||
result.ShowHelpOrErrorIfAppropriate();
|
||||
|
||||
var parsedTest = result["dotnet"]["test"];
|
||||
|
@ -42,7 +43,7 @@ namespace Microsoft.DotNet.Tools.Test
|
|||
|
||||
msbuildArgs.AddRange(parsedTest.Arguments);
|
||||
|
||||
var runSettingsOptions =
|
||||
var runSettingsOptions =
|
||||
result.UnparsedTokens
|
||||
.Select(GetSemiColonEscapedString);
|
||||
|
||||
|
@ -53,6 +54,17 @@ namespace Microsoft.DotNet.Tools.Test
|
|||
msbuildArgs.Add($"/p:VSTestCLIRunSettings=\"{runSettingsArg}\"");
|
||||
}
|
||||
|
||||
var verbosityArg = msbuildArgs.LastOrDefault(arg => arg.StartsWith("/verbosity"));
|
||||
|
||||
if (!string.IsNullOrEmpty(verbosityArg))
|
||||
{
|
||||
var verbosity = verbosityArg.Split(':');
|
||||
if (verbosity.Length == 2)
|
||||
{
|
||||
msbuildArgs.Add($"/p:VSTestVerbosity={verbosity[1]}");
|
||||
}
|
||||
}
|
||||
|
||||
return new TestCommand(msbuildArgs, msbuildPath);
|
||||
}
|
||||
|
||||
|
@ -61,7 +73,7 @@ namespace Microsoft.DotNet.Tools.Test
|
|||
DebugHelper.HandleDebugSwitch(ref args);
|
||||
|
||||
TestCommand cmd;
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
cmd = FromArgs(args);
|
||||
|
@ -96,5 +108,11 @@ namespace Microsoft.DotNet.Tools.Test
|
|||
|
||||
return array;
|
||||
}
|
||||
|
||||
private static void UpdateRunSettingsArgumentsText()
|
||||
{
|
||||
DefaultHelpViewText.Synopsis.AdditionalArguments = " [[--] <RunSettings arguments>...]]";
|
||||
DefaultHelpViewText.AdditionalArgumentsSection = LocalizableStrings.RunSettingsArgumentsDescription;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ namespace Microsoft.DotNet.Cli
|
|||
Accept.ZeroOrMoreArguments()
|
||||
.With(name: LocalizableStrings.CmdArgProject,
|
||||
description: LocalizableStrings.CmdArgDescription),
|
||||
false,
|
||||
CommonOptions.HelpOption(),
|
||||
Create.Option(
|
||||
"-s|--settings",
|
||||
|
@ -74,6 +75,12 @@ namespace Microsoft.DotNet.Cli
|
|||
Accept.ExactlyOneArgument()
|
||||
.With(name: LocalizableStrings.CmdPathToResultsDirectory)
|
||||
.ForwardAsSingle(o => $"/p:VSTestResultsDirectory={o.Arguments.Single()}")),
|
||||
Create.Option(
|
||||
"--collect",
|
||||
LocalizableStrings.cmdCollectDescription,
|
||||
Accept.OneOrMoreArguments()
|
||||
.With(name: LocalizableStrings.cmdCollectFriendlyName)
|
||||
.ForwardAsSingle(o => $"/p:VSTestCollect=\"{string.Join(";", o.Arguments)}\"")),
|
||||
CommonOptions.VerbosityOption());
|
||||
|
||||
private static string GetSemiColonEsacpedstring(string arg)
|
||||
|
|
|
@ -73,7 +73,7 @@ namespace Microsoft.DotNet.Restore.Tests
|
|||
[Fact]
|
||||
public void ItRestoresTestAppToSpecificDirectory()
|
||||
{
|
||||
var rootPath = TestAssets.Get("VSTestDotNetCore").CreateInstance().WithSourceFiles().Root.FullName;
|
||||
var rootPath = TestAssets.Get("VSTestCore").CreateInstance().WithSourceFiles().Root.FullName;
|
||||
|
||||
string dir = "pkgs";
|
||||
string fullPath = Path.GetFullPath(Path.Combine(rootPath, dir));
|
||||
|
|
|
@ -12,11 +12,11 @@ namespace Microsoft.DotNet.Cli.Test.Tests
|
|||
{
|
||||
public class GivenDotnetTestBuildsAndRunsTestFromCsprojForMultipleTFM : TestBase
|
||||
{
|
||||
[WindowsOnlyFact(Skip="https://github.com/dotnet/cli/issues/4616")]
|
||||
[WindowsOnlyFact]
|
||||
public void MStestMultiTFM()
|
||||
{
|
||||
var testProjectDirectory = TestAssets.Get("VSTestDesktopAndNetCore")
|
||||
.CreateInstance()
|
||||
var testProjectDirectory = TestAssets.Get("VSTestMulti")
|
||||
.CreateInstance("1")
|
||||
.WithSourceFiles()
|
||||
.WithNuGetConfig(new RepoDirectoriesProvider().TestPackages)
|
||||
.Root;
|
||||
|
@ -45,15 +45,15 @@ namespace Microsoft.DotNet.Cli.Test.Tests
|
|||
[WindowsOnlyFact]
|
||||
public void XunitMultiTFM()
|
||||
{
|
||||
// Copy VSTestXunitDesktopAndNetCore project in output directory of project dotnet-test.Tests
|
||||
string testAppName = "VSTestXunitDesktopAndNetCore";
|
||||
// Copy XunitMulti project in output directory of project dotnet-test.Tests
|
||||
string testAppName = "XunitMulti";
|
||||
var testInstance = TestAssets.Get(testAppName)
|
||||
.CreateInstance()
|
||||
.CreateInstance("2")
|
||||
.WithSourceFiles();
|
||||
|
||||
var testProjectDirectory = testInstance.Root.FullName;
|
||||
|
||||
// Restore project VSTestXunitDesktopAndNetCore
|
||||
// Restore project XunitMulti
|
||||
new RestoreCommand()
|
||||
.WithWorkingDirectory(testProjectDirectory)
|
||||
.Execute()
|
||||
|
|
|
@ -17,20 +17,7 @@ namespace Microsoft.DotNet.Cli.Test.Tests
|
|||
[Fact]
|
||||
public void MSTestSingleTFM()
|
||||
{
|
||||
// Copy VSTestDotNetCore project in output directory of project dotnet-vstest.Tests
|
||||
string testAppName = "VSTestDotNetCore";
|
||||
var testInstance = TestAssets.Get(testAppName)
|
||||
.CreateInstance()
|
||||
.WithSourceFiles();
|
||||
|
||||
var testProjectDirectory = testInstance.Root.FullName;
|
||||
|
||||
// Restore project VSTestDotNetCore
|
||||
new RestoreCommand()
|
||||
.WithWorkingDirectory(testProjectDirectory)
|
||||
.Execute()
|
||||
.Should()
|
||||
.Pass();
|
||||
var testProjectDirectory = this.CopyAndRestoreVSTestDotNetCoreTestApp("3");
|
||||
|
||||
// Call test
|
||||
CommandResult result = new DotnetTestCommand()
|
||||
|
@ -47,15 +34,15 @@ namespace Microsoft.DotNet.Cli.Test.Tests
|
|||
[Fact]
|
||||
public void XunitSingleTFM()
|
||||
{
|
||||
// Copy VSTestXunitDotNetCore project in output directory of project dotnet-vstest.Tests
|
||||
string testAppName = "VSTestXunitDotNetCore";
|
||||
// Copy XunitCore project in output directory of project dotnet-vstest.Tests
|
||||
string testAppName = "XunitCore";
|
||||
var testInstance = TestAssets.Get(testAppName)
|
||||
.CreateInstance()
|
||||
.CreateInstance("4")
|
||||
.WithSourceFiles();
|
||||
|
||||
var testProjectDirectory = testInstance.Root.FullName;
|
||||
|
||||
// Restore project VSTestXunitDotNetCore
|
||||
// Restore project XunitCore
|
||||
new RestoreCommand()
|
||||
.WithWorkingDirectory(testProjectDirectory)
|
||||
.Execute()
|
||||
|
@ -77,11 +64,11 @@ namespace Microsoft.DotNet.Cli.Test.Tests
|
|||
[Fact]
|
||||
public void TestWillNotBuildTheProjectIfNoBuildArgsIsGiven()
|
||||
{
|
||||
// Copy and restore VSTestDotNetCore project in output directory of project dotnet-vstest.Tests
|
||||
var testProjectDirectory = this.CopyAndRestoreVSTestDotNetCoreTestApp();
|
||||
// Copy and restore VSTestCore project in output directory of project dotnet-vstest.Tests
|
||||
var testProjectDirectory = this.CopyAndRestoreVSTestDotNetCoreTestApp("5");
|
||||
string configuration = Environment.GetEnvironmentVariable("CONFIGURATION") ?? "Debug";
|
||||
string expectedError = Path.Combine(testProjectDirectory, "bin",
|
||||
configuration, "netcoreapp2.0", "VSTestDotNetCore.dll");
|
||||
configuration, "netcoreapp2.0", "VSTestCore.dll");
|
||||
expectedError = "The test source file " + "\"" + expectedError + "\"" + " provided was not found.";
|
||||
|
||||
// Call test
|
||||
|
@ -96,10 +83,10 @@ namespace Microsoft.DotNet.Cli.Test.Tests
|
|||
[Fact]
|
||||
public void TestWillCreateTrxLoggerInTheSpecifiedResultsDirectoryBySwitch()
|
||||
{
|
||||
// Copy and restore VSTestDotNetCore project in output directory of project dotnet-vstest.Tests
|
||||
var testProjectDirectory = this.CopyAndRestoreVSTestDotNetCoreTestApp();
|
||||
// Copy and restore VSTestCore project in output directory of project dotnet-vstest.Tests
|
||||
var testProjectDirectory = this.CopyAndRestoreVSTestDotNetCoreTestApp("6");
|
||||
|
||||
string trxLoggerDirectory = Path.Combine(testProjectDirectory, "TestResults", "netcoreappx.y");
|
||||
string trxLoggerDirectory = Path.Combine(testProjectDirectory, "TR", "x.y");
|
||||
|
||||
// Delete trxLoggerDirectory if it exist
|
||||
if (Directory.Exists(trxLoggerDirectory))
|
||||
|
@ -127,10 +114,10 @@ namespace Microsoft.DotNet.Cli.Test.Tests
|
|||
[Fact]
|
||||
public void ItCreatesTrxReportInTheSpecifiedResultsDirectoryByArgs()
|
||||
{
|
||||
// Copy and restore VSTestDotNetCore project in output directory of project dotnet-vstest.Tests
|
||||
var testProjectDirectory = this.CopyAndRestoreVSTestDotNetCoreTestApp();
|
||||
// Copy and restore VSTestCore project in output directory of project dotnet-vstest.Tests
|
||||
var testProjectDirectory = this.CopyAndRestoreVSTestDotNetCoreTestApp("7");
|
||||
|
||||
string trxLoggerDirectory = Path.Combine(testProjectDirectory, "ResultsDirectory");
|
||||
string trxLoggerDirectory = Path.Combine(testProjectDirectory, "RD");
|
||||
|
||||
// Delete trxLoggerDirectory if it exist
|
||||
if (Directory.Exists(trxLoggerDirectory))
|
||||
|
@ -155,12 +142,14 @@ namespace Microsoft.DotNet.Cli.Test.Tests
|
|||
}
|
||||
}
|
||||
|
||||
[Fact(Skip = "https://github.com/dotnet/cli/issues/5035")]
|
||||
[Fact]
|
||||
public void ItBuildsAndTestsAppWhenRestoringToSpecificDirectory()
|
||||
{
|
||||
var rootPath = TestAssets.Get("VSTestDotNetCore").CreateInstance().WithSourceFiles().Root.FullName;
|
||||
// Creating folder with name short name "RestoreTest" to avoid PathTooLongException
|
||||
var rootPath = TestAssets.Get("VSTestCore").CreateInstance("8").WithSourceFiles().Root.FullName;
|
||||
|
||||
string dir = "pkgs";
|
||||
// Moving pkgs folder on top to avoid PathTooLongException
|
||||
string dir = @"..\..\..\..\pkgs";
|
||||
string fullPath = Path.GetFullPath(Path.Combine(rootPath, dir));
|
||||
|
||||
string args = $"--packages \"{dir}\"";
|
||||
|
@ -186,17 +175,35 @@ namespace Microsoft.DotNet.Cli.Test.Tests
|
|||
result.StdOut.Should().Contain("Failed TestNamespace.VSTestTests.VSTestFailTest");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ItUsesVerbosityPassedToDefineVerbosityOfConsoleLoggerOfTheTests()
|
||||
{
|
||||
// Copy and restore VSTestCore project in output directory of project dotnet-vstest.Tests
|
||||
var testProjectDirectory = this.CopyAndRestoreVSTestDotNetCoreTestApp("9");
|
||||
|
||||
// Call test
|
||||
CommandResult result = new DotnetTestCommand()
|
||||
.WithWorkingDirectory(testProjectDirectory)
|
||||
.ExecuteWithCapturedOutput("-v q");
|
||||
|
||||
// Verify
|
||||
result.StdOut.Should().Contain("Total tests: 2. Passed: 1. Failed: 1. Skipped: 0.");
|
||||
result.StdOut.Should().NotContain("Passed TestNamespace.VSTestTests.VSTestPassTest");
|
||||
result.StdOut.Should().NotContain("Failed TestNamespace.VSTestTests.VSTestFailTest");
|
||||
result.ExitCode.Should().Be(1);
|
||||
}
|
||||
|
||||
private string CopyAndRestoreVSTestDotNetCoreTestApp([CallerMemberName] string callingMethod = "")
|
||||
{
|
||||
// Copy VSTestDotNetCore project in output directory of project dotnet-vstest.Tests
|
||||
string testAppName = "VSTestDotNetCore";
|
||||
// Copy VSTestCore project in output directory of project dotnet-vstest.Tests
|
||||
string testAppName = "VSTestCore";
|
||||
var testInstance = TestAssets.Get(testAppName)
|
||||
.CreateInstance(callingMethod)
|
||||
.WithSourceFiles();
|
||||
|
||||
var testProjectDirectory = testInstance.Root.FullName;
|
||||
|
||||
// Restore project VSTestDotNetCore
|
||||
// Restore project VSTestCore
|
||||
new RestoreCommand()
|
||||
.WithWorkingDirectory(testProjectDirectory)
|
||||
.Execute()
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace Microsoft.DotNet.Cli.VSTest.Tests
|
|||
[Fact]
|
||||
public void TestsFromAGivenContainerShouldRunWithExpectedOutput()
|
||||
{
|
||||
var testAppName = "VSTestDotNetCore";
|
||||
var testAppName = "VSTestCore";
|
||||
var testRoot = TestAssets.Get(testAppName)
|
||||
.CreateInstance()
|
||||
.WithSourceFiles()
|
||||
|
|
Loading…
Reference in a new issue