Adding backwards compat tests to the CLI test catalog.

https://github.com/dotnet/cli/issues/6227
https://github.com/dotnet/cli/issues/6228
This commit is contained in:
John Beisner 2017-04-06 11:58:19 -07:00
parent 3d4a6ed72a
commit 9bfe67a8e8
3 changed files with 121 additions and 0 deletions

View file

@ -222,6 +222,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "templates", "templates", "{
build\templates\templates.csproj = build\templates\templates.csproj build\templates\templates.csproj = build\templates\templates.csproj
EndProjectSection EndProjectSection
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "dotnet-back-compat.Tests", "test\dotnet-back-compat.Tests\dotnet-back-compat.Tests.csproj", "{A4C198B4-D46E-4CA8-87DF-B2B206DCCAE6}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@ -1510,6 +1512,30 @@ Global
{CACA427D-5A71-45E6-88DC-3E2DB6C4D52D}.RelWithDebInfo|x64.Build.0 = Release|Any CPU {CACA427D-5A71-45E6-88DC-3E2DB6C4D52D}.RelWithDebInfo|x64.Build.0 = Release|Any CPU
{CACA427D-5A71-45E6-88DC-3E2DB6C4D52D}.RelWithDebInfo|x86.ActiveCfg = Release|Any CPU {CACA427D-5A71-45E6-88DC-3E2DB6C4D52D}.RelWithDebInfo|x86.ActiveCfg = Release|Any CPU
{CACA427D-5A71-45E6-88DC-3E2DB6C4D52D}.RelWithDebInfo|x86.Build.0 = Release|Any CPU {CACA427D-5A71-45E6-88DC-3E2DB6C4D52D}.RelWithDebInfo|x86.Build.0 = Release|Any CPU
{A4C198B4-D46E-4CA8-87DF-B2B206DCCAE6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A4C198B4-D46E-4CA8-87DF-B2B206DCCAE6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A4C198B4-D46E-4CA8-87DF-B2B206DCCAE6}.Debug|x64.ActiveCfg = Debug|Any CPU
{A4C198B4-D46E-4CA8-87DF-B2B206DCCAE6}.Debug|x64.Build.0 = Debug|Any CPU
{A4C198B4-D46E-4CA8-87DF-B2B206DCCAE6}.Debug|x86.ActiveCfg = Debug|Any CPU
{A4C198B4-D46E-4CA8-87DF-B2B206DCCAE6}.Debug|x86.Build.0 = Debug|Any CPU
{A4C198B4-D46E-4CA8-87DF-B2B206DCCAE6}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU
{A4C198B4-D46E-4CA8-87DF-B2B206DCCAE6}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU
{A4C198B4-D46E-4CA8-87DF-B2B206DCCAE6}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU
{A4C198B4-D46E-4CA8-87DF-B2B206DCCAE6}.MinSizeRel|x64.Build.0 = Debug|Any CPU
{A4C198B4-D46E-4CA8-87DF-B2B206DCCAE6}.MinSizeRel|x86.ActiveCfg = Debug|Any CPU
{A4C198B4-D46E-4CA8-87DF-B2B206DCCAE6}.MinSizeRel|x86.Build.0 = Debug|Any CPU
{A4C198B4-D46E-4CA8-87DF-B2B206DCCAE6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A4C198B4-D46E-4CA8-87DF-B2B206DCCAE6}.Release|Any CPU.Build.0 = Release|Any CPU
{A4C198B4-D46E-4CA8-87DF-B2B206DCCAE6}.Release|x64.ActiveCfg = Release|Any CPU
{A4C198B4-D46E-4CA8-87DF-B2B206DCCAE6}.Release|x64.Build.0 = Release|Any CPU
{A4C198B4-D46E-4CA8-87DF-B2B206DCCAE6}.Release|x86.ActiveCfg = Release|Any CPU
{A4C198B4-D46E-4CA8-87DF-B2B206DCCAE6}.Release|x86.Build.0 = Release|Any CPU
{A4C198B4-D46E-4CA8-87DF-B2B206DCCAE6}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU
{A4C198B4-D46E-4CA8-87DF-B2B206DCCAE6}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU
{A4C198B4-D46E-4CA8-87DF-B2B206DCCAE6}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU
{A4C198B4-D46E-4CA8-87DF-B2B206DCCAE6}.RelWithDebInfo|x64.Build.0 = Release|Any CPU
{A4C198B4-D46E-4CA8-87DF-B2B206DCCAE6}.RelWithDebInfo|x86.ActiveCfg = Release|Any CPU
{A4C198B4-D46E-4CA8-87DF-B2B206DCCAE6}.RelWithDebInfo|x86.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
@ -1578,5 +1604,6 @@ Global
{CACA427D-5A71-45E6-88DC-3E2DB6C4D52D} = {FF498306-2DE2-47F6-8C35-3CF0589CF2B8} {CACA427D-5A71-45E6-88DC-3E2DB6C4D52D} = {FF498306-2DE2-47F6-8C35-3CF0589CF2B8}
{3275D006-54C8-4C64-A537-B9941C5D2F0C} = {89905EC4-BC0F-443B-8ADF-691321F10108} {3275D006-54C8-4C64-A537-B9941C5D2F0C} = {89905EC4-BC0F-443B-8ADF-691321F10108}
{DE4D1AEB-871B-4E7C-945A-453F9A490C06} = {89905EC4-BC0F-443B-8ADF-691321F10108} {DE4D1AEB-871B-4E7C-945A-453F9A490C06} = {89905EC4-BC0F-443B-8ADF-691321F10108}
{A4C198B4-D46E-4CA8-87DF-B2B206DCCAE6} = {17735A9D-BFD9-4585-A7CB-3208CA6EA8A7}
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal

View file

@ -0,0 +1,72 @@
// 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;
using System.IO;
using FluentAssertions;
using Microsoft.DotNet.Tools.Test.Utilities;
using Xunit;
using System.Linq;
using System.Xml.Linq;
namespace Microsoft.DotNet.Cli.Build.Tests
{
public class GivenBackCompat : TestBase
{
[Theory]
[InlineData("netcoreapp1.0", false, true)]
[InlineData("netcoreapp1.1", false, true)]
[InlineData("netstandard1.3", true, false)]
[InlineData("netstandard1.6", true, false)]
public void ItRestoresBuildsPacksRuns(string target, bool createNuGetPackage, bool executeProgram)
{
var testAppName = "TestAppSimple";
var testInstance = TestAssets.Get(testAppName)
.CreateInstance(testAppName + "_" + target.Replace('.', '_'))
.WithSourceFiles();
// Replace the 'TargetFramework'
string projectFile = Path.Combine(testInstance.Root.ToString(), $"{testAppName}.csproj");
var projectXml = XDocument.Load(projectFile);
var ns = projectXml.Root.Name.Namespace;
var propertyGroup = projectXml.Root.Elements(ns + "PropertyGroup").First();
var rootNamespaceElement = propertyGroup.Element(ns + "TargetFramework");
rootNamespaceElement.SetValue(target);
projectXml.Save(projectFile);
new RestoreCommand()
.WithWorkingDirectory(testInstance.Root)
.Execute()
.Should().Pass();
new BuildCommand()
.WithWorkingDirectory(testInstance.Root)
.Execute()
.Should().Pass();
if (createNuGetPackage)
{
new PackCommand()
.WithWorkingDirectory(testInstance.Root)
.Execute()
.Should().Pass();
}
if (executeProgram)
{
var configuration = Environment.GetEnvironmentVariable("CONFIGURATION") ?? "Debug";
var outputDll = testInstance.Root.GetDirectory("bin", configuration, target)
.GetFile($"{testAppName}.dll");
new DotnetCommand()
.ExecuteWithCapturedOutput(outputDll.FullName)
.Should().Pass()
.And.HaveStdOutContaining("Hello World");
}
}
}
}

View file

@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<PropertyGroup>
<TargetFramework>$(CliTargetFramework)</TargetFramework>
<RuntimeFrameworkVersion>$(CLI_SharedFrameworkVersion)</RuntimeFrameworkVersion>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<AssemblyName>dotnet-back-compat.Tests</AssemblyName>
<PackageTargetFallback>$(PackageTargetFallback);dotnet5.4;portable-net451+win8</PackageTargetFallback>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Microsoft.DotNet.Tools.Tests.Utilities\Microsoft.DotNet.Tools.Tests.Utilities.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(CLI_TestPlatform_Version)" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0-beta4-build1194" />
<PackageReference Include="xunit" Version="2.2.0-beta4-build3444" />
<PackageReference Include="Microsoft.Build" Version="$(CLI_MSBuild_Version)" />
</ItemGroup>
</Project>