Fix dotnet-tests to run tests on net46, since we only support netstandard1.3 in ProjectModel.

This commit is contained in:
Eric Erhardt 2016-10-11 16:59:58 -05:00
parent 7618cce420
commit 00f543d089
4 changed files with 28 additions and 24 deletions

View file

@ -8,14 +8,14 @@ namespace FakeTests
{ {
public class GivenThatIWantSomeFakeTests public class GivenThatIWantSomeFakeTests
{ {
#if NET451 #if NET46
[Fact] [Fact]
public void NET451_succeeds() public void NET46_succeeds()
{ {
Assert.True(true); Assert.True(true);
} }
[Fact(Skip="Skipped for NET451")] [Fact(Skip="Skipped for NET46")]
public void SkippedTest() public void SkippedTest()
{ {
@ -45,8 +45,8 @@ namespace FakeTests
{ {
var shouldFail = string.IsNullOrEmpty(Environment.GetEnvironmentVariable("DOTNET_TEST_SHOULD_FAIL")); var shouldFail = string.IsNullOrEmpty(Environment.GetEnvironmentVariable("DOTNET_TEST_SHOULD_FAIL"));
#if NET451 #if NET46
Assert.True(shouldFail, "Failing in NET451"); Assert.True(shouldFail, "Failing in NET46");
#else #else
Assert.True(shouldFail, "Failing in NETCOREAPP1.0"); Assert.True(shouldFail, "Failing in NETCOREAPP1.0");
#endif #endif

View file

@ -20,7 +20,11 @@
"System.Runtime.Serialization.Primitives": "4.1.1" "System.Runtime.Serialization.Primitives": "4.1.1"
} }
}, },
"net46": {} "net46": {
"dependencies": {
"System.IO.FileSystem": "4.0.1"
}
}
}, },
"testRunner": "xunit" "testRunner": "xunit"
} }

View file

@ -17,7 +17,7 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
{ {
private readonly string _projectFilePath; private readonly string _projectFilePath;
private readonly string _defaultNetCoreAppOutputPath; private readonly string _defaultNetCoreAppOutputPath;
private readonly string _defaultNet451OutputPath; private readonly string _defaultNet46OutputPath;
public GivenThatWeWantToRunTestsForMultipleTFMsInTheConsole() public GivenThatWeWantToRunTestsForMultipleTFMsInTheConsole()
{ {
@ -36,7 +36,7 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
new RestoreCommand() { WorkingDirectory = testInstance.TestRoot }.Execute().Should().Pass(); new RestoreCommand() { WorkingDirectory = testInstance.TestRoot }.Execute().Should().Pass();
_defaultNetCoreAppOutputPath = Path.Combine(testInstance.TestRoot, "bin", "Debug", "netcoreapp1.0"); _defaultNetCoreAppOutputPath = Path.Combine(testInstance.TestRoot, "bin", "Debug", "netcoreapp1.0");
_defaultNet451OutputPath = Path.Combine(testInstance.TestRoot, "bin", "Debug", "net451", RuntimeEnvironmentRidExtensions.GetAllCandidateRuntimeIdentifiers().First()); _defaultNet46OutputPath = Path.Combine(testInstance.TestRoot, "bin", "Debug", "net46", RuntimeEnvironmentRidExtensions.GetAllCandidateRuntimeIdentifiers().First());
} }
[WindowsOnlyFact] [WindowsOnlyFact]
@ -46,18 +46,18 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
var result = testCommand var result = testCommand
.ExecuteWithCapturedOutput($"{_projectFilePath}"); .ExecuteWithCapturedOutput($"{_projectFilePath}");
result.Should().Pass(); result.Should().Pass();
result.StdOut.Should().Contain("Skipped for NET451"); result.StdOut.Should().Contain("Skipped for NET46");
result.StdOut.Should().Contain("Skipped for NETCOREAPP1.0"); result.StdOut.Should().Contain("Skipped for NETCOREAPP1.0");
} }
[WindowsOnlyFact] [WindowsOnlyFact]
public void It_builds_and_runs_tests_for_net451() public void It_builds_and_runs_tests_for_net46()
{ {
var testCommand = new DotnetTestCommand(); var testCommand = new DotnetTestCommand();
var result = testCommand var result = testCommand
.ExecuteWithCapturedOutput($"{_projectFilePath} -f net451"); .ExecuteWithCapturedOutput($"{_projectFilePath} -f net46");
result.Should().Pass(); result.Should().Pass();
result.StdOut.Should().Contain($"Skipped for NET451"); result.StdOut.Should().Contain($"Skipped for NET46");
result.StdOut.Should().NotContain($"Skipped for NETCOREAPP1.0"); result.StdOut.Should().NotContain($"Skipped for NETCOREAPP1.0");
} }
@ -69,7 +69,7 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
.ExecuteWithCapturedOutput($"{_projectFilePath} -f netcoreapp1.0"); .ExecuteWithCapturedOutput($"{_projectFilePath} -f netcoreapp1.0");
result.Should().Pass(); result.Should().Pass();
result.StdOut.Should().Contain($"Skipped for NETCOREAPP1.0"); result.StdOut.Should().Contain($"Skipped for NETCOREAPP1.0");
result.StdOut.Should().NotContain($"Skipped for NET451"); result.StdOut.Should().NotContain($"Skipped for NET46");
} }
[Fact] [Fact]
@ -103,15 +103,15 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
} }
[WindowsOnlyFact] [WindowsOnlyFact]
public void It_skips_build_when_the_no_build_flag_is_passed_for_net451() public void It_skips_build_when_the_no_build_flag_is_passed_for_net46()
{ {
var rid = RuntimeEnvironmentRidExtensions.GetAllCandidateRuntimeIdentifiers().First(); var rid = RuntimeEnvironmentRidExtensions.GetAllCandidateRuntimeIdentifiers().First();
var buildCommand = new BuildCommand(_projectFilePath); var buildCommand = new BuildCommand(_projectFilePath);
var result = buildCommand.Execute($"-f net451 -r {rid} -o {_defaultNet451OutputPath}"); var result = buildCommand.Execute($"-f net46 -r {rid} -o {_defaultNet46OutputPath}");
result.Should().Pass(); result.Should().Pass();
var testCommand = new DotnetTestCommand(); var testCommand = new DotnetTestCommand();
result = testCommand.Execute($"{_projectFilePath} -f net451 -r {rid} -o {_defaultNet451OutputPath} --no-build"); result = testCommand.Execute($"{_projectFilePath} -f net46 -r {rid} -o {_defaultNet46OutputPath} --no-build");
result.Should().Pass(); result.Should().Pass();
} }
@ -142,7 +142,7 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
.ExecuteWithCapturedOutput($"{_projectFilePath}"); .ExecuteWithCapturedOutput($"{_projectFilePath}");
result.Should().Fail(); result.Should().Fail();
result.StdOut.Should().Contain("Failing in NET451"); result.StdOut.Should().Contain("Failing in NET46");
result.StdOut.Should().Contain("Failing in NETCOREAPP1.0"); result.StdOut.Should().Contain("Failing in NETCOREAPP1.0");
} }

View file

@ -18,7 +18,7 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
{ {
private string _projectFilePath; private string _projectFilePath;
private string _netCoreAppOutputPath; private string _netCoreAppOutputPath;
private string _net451OutputPath; private string _net46OutputPath;
private void Setup([CallerMemberName] string callingMethod = "") private void Setup([CallerMemberName] string callingMethod = "")
{ {
@ -44,8 +44,8 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
if (RuntimeEnvironment.OperatingSystemPlatform == Platform.Windows) if (RuntimeEnvironment.OperatingSystemPlatform == Platform.Windows)
{ {
var rid = RuntimeEnvironmentRidExtensions.GetAllCandidateRuntimeIdentifiers().First(); var rid = RuntimeEnvironmentRidExtensions.GetAllCandidateRuntimeIdentifiers().First();
_net451OutputPath = Path.Combine(testInstance.TestRoot, "bin", "Debug", "net451", rid); _net46OutputPath = Path.Combine(testInstance.TestRoot, "bin", "Debug", "net46", rid);
result = buildCommand.Execute($"-f net451 -r {rid} -o {_net451OutputPath}"); result = buildCommand.Execute($"-f net46 -r {rid} -o {_net46OutputPath}");
result.Should().Pass(); result.Should().Pass();
} }
} }
@ -70,7 +70,7 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
} }
[WindowsOnlyFact(Skip="https://github.com/xunit/xunit/issues/934")] [WindowsOnlyFact(Skip="https://github.com/xunit/xunit/issues/934")]
public void It_discovers_tests_for_the_ProjectWithTestsWithNet451() public void It_discovers_tests_for_the_ProjectWithTestsWithNet46()
{ {
Setup(); Setup();
@ -80,7 +80,7 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
var rid = RuntimeEnvironmentRidExtensions.GetAllCandidateRuntimeIdentifiers().First(); var rid = RuntimeEnvironmentRidExtensions.GetAllCandidateRuntimeIdentifiers().First();
var testCommand = new DotnetTestCommand(); var testCommand = new DotnetTestCommand();
var result = testCommand.Execute($"{_projectFilePath} -f net451 -r {rid} -o {_net451OutputPath} --port {adapter.Port} --no-build"); var result = testCommand.Execute($"{_projectFilePath} -f net46 -r {rid} -o {_net46OutputPath} --port {adapter.Port} --no-build");
result.Should().Pass(); result.Should().Pass();
adapter.Messages["TestSession.Connected"].Count.Should().Be(1); adapter.Messages["TestSession.Connected"].Count.Should().Be(1);
@ -111,7 +111,7 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
} }
[WindowsOnlyFact(Skip="https://github.com/xunit/xunit/issues/934")] [WindowsOnlyFact(Skip="https://github.com/xunit/xunit/issues/934")]
public void It_runs_tests_for_net451() public void It_runs_tests_for_net46()
{ {
Setup(); Setup();
@ -121,7 +121,7 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
var testCommand = new DotnetTestCommand(); var testCommand = new DotnetTestCommand();
var rid = RuntimeEnvironmentRidExtensions.GetAllCandidateRuntimeIdentifiers().First(); var rid = RuntimeEnvironmentRidExtensions.GetAllCandidateRuntimeIdentifiers().First();
var result = testCommand.Execute($"{_projectFilePath} -f net451 -r {rid} -o {_net451OutputPath} --port {adapter.Port} --no-build"); var result = testCommand.Execute($"{_projectFilePath} -f net46 -r {rid} -o {_net46OutputPath} --port {adapter.Port} --no-build");
result.Should().Pass(); result.Should().Pass();
adapter.Messages["TestSession.Connected"].Count.Should().Be(1); adapter.Messages["TestSession.Connected"].Count.Should().Be(1);