This commit is contained in:
jonsequitur 2017-03-21 11:57:08 -07:00
commit 4effd9354c
110 changed files with 283 additions and 346 deletions

View file

@ -89,7 +89,7 @@ namespace Microsoft.DotNet.Tests.EndToEnd
.And.HaveStdOutContaining("Hello I prefer the cli runtime World!");;
}
[Fact]
[RequiresSpecificFrameworkFact("netcoreapp1.1")] // https://github.com/dotnet/cli/issues/6087
public void ItCanRunAToolThatInvokesADependencyToolInACSProj()
{
var repoDirectoriesProvider = new RepoDirectoriesProvider();

View file

@ -198,7 +198,7 @@ namespace Microsoft.DotNet.Cli.Utils.Tests
var command = factory.Create("dotnet-tool-with-output-name", null);
command.CommandArgs.Should().Contain(
Path.Combine("toolwithoutputname", "1.0.0", "lib", "netcoreapp1.0", "dotnet-tool-with-output-name.dll"));
Path.Combine("toolwithoutputname", "1.0.0", "lib", "netcoreapp2.0", "dotnet-tool-with-output-name.dll"));
}
}
}

View file

@ -18,7 +18,7 @@ namespace Microsoft.DotNet.Tests
public class GivenAProjectToolsCommandResolver : TestBase
{
private static readonly NuGetFramework s_toolPackageFramework =
FrameworkConstants.CommonFrameworks.NetCoreApp10;
FrameworkConstants.CommonFrameworks.NetCoreApp20;
private const string TestProjectName = "AppWithToolDependency";

View file

@ -13,8 +13,6 @@ namespace StreamForwarderTests
{
public class StreamForwarderTests : TestBase
{
private static readonly string s_rid = DotnetLegacyRuntimeIdentifiers.InferLegacyRestoreRuntimeIdentifier();
public static IEnumerable<object[]> ForwardingTheoryVariations
{
get

View file

@ -30,7 +30,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
var appDirectory = Path.Combine(solutionDirectory, "TestApp");
var projectContext = ProjectContext.Create(appDirectory, FrameworkConstants.CommonFrameworks.NetCoreApp10);
var projectContext = ProjectContext.Create(appDirectory, FrameworkConstants.CommonFrameworks.NetCoreApp11);
var mockProj = ProjectRootElement.Create();
var testSettings = MigrationSettings.CreateMigrationSettingsTestHook(appDirectory, appDirectory, mockProj, null);
var testInputs = new MigrationRuleInputs(new[] {projectContext}, mockProj, mockProj.AddItemGroup(),
@ -55,7 +55,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
var appDirectory = Path.Combine(solutionDirectory, "TestApp");
var projectContext = ProjectContext.Create(appDirectory, FrameworkConstants.CommonFrameworks.NetCoreApp10);
var projectContext = ProjectContext.Create(appDirectory, FrameworkConstants.CommonFrameworks.NetCoreApp11);
var mockProj = ProjectRootElement.Create();
var testSettings = MigrationSettings.CreateMigrationSettingsTestHook(appDirectory, appDirectory, mockProj, null);
var testInputs = new MigrationRuleInputs(new[] {projectContext}, mockProj, mockProj.AddItemGroup(),
@ -77,7 +77,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
var appDirectory = Path.Combine(solutionDirectory, "TestApp");
var projectContext = ProjectContext.Create(appDirectory, FrameworkConstants.CommonFrameworks.NetCoreApp10);
var projectContext = ProjectContext.Create(appDirectory, FrameworkConstants.CommonFrameworks.NetCoreApp11);
var mockProj = ProjectRootElement.Create();
var testSettings = MigrationSettings.CreateMigrationSettingsTestHook(appDirectory, appDirectory, mockProj, null);
var testInputs = new MigrationRuleInputs(new[] {projectContext}, mockProj, mockProj.AddItemGroup(),
@ -89,7 +89,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
var projectReference = projectReferences.First();
projectReference.Include.Should().Be(Path.Combine("..", "TestLibrary", "TestLibrary.csproj"));
projectReference.Parent.Condition.Should().Be(" '$(TargetFramework)' == 'netcoreapp1.0' ");
projectReference.Parent.Condition.Should().Be(" '$(TargetFramework)' == 'netcoreapp1.1' ");
}
[Fact]
@ -105,7 +105,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
var libraryDirectory = Path.Combine(solutionDirectory, "TestLibrary");
Directory.Delete(libraryDirectory, true);
var projectContext = ProjectContext.Create(appDirectory, FrameworkConstants.CommonFrameworks.NetCoreApp10);
var projectContext = ProjectContext.Create(appDirectory, FrameworkConstants.CommonFrameworks.NetCoreApp11);
var mockProj = ProjectRootElement.Create();
var testSettings = MigrationSettings.CreateMigrationSettingsTestHook(appDirectory, appDirectory, mockProj);
var testInputs = new MigrationRuleInputs(new[] {projectContext}, mockProj, mockProj.AddItemGroup(), mockProj.AddPropertyGroup());
@ -322,7 +322,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
var appDirectory = Path.Combine(solutionDirectory, "ProjectB");
var projectContext = ProjectContext.Create(appDirectory, FrameworkConstants.CommonFrameworks.NetCoreApp10);
var projectContext = ProjectContext.Create(appDirectory, FrameworkConstants.CommonFrameworks.NetCoreApp11);
var mockProj = ProjectRootElement.Create();
var testSettings = MigrationSettings.CreateMigrationSettingsTestHook(appDirectory, appDirectory, mockProj, null);
var testInputs = new MigrationRuleInputs(new[] {projectContext}, mockProj, mockProj.AddItemGroup(),
@ -337,7 +337,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
private ProjectRootElement MigrateProject(string solution, string project)
{
return MigrateProject(solution, project, FrameworkConstants.CommonFrameworks.NetCoreApp10);
return MigrateProject(solution, project, FrameworkConstants.CommonFrameworks.NetCoreApp11);
}
private ProjectRootElement MigrateProject(

View file

@ -1,22 +1,30 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using Microsoft.DotNet.PlatformAbstractions;
namespace Microsoft.DotNet.Tools.Test.Utilities
{
public static class EnvironmentInfo
{
public static bool HasSharedFramework(string framework)
{
string rid = RepoDirectoriesProvider.BuildRid;
if (framework == "netcoreapp1.0")
{
string rid = RuntimeEnvironment.GetRuntimeIdentifier();
switch (rid)
{
case "fedora.24-x64":
case "opensuse.42.1-x64":
case "ubuntu.16.10-x64":
case "linux-x64":
return false;
}
}
else if (framework == "netcoreapp1.1")
{
switch (rid)
{
case "linux-x64":
return false;
}
}

View file

@ -4,6 +4,7 @@
using System;
using System.IO;
using System.Linq;
using System.Xml.Linq;
using Microsoft.DotNet.PlatformAbstractions;
namespace Microsoft.DotNet.Tools.Test.Utilities
@ -11,6 +12,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
public class RepoDirectoriesProvider
{
private static string s_repoRoot;
private static string s_buildRid;
private string _artifacts;
private string _builtDotnet;
@ -49,6 +51,32 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
}
}
public static string BuildRid
{
get
{
if (string.IsNullOrEmpty(s_buildRid))
{
var buildInfoPath = Path.Combine(RepoRoot, "artifacts", "obj", "BuildInfo.props");
var root = XDocument.Load(buildInfoPath).Root;
var ns = root.Name.Namespace;
s_buildRid = root
.Elements(ns + "PropertyGroup")
.Elements(ns + "Rid")
.FirstOrDefault()
?.Value;
if (string.IsNullOrEmpty(s_buildRid))
{
throw new InvalidOperationException($"Could not find a property named 'Rid' in {buildInfoPath}");
}
}
return s_buildRid;
}
}
public string Artifacts => _artifacts;
public string BuiltDotnet => _builtDotnet;
public string NugetPackages => _nugetPackages;
@ -64,9 +92,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
string corehostDummyPackages = null,
string pjDotnet = null)
{
var currentRid = RuntimeEnvironment.GetRuntimeIdentifier();
_artifacts = artifacts ?? Path.Combine(RepoRoot, "artifacts", currentRid);
_artifacts = artifacts ?? Path.Combine(RepoRoot, "artifacts", BuildRid);
_builtDotnet = builtDotnet ?? Path.Combine(_artifacts, "intermediate", "sharedFrameworkPublish");
_nugetPackages = nugetPackages ?? Path.Combine(RepoRoot, ".nuget", "packages");
_pjDotnet = pjDotnet ?? GetPjDotnetPath();

View file

@ -220,7 +220,7 @@ namespace Microsoft.DotNet.Migration.Tests
.Execute("publish -c Debug")
.Should().Pass();
var outputDir = projectDirectory.GetDirectory("bin", "Debug", "netcoreapp1.0");
var outputDir = projectDirectory.GetDirectory("bin", "Debug", "netcoreapp1.1");
outputDir.Should().Exist()
.And.HaveFiles(new[]
{
@ -233,7 +233,7 @@ namespace Microsoft.DotNet.Migration.Tests
Directory.Exists(Path.Combine(outputDir.FullName, "ExcludeThis1.txt")).Should().BeFalse();
Directory.Exists(Path.Combine(outputDir.FullName, "ExcludeThis2.txt")).Should().BeFalse();
var publishDir = projectDirectory.GetDirectory("bin", "Debug", "netcoreapp1.0", "publish");
var publishDir = projectDirectory.GetDirectory("bin", "Debug", "netcoreapp1.1", "publish");
publishDir.Should().Exist()
.And.HaveFiles(new[]
{
@ -431,9 +431,9 @@ namespace Microsoft.DotNet.Migration.Tests
.Execute("build -c Debug")
.Should().Pass();
if (!EnvironmentInfo.HasSharedFramework("netcoreapp1.0"))
if (!EnvironmentInfo.HasSharedFramework("netcoreapp1.1"))
{
// running the app requires netcoreapp1.0
// running the app requires netcoreapp1.1
return;
}
@ -489,9 +489,9 @@ namespace Microsoft.DotNet.Migration.Tests
.Execute("build -c Debug")
.Should().Pass();
if (!EnvironmentInfo.HasSharedFramework("netcoreapp1.0"))
if (!EnvironmentInfo.HasSharedFramework("netcoreapp1.1"))
{
// running the app requires netcoreapp1.0
// running the app requires netcoreapp1.1
return;
}
@ -546,9 +546,9 @@ namespace Microsoft.DotNet.Migration.Tests
.Execute("build -c Debug")
.Should().Pass();
if (!EnvironmentInfo.HasSharedFramework("netcoreapp1.0"))
if (!EnvironmentInfo.HasSharedFramework("netcoreapp1.1"))
{
// running the app requires netcoreapp1.0
// running the app requires netcoreapp1.1
return;
}

View file

@ -23,16 +23,24 @@ namespace Microsoft.DotNet.New.Tests
[InlineData("C#", "web", true)]
[InlineData("C#", "mvc", true)]
[InlineData("C#", "webapi", true)]
[InlineData("F#", "console", false)]
[InlineData("F#", "classlib", false)]
[InlineData("F#", "mstest", false)]
[InlineData("F#", "xunit", false)]
[InlineData("F#", "mvc", true)]
// Uncomment the test below once https://github.com/dotnet/netcorecli-fsc/issues/92 is fixed.
//[InlineData("F#", "console", false)]
//[InlineData("F#", "classlib", false)]
//[InlineData("F#", "mstest", false)]
//[InlineData("F#", "xunit", false)]
//[InlineData("F#", "mvc", true)]
public void TemplateRestoresAndBuildsWithoutWarnings(
string language,
string projectType,
bool useNuGetConfigForAspNet)
{
if (language == "F#" && !EnvironmentInfo.HasSharedFramework("netcoreapp1.0"))
{
// F# requires netcoreapp1.0 to be present in order to build
// https://github.com/dotnet/netcorecli-fsc/issues/76
return;
}
string rootPath = TestAssets.CreateTestDirectory(identifier: $"{language}_{projectType}").FullName;
new TestCommand("dotnet") { WorkingDirectory = rootPath }

View file

@ -112,7 +112,7 @@ namespace Microsoft.DotNet.Tests
.And.Pass();
}
[Fact]
[RequiresSpecificFrameworkFact("netcoreapp1.1")] // https://github.com/dotnet/cli/issues/6087
public void CanInvokeToolFromDirectDependenciesIfPackageNameDifferentFromToolName()
{
var testInstance = TestAssets.Get("AppWithDirectDepWithOutputName")
@ -242,7 +242,7 @@ namespace Microsoft.DotNet.Tests
.Should().Fail();
}
[Fact]
[RequiresSpecificFrameworkFact("netcoreapp1.1")] // https://github.com/dotnet/cli/issues/6087
public void ToolsCanAccessDependencyContextProperly()
{
var testInstance = TestAssets.Get("DependencyContextFromTool")
@ -296,7 +296,7 @@ namespace Microsoft.DotNet.Tests
.WithRestoreFiles();
var assetsFile = new DirectoryInfo(new RepoDirectoriesProvider().NugetPackages)
.GetDirectory(".tools", "dotnet-portable", "1.0.0", "netcoreapp1.0")
.GetDirectory(".tools", "dotnet-portable", "1.0.0", "netcoreapp2.0")
.GetFile("project.assets.json");
var stopWatch = Stopwatch.StartNew();
@ -317,7 +317,7 @@ namespace Microsoft.DotNet.Tests
stopWatch.ElapsedMilliseconds.Should().BeGreaterThan(1000, "Because dotnet should respect the NuGet lock");
}
[Fact]
[Fact(Skip="https://github.com/dotnet/cli/issues/6006")]
public void WhenToolAssetsFileIsLockedByNuGetThenCLIRetriesLaunchingTheCommandForAtLeastOneSecond()
{
var testInstance = TestAssets.Get("AppWithToolDependency")