Merge pull request #6054 from eerhardt/EnableLinuxTests

Enable tests on linux portable build.
This commit is contained in:
Livar 2017-03-20 20:59:44 -07:00 committed by GitHub
commit a70f2a7af8
11 changed files with 52 additions and 117 deletions

View file

@ -60,11 +60,7 @@ platformList.each { platform ->
Utilities.setMachineAffinity(newJob, osUsedForMachineAffinity, 'latest-or-auto') Utilities.setMachineAffinity(newJob, osUsedForMachineAffinity, 'latest-or-auto')
Utilities.standardJobSetup(newJob, project, isPR, "*/${branch}") Utilities.standardJobSetup(newJob, project, isPR, "*/${branch}")
// Remove this check once tests work for 2.0. Until that time Linux portable tests will fail so we Utilities.addMSTestResults(newJob, '**/*.trx')
// don't run the tests and there won't be any .trx file.
if (os != 'Linux') {
Utilities.addMSTestResults(newJob, '**/*.trx')
}
Utilities.addGithubPRTriggerForBranch(newJob, branch, "${os} ${architecture} ${configuration} Build") Utilities.addGithubPRTriggerForBranch(newJob, branch, "${os} ${architecture} ${configuration} Build")
} }

View file

@ -98,8 +98,7 @@ while [[ $# > 0 ]]; do
;; ;;
--linux-portable) --linux-portable)
LINUX_PORTABLE_INSTALL_ARGS="--runtime-id linux-x64" LINUX_PORTABLE_INSTALL_ARGS="--runtime-id linux-x64"
# Until we get test support for 2.0 we need to pass in the targets without test. CUSTOM_BUILD_ARGS="/p:Rid=\"linux-x64\" /p:OSName=\"linux\""
CUSTOM_BUILD_ARGS="/p:Rid=\"linux-x64\" /p:OSName=\"linux\" /p:CLITargets=\"Prepare;Compile;Package;Publish\""
args=( "${args[@]/$1}" ) args=( "${args[@]/$1}" )
;; ;;
--help) --help)

View file

@ -25,16 +25,5 @@ namespace Microsoft.DotNet.Cli
{ {
get { return s_versionFileObject.Value; } get { return s_versionFileObject.Value; }
} }
/// <summary>
/// Reads the version file and adds runtime specific information
/// </summary>
public static string ReadAndInterpretVersionFile()
{
var content = File.ReadAllText(DotnetFiles.VersionFile);
content += Environment.NewLine;
content += RuntimeEnvironment.GetRuntimeIdentifier();
return content;
}
} }
} }

View file

@ -1,34 +0,0 @@
// 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 System.Collections.Generic;
namespace Microsoft.DotNet.Cli.Utils
{
internal static class DotnetRuntimeIdentifiers
{
public static IEnumerable<string> InferCurrentRuntimeIdentifiers(DotnetVersionFile versionFile)
{
IEnumerable<string> fallbackIdentifiers = null;
// If the machine's RID isn't supported by the shared framework (i.e. the CLI
// is being used on a newer version of an OS), add the RID that the CLI was built
// with as a fallback. The RID the CLI was built with will have the correct
// runtime.* NuGet packages available.
// For example, when a user is using osx.10.12, but we only support osx.10.10 and
// osx.10.11, the project.json "runtimes" section cannot contain osx.10.12, since
// that RID isn't contained in the runtime graph - users will get a restore error.
FrameworkDependencyFile fxDepsFile = new FrameworkDependencyFile();
if (!fxDepsFile.SupportsCurrentRuntime())
{
string buildRid = versionFile.BuildRid;
if (!string.IsNullOrEmpty(buildRid))
{
fallbackIdentifiers = new string[] { buildRid };
}
}
return RuntimeEnvironmentRidExtensions.GetAllCandidateRuntimeIdentifiers(fallbackIdentifiers);
}
}
}

View file

@ -29,59 +29,5 @@ namespace Microsoft.DotNet.Cli.Utils
return "win7-" + arch; return "win7-" + arch;
} }
} }
public static IEnumerable<string> GetAllCandidateRuntimeIdentifiers()
{
return GetAllCandidateRuntimeIdentifiers(null);
}
public static IEnumerable<string> GetAllCandidateRuntimeIdentifiers(IEnumerable<string> fallbackIdentifiers = null)
{
List<string> result = new List<string>();
if (RuntimeEnvironment.OperatingSystemPlatform != Platform.Windows)
{
result.Add(RuntimeEnvironment.GetRuntimeIdentifier());
}
else
{
var arch = RuntimeEnvironment.RuntimeArchitecture.ToLowerInvariant();
if (RuntimeEnvironment.OperatingSystemVersion.StartsWith("6.1", StringComparison.Ordinal))
{
result.Add("win7-" + arch);
}
else if (RuntimeEnvironment.OperatingSystemVersion.StartsWith("6.2", StringComparison.Ordinal))
{
result.Add("win8-" + arch);
result.Add("win7-" + arch);
}
else if (RuntimeEnvironment.OperatingSystemVersion.StartsWith("6.3", StringComparison.Ordinal))
{
result.Add("win81-" + arch);
result.Add("win8-" + arch);
result.Add("win7-" + arch);
}
else if (RuntimeEnvironment.OperatingSystemVersion.StartsWith("10.0", StringComparison.Ordinal))
{
result.Add("win10-" + arch);
result.Add("win81-" + arch);
result.Add("win8-" + arch);
result.Add("win7-" + arch);
}
}
if (fallbackIdentifiers != null)
{
foreach (string fallbackIdentifier in fallbackIdentifiers)
{
if (!result.Contains(fallbackIdentifier))
{
result.Add(fallbackIdentifier);
}
}
}
return result;
}
} }
} }

View file

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

View file

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

View file

@ -1,22 +1,30 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved. // 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. // 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 namespace Microsoft.DotNet.Tools.Test.Utilities
{ {
public static class EnvironmentInfo public static class EnvironmentInfo
{ {
public static bool HasSharedFramework(string framework) public static bool HasSharedFramework(string framework)
{ {
string rid = RepoDirectoriesProvider.BuildRid;
if (framework == "netcoreapp1.0") if (framework == "netcoreapp1.0")
{ {
string rid = RuntimeEnvironment.GetRuntimeIdentifier();
switch (rid) switch (rid)
{ {
case "fedora.24-x64": case "fedora.24-x64":
case "opensuse.42.1-x64": case "opensuse.42.1-x64":
case "ubuntu.16.10-x64": case "ubuntu.16.10-x64":
case "linux-x64":
return false;
}
}
else if (framework == "netcoreapp1.1")
{
switch (rid)
{
case "linux-x64":
return false; return false;
} }
} }

View file

@ -4,6 +4,7 @@
using System; using System;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Xml.Linq;
using Microsoft.DotNet.PlatformAbstractions; using Microsoft.DotNet.PlatformAbstractions;
namespace Microsoft.DotNet.Tools.Test.Utilities namespace Microsoft.DotNet.Tools.Test.Utilities
@ -11,6 +12,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
public class RepoDirectoriesProvider public class RepoDirectoriesProvider
{ {
private static string s_repoRoot; private static string s_repoRoot;
private static string s_buildRid;
private string _artifacts; private string _artifacts;
private string _builtDotnet; 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 Artifacts => _artifacts;
public string BuiltDotnet => _builtDotnet; public string BuiltDotnet => _builtDotnet;
public string NugetPackages => _nugetPackages; public string NugetPackages => _nugetPackages;
@ -64,9 +92,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
string corehostDummyPackages = null, string corehostDummyPackages = null,
string pjDotnet = null) string pjDotnet = null)
{ {
var currentRid = RuntimeEnvironment.GetRuntimeIdentifier(); _artifacts = artifacts ?? Path.Combine(RepoRoot, "artifacts", BuildRid);
_artifacts = artifacts ?? Path.Combine(RepoRoot, "artifacts", currentRid);
_builtDotnet = builtDotnet ?? Path.Combine(_artifacts, "intermediate", "sharedFrameworkPublish"); _builtDotnet = builtDotnet ?? Path.Combine(_artifacts, "intermediate", "sharedFrameworkPublish");
_nugetPackages = nugetPackages ?? Path.Combine(RepoRoot, ".nuget", "packages"); _nugetPackages = nugetPackages ?? Path.Combine(RepoRoot, ".nuget", "packages");
_pjDotnet = pjDotnet ?? GetPjDotnetPath(); _pjDotnet = pjDotnet ?? GetPjDotnetPath();

View file

@ -34,6 +34,13 @@ namespace Microsoft.DotNet.New.Tests
string projectType, string projectType,
bool useNuGetConfigForAspNet) 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; string rootPath = TestAssets.CreateTestDirectory(identifier: $"{language}_{projectType}").FullName;
new TestCommand("dotnet") { WorkingDirectory = rootPath } new TestCommand("dotnet") { WorkingDirectory = rootPath }

View file

@ -112,7 +112,7 @@ namespace Microsoft.DotNet.Tests
.And.Pass(); .And.Pass();
} }
[Fact] [RequiresSpecificFrameworkFact("netcoreapp1.1")] // https://github.com/dotnet/cli/issues/6087
public void CanInvokeToolFromDirectDependenciesIfPackageNameDifferentFromToolName() public void CanInvokeToolFromDirectDependenciesIfPackageNameDifferentFromToolName()
{ {
var testInstance = TestAssets.Get("AppWithDirectDepWithOutputName") var testInstance = TestAssets.Get("AppWithDirectDepWithOutputName")
@ -242,7 +242,7 @@ namespace Microsoft.DotNet.Tests
.Should().Fail(); .Should().Fail();
} }
[Fact] [RequiresSpecificFrameworkFact("netcoreapp1.1")] // https://github.com/dotnet/cli/issues/6087
public void ToolsCanAccessDependencyContextProperly() public void ToolsCanAccessDependencyContextProperly()
{ {
var testInstance = TestAssets.Get("DependencyContextFromTool") var testInstance = TestAssets.Get("DependencyContextFromTool")