Enable tests

This commit is contained in:
Daniel Plaisted 2018-10-29 11:26:53 -07:00
parent ac23150af3
commit 96c79f9661
26 changed files with 288 additions and 394 deletions

View file

@ -11,11 +11,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "redist", "src\redist\redist
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EndToEnd.Tests", "test\EndToEnd\EndToEnd.Tests.csproj", "{1BFF54F9-4E35-49DB-893C-AF2047722FC6}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.DotNet.Tools.Tests.Utilities", "test\Microsoft.DotNet.Tools.Tests.Utilities\Microsoft.DotNet.Tools.Tests.Utilities.csproj", "{48E260F4-6F3F-4387-B61F-D15BABD06D9A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "core-sdk-tasks", "src\core-sdk-tasks\core-sdk-tasks.csproj", "{53AF2D01-B69F-4CD0-86A7-8FD95967D23C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.DotNet.TestFramework", "test\Microsoft.DotNet.TestFramework\Microsoft.DotNet.TestFramework.csproj", "{D03CF1D2-39D1-4825-9AF0-4A4D3882CB69}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.DotNet.Tools.Tests.Utilities", "test\Microsoft.DotNet.Tools.Tests.Utilities\Microsoft.DotNet.Tools.Tests.Utilities.csproj", "{78E15EC1-7732-41E3-8591-934E9F583254}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -81,30 +79,6 @@ Global
{1BFF54F9-4E35-49DB-893C-AF2047722FC6}.RelWithDebInfo|x64.Build.0 = Release|Any CPU
{1BFF54F9-4E35-49DB-893C-AF2047722FC6}.RelWithDebInfo|x86.ActiveCfg = Release|Any CPU
{1BFF54F9-4E35-49DB-893C-AF2047722FC6}.RelWithDebInfo|x86.Build.0 = Release|Any CPU
{48E260F4-6F3F-4387-B61F-D15BABD06D9A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{48E260F4-6F3F-4387-B61F-D15BABD06D9A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{48E260F4-6F3F-4387-B61F-D15BABD06D9A}.Debug|x64.ActiveCfg = Release|Any CPU
{48E260F4-6F3F-4387-B61F-D15BABD06D9A}.Debug|x64.Build.0 = Release|Any CPU
{48E260F4-6F3F-4387-B61F-D15BABD06D9A}.Debug|x86.ActiveCfg = Release|Any CPU
{48E260F4-6F3F-4387-B61F-D15BABD06D9A}.Debug|x86.Build.0 = Release|Any CPU
{48E260F4-6F3F-4387-B61F-D15BABD06D9A}.MinSizeRel|Any CPU.ActiveCfg = Release|Any CPU
{48E260F4-6F3F-4387-B61F-D15BABD06D9A}.MinSizeRel|Any CPU.Build.0 = Release|Any CPU
{48E260F4-6F3F-4387-B61F-D15BABD06D9A}.MinSizeRel|x64.ActiveCfg = Release|Any CPU
{48E260F4-6F3F-4387-B61F-D15BABD06D9A}.MinSizeRel|x64.Build.0 = Release|Any CPU
{48E260F4-6F3F-4387-B61F-D15BABD06D9A}.MinSizeRel|x86.ActiveCfg = Release|Any CPU
{48E260F4-6F3F-4387-B61F-D15BABD06D9A}.MinSizeRel|x86.Build.0 = Release|Any CPU
{48E260F4-6F3F-4387-B61F-D15BABD06D9A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{48E260F4-6F3F-4387-B61F-D15BABD06D9A}.Release|Any CPU.Build.0 = Release|Any CPU
{48E260F4-6F3F-4387-B61F-D15BABD06D9A}.Release|x64.ActiveCfg = Release|Any CPU
{48E260F4-6F3F-4387-B61F-D15BABD06D9A}.Release|x64.Build.0 = Release|Any CPU
{48E260F4-6F3F-4387-B61F-D15BABD06D9A}.Release|x86.ActiveCfg = Release|Any CPU
{48E260F4-6F3F-4387-B61F-D15BABD06D9A}.Release|x86.Build.0 = Release|Any CPU
{48E260F4-6F3F-4387-B61F-D15BABD06D9A}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU
{48E260F4-6F3F-4387-B61F-D15BABD06D9A}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU
{48E260F4-6F3F-4387-B61F-D15BABD06D9A}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU
{48E260F4-6F3F-4387-B61F-D15BABD06D9A}.RelWithDebInfo|x64.Build.0 = Release|Any CPU
{48E260F4-6F3F-4387-B61F-D15BABD06D9A}.RelWithDebInfo|x86.ActiveCfg = Release|Any CPU
{48E260F4-6F3F-4387-B61F-D15BABD06D9A}.RelWithDebInfo|x86.Build.0 = Release|Any CPU
{53AF2D01-B69F-4CD0-86A7-8FD95967D23C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{53AF2D01-B69F-4CD0-86A7-8FD95967D23C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{53AF2D01-B69F-4CD0-86A7-8FD95967D23C}.Debug|x64.ActiveCfg = Debug|Any CPU
@ -129,30 +103,30 @@ Global
{53AF2D01-B69F-4CD0-86A7-8FD95967D23C}.RelWithDebInfo|x64.Build.0 = Release|Any CPU
{53AF2D01-B69F-4CD0-86A7-8FD95967D23C}.RelWithDebInfo|x86.ActiveCfg = Release|Any CPU
{53AF2D01-B69F-4CD0-86A7-8FD95967D23C}.RelWithDebInfo|x86.Build.0 = Release|Any CPU
{D03CF1D2-39D1-4825-9AF0-4A4D3882CB69}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D03CF1D2-39D1-4825-9AF0-4A4D3882CB69}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D03CF1D2-39D1-4825-9AF0-4A4D3882CB69}.Debug|x64.ActiveCfg = Debug|Any CPU
{D03CF1D2-39D1-4825-9AF0-4A4D3882CB69}.Debug|x64.Build.0 = Debug|Any CPU
{D03CF1D2-39D1-4825-9AF0-4A4D3882CB69}.Debug|x86.ActiveCfg = Debug|Any CPU
{D03CF1D2-39D1-4825-9AF0-4A4D3882CB69}.Debug|x86.Build.0 = Debug|Any CPU
{D03CF1D2-39D1-4825-9AF0-4A4D3882CB69}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU
{D03CF1D2-39D1-4825-9AF0-4A4D3882CB69}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU
{D03CF1D2-39D1-4825-9AF0-4A4D3882CB69}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU
{D03CF1D2-39D1-4825-9AF0-4A4D3882CB69}.MinSizeRel|x64.Build.0 = Debug|Any CPU
{D03CF1D2-39D1-4825-9AF0-4A4D3882CB69}.MinSizeRel|x86.ActiveCfg = Debug|Any CPU
{D03CF1D2-39D1-4825-9AF0-4A4D3882CB69}.MinSizeRel|x86.Build.0 = Debug|Any CPU
{D03CF1D2-39D1-4825-9AF0-4A4D3882CB69}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D03CF1D2-39D1-4825-9AF0-4A4D3882CB69}.Release|Any CPU.Build.0 = Release|Any CPU
{D03CF1D2-39D1-4825-9AF0-4A4D3882CB69}.Release|x64.ActiveCfg = Release|Any CPU
{D03CF1D2-39D1-4825-9AF0-4A4D3882CB69}.Release|x64.Build.0 = Release|Any CPU
{D03CF1D2-39D1-4825-9AF0-4A4D3882CB69}.Release|x86.ActiveCfg = Release|Any CPU
{D03CF1D2-39D1-4825-9AF0-4A4D3882CB69}.Release|x86.Build.0 = Release|Any CPU
{D03CF1D2-39D1-4825-9AF0-4A4D3882CB69}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU
{D03CF1D2-39D1-4825-9AF0-4A4D3882CB69}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU
{D03CF1D2-39D1-4825-9AF0-4A4D3882CB69}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU
{D03CF1D2-39D1-4825-9AF0-4A4D3882CB69}.RelWithDebInfo|x64.Build.0 = Release|Any CPU
{D03CF1D2-39D1-4825-9AF0-4A4D3882CB69}.RelWithDebInfo|x86.ActiveCfg = Release|Any CPU
{D03CF1D2-39D1-4825-9AF0-4A4D3882CB69}.RelWithDebInfo|x86.Build.0 = Release|Any CPU
{78E15EC1-7732-41E3-8591-934E9F583254}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{78E15EC1-7732-41E3-8591-934E9F583254}.Debug|Any CPU.Build.0 = Debug|Any CPU
{78E15EC1-7732-41E3-8591-934E9F583254}.Debug|x64.ActiveCfg = Debug|Any CPU
{78E15EC1-7732-41E3-8591-934E9F583254}.Debug|x64.Build.0 = Debug|Any CPU
{78E15EC1-7732-41E3-8591-934E9F583254}.Debug|x86.ActiveCfg = Debug|Any CPU
{78E15EC1-7732-41E3-8591-934E9F583254}.Debug|x86.Build.0 = Debug|Any CPU
{78E15EC1-7732-41E3-8591-934E9F583254}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU
{78E15EC1-7732-41E3-8591-934E9F583254}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU
{78E15EC1-7732-41E3-8591-934E9F583254}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU
{78E15EC1-7732-41E3-8591-934E9F583254}.MinSizeRel|x64.Build.0 = Debug|Any CPU
{78E15EC1-7732-41E3-8591-934E9F583254}.MinSizeRel|x86.ActiveCfg = Debug|Any CPU
{78E15EC1-7732-41E3-8591-934E9F583254}.MinSizeRel|x86.Build.0 = Debug|Any CPU
{78E15EC1-7732-41E3-8591-934E9F583254}.Release|Any CPU.ActiveCfg = Release|Any CPU
{78E15EC1-7732-41E3-8591-934E9F583254}.Release|Any CPU.Build.0 = Release|Any CPU
{78E15EC1-7732-41E3-8591-934E9F583254}.Release|x64.ActiveCfg = Release|Any CPU
{78E15EC1-7732-41E3-8591-934E9F583254}.Release|x64.Build.0 = Release|Any CPU
{78E15EC1-7732-41E3-8591-934E9F583254}.Release|x86.ActiveCfg = Release|Any CPU
{78E15EC1-7732-41E3-8591-934E9F583254}.Release|x86.Build.0 = Release|Any CPU
{78E15EC1-7732-41E3-8591-934E9F583254}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU
{78E15EC1-7732-41E3-8591-934E9F583254}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU
{78E15EC1-7732-41E3-8591-934E9F583254}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU
{78E15EC1-7732-41E3-8591-934E9F583254}.RelWithDebInfo|x64.Build.0 = Release|Any CPU
{78E15EC1-7732-41E3-8591-934E9F583254}.RelWithDebInfo|x86.ActiveCfg = Release|Any CPU
{78E15EC1-7732-41E3-8591-934E9F583254}.RelWithDebInfo|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -160,9 +134,8 @@ Global
GlobalSection(NestedProjects) = preSolution
{098D9321-1201-4974-A75E-F58EBCD98ACF} = {ED2FE3E2-F7E7-4389-8231-B65123F2076F}
{1BFF54F9-4E35-49DB-893C-AF2047722FC6} = {17735A9D-BFD9-4585-A7CB-3208CA6EA8A7}
{48E260F4-6F3F-4387-B61F-D15BABD06D9A} = {17735A9D-BFD9-4585-A7CB-3208CA6EA8A7}
{53AF2D01-B69F-4CD0-86A7-8FD95967D23C} = {ED2FE3E2-F7E7-4389-8231-B65123F2076F}
{D03CF1D2-39D1-4825-9AF0-4A4D3882CB69} = {17735A9D-BFD9-4585-A7CB-3208CA6EA8A7}
{78E15EC1-7732-41E3-8591-934E9F583254} = {17735A9D-BFD9-4585-A7CB-3208CA6EA8A7}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B526D2CE-EE2D-4AD4-93EF-1867D90FF1F5}

View file

@ -0,0 +1,3 @@
<Project>
<!-- Empty Directory.Build.targets file to prevent test asset projects from picking up the repo's Directory.Build.props' -->
</Project>

View file

@ -1,21 +1,16 @@
<Project>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), testAsset.props))\testAsset.props" />
<Import Sdk="Microsoft.NET.Sdk" Project="Sdk.props" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<VersionPrefix>1.0.0-rc</VersionPrefix>
<TargetFramework>$(CliTargetFramework)</TargetFramework>
<TargetFramework>netcoreapp3.0</TargetFramework>
<OutputType>Exe</OutputType>
<VersionSuffix></VersionSuffix>
<RuntimeFrameworkVersion>$(MicrosoftNETCoreAppPackageVersion)</RuntimeFrameworkVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="NuGet.Frameworks" Version="$(NuGetFrameworksPackageVersion)" />
<PackageReference Include="Microsoft.DotNet.Cli.Utils" Version="$(MicrosoftDotNetCliUtilsPackageVersion)" />
<PackageReference Include="Microsoft.DotNet.Cli.CommandLine" Version="$(MicrosoftDotNetCliCommandLinePackageVersion)" />
<PackageReference Include="NuGet.Frameworks" Version="4.8.0-rtm.5348" />
<PackageReference Include="Microsoft.DotNet.Cli.Utils" Version="3.0.100-alpha1-20180711-1" />
<PackageReference Include="Microsoft.DotNet.Cli.CommandLine" Version="0.1.1" />
<PackageReference Include="System.Linq" Version="4.3.0" />
</ItemGroup>
<Import Sdk="Microsoft.NET.Sdk" Project="Sdk.targets" />
</Project>

View file

@ -1,8 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), testAsset.props))\testAsset.props" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>$(CliTargetFramework)</TargetFramework>
<TargetFramework>netcoreapp3.0</TargetFramework>
<OutputType>Exe</OutputType>
</PropertyGroup>

View file

@ -1,8 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), testAsset.props))\testAsset.props" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>$(CliTargetFramework)</TargetFramework>
<TargetFramework>netcoreapp3.0</TargetFramework>
<OutputType>Exe</OutputType>
<VersionSuffix></VersionSuffix>
</PropertyGroup>

View file

@ -1,10 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), testAsset.props))\testAsset.props" />
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>$(CliTargetFramework)</TargetFramework>
<RuntimeIdentifiers>win7-x64;win7-x86;osx.10.12-x64;ubuntu.14.04-x64;ubuntu.16.04-x64;ubuntu.16.10-x64;rhel.6-x64;centos.7-x64;rhel.7-x64;debian.8-x64;fedora.24-x64;opensuse.42.1-x64;linux-musl-x64</RuntimeIdentifiers>
<TargetFramework>netcoreapp3.0</TargetFramework>
<RestoreAdditionalProjectSources Condition="'$(TEST_PACKAGES)' != ''">$(TEST_PACKAGES)</RestoreAdditionalProjectSources>
</PropertyGroup>

View file

@ -1,9 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), testAsset.props))\testAsset.props" />
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>$(CliTargetFramework)</TargetFramework>
<TargetFramework>netcoreapp3.0</TargetFramework>
<RestoreAdditionalProjectSources Condition="'$(TEST_PACKAGES)' != ''">$(TEST_PACKAGES)</RestoreAdditionalProjectSources>
</PropertyGroup>

View file

@ -4,14 +4,10 @@
</PropertyGroup>
<ItemGroup>
<!-- <Content Include="..\..\artifacts\*\stage2\sdk\*\.version">
<Link>.version</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> -->
</ItemGroup>
<!-- Copy empty Directory.Build files to stop tests from getting repo build logic -->
<Content Include="$(RepoRoot)TestAssets\Directory.Build.props" LinkBase="Tests" CopyToOutputDirectory="PreserveNewest" />
<Content Include="$(RepoRoot)TestAssets\Directory.Build.targets" LinkBase="Tests" CopyToOutputDirectory="PreserveNewest" />
<ItemGroup>
<ProjectReference Include="..\Microsoft.DotNet.Tools.Tests.Utilities\Microsoft.DotNet.Tools.Tests.Utilities.csproj" />
</ItemGroup>
<ItemGroup>
@ -19,4 +15,8 @@
<PackageReference Include="xunit" Version="2.2.0" /> -->
<PackageReference Include="Microsoft.DotNet.PlatformAbstractions" Version="$(MicrosoftDotNetPlatformAbstractionsPackageVersion)" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Microsoft.DotNet.Tools.Tests.Utilities\Microsoft.DotNet.Tools.Tests.Utilities.csproj" />
</ItemGroup>
</Project>

View file

@ -175,10 +175,10 @@ namespace EndToEnd
[Fact(Skip = "https://github.com/dotnet/core-sdk/issues/21")]
public void WeCoverLatestAspNetCoreAppRollForward()
{
var directory = TestAssets.CreateTestDirectory();
string projectDirectory = directory.FullName;
// Run "dotnet new web", get TargetFramework property, and make sure it's covered in SupportedAspNetCoreAppVersions
using (DisposableDirectory directory = Temp.CreateDirectory())
{
string projectDirectory = directory.Path;
new NewCommandShim()
.WithWorkingDirectory(projectDirectory)
@ -199,7 +199,6 @@ namespace EndToEnd
"of Microsoft.AspNetCore.App used by the templates created by \"dotnet new web\"");
}
}
private NuGetVersion GetAspNetCoreAppVersion(LockFile lockFile, bool portable = false)
{

View file

@ -5,6 +5,7 @@ using System;
using System.IO;
using System.Linq;
using System.Xml.Linq;
using Microsoft.DotNet.TestFramework;
using Microsoft.DotNet.Tools.Test.Utilities;
using Xunit;
@ -14,12 +15,24 @@ namespace Microsoft.DotNet.Tests.EndToEnd
{
public class GivenDotNetUsesMSBuild : TestBase
{
private string _testPackagesDirectory;
private string _testNuGetCache;
public GivenDotNetUsesMSBuild()
{
_testPackagesDirectory = SetupTestPackages();
_testNuGetCache = TestAssets.CreateTestDirectory(testProjectName: string.Empty,
callingMethod: "packages",
identifier: string.Empty)
.FullName;
}
[Fact]
public void ItCanNewRestoreBuildRunCleanMSBuildProject()
{
using (DisposableDirectory directory = Temp.CreateDirectory())
{
string projectDirectory = directory.Path;
var directory = TestAssets.CreateTestDirectory();
string projectDirectory = directory.FullName;
string newArgs = "console --debug:ephemeral-hive --no-restore";
new NewCommandShim()
@ -58,20 +71,28 @@ namespace Microsoft.DotNet.Tests.EndToEnd
binDirectory.Should().NotHaveFilesMatching("*.dll", SearchOption.AllDirectories);
}
}
[Fact]
public void ItCanRunToolsInACSProj()
{
var testInstance = TestAssets.Get("MSBuildTestApp")
.CreateInstance()
.WithSourceFiles()
.WithRestoreFiles();
.WithSourceFiles();
var testProjectDirectory = testInstance.Root;
new RestoreCommand()
.WithWorkingDirectory(testProjectDirectory)
.WithEnvironmentVariable("NUGET_PACKAGES", _testNuGetCache)
.WithEnvironmentVariable("TEST_PACKAGES", _testPackagesDirectory)
.Execute()
.Should()
.Pass();
new DotnetCommand()
.WithWorkingDirectory(testInstance.Root)
.WithEnvironmentVariable("NUGET_PACKAGES", _testNuGetCache)
.WithEnvironmentVariable("TEST_PACKAGES", _testPackagesDirectory)
.ExecuteWithCapturedOutput("-d portable")
.Should()
.Pass()
@ -79,49 +100,133 @@ namespace Microsoft.DotNet.Tests.EndToEnd
.HaveStdOutContaining("Hello Portable World!");;
}
[Fact(Skip="https://github.com/dotnet/cli/issues/9688")]
[Fact]
public void ItCanRunToolsThatPrefersTheCliRuntimeEvenWhenTheToolItselfDeclaresADifferentRuntime()
{
var testInstance = TestAssets.Get("MSBuildTestApp")
.CreateInstance()
.WithSourceFiles()
.WithRestoreFiles();
.WithSourceFiles();
var testProjectDirectory = testInstance.Root;
new RestoreCommand()
.WithWorkingDirectory(testProjectDirectory)
.WithEnvironmentVariable("NUGET_PACKAGES", _testNuGetCache)
.WithEnvironmentVariable("TEST_PACKAGES", _testPackagesDirectory)
.Execute()
.Should()
.Pass();
new DotnetCommand()
.WithWorkingDirectory(testInstance.Root)
.WithEnvironmentVariable("NUGET_PACKAGES", _testNuGetCache)
.WithEnvironmentVariable("TEST_PACKAGES", _testPackagesDirectory)
.ExecuteWithCapturedOutput("-d prefercliruntime")
.Should().Pass()
.And.HaveStdOutContaining("Hello I prefer the cli runtime World!");;
}
[Fact(Skip="https://github.com/dotnet/cli/issues/9688")]
[Fact]
public void ItCanRunAToolThatInvokesADependencyToolInACSProj()
{
var repoDirectoriesProvider = new RepoDirectoriesProvider();
var testInstance = TestAssets.Get("TestAppWithProjDepTool")
.CreateInstance()
.WithSourceFiles()
.WithRestoreFiles();
.WithSourceFiles();
var configuration = "Debug";
var testProjectDirectory = testInstance.Root;
new RestoreCommand()
.WithWorkingDirectory(testProjectDirectory)
.WithEnvironmentVariable("NUGET_PACKAGES", _testNuGetCache)
.WithEnvironmentVariable("TEST_PACKAGES", _testPackagesDirectory)
.Execute()
.Should()
.Pass();
new BuildCommand()
.WithWorkingDirectory(testProjectDirectory)
.WithEnvironmentVariable("NUGET_PACKAGES", _testNuGetCache)
.WithEnvironmentVariable("TEST_PACKAGES", _testPackagesDirectory)
.Execute($"-c {configuration} ")
.Should()
.Pass();
new DotnetCommand()
.WithWorkingDirectory(testProjectDirectory)
.WithEnvironmentVariable("NUGET_PACKAGES", _testNuGetCache)
.WithEnvironmentVariable("TEST_PACKAGES", _testPackagesDirectory)
.ExecuteWithCapturedOutput(
$"-d dependency-tool-invoker -c {configuration} -f netcoreapp3.0 portable")
.Should().Pass()
.And.HaveStdOutContaining("Hello Portable World!");;
.And.HaveStdOutContaining("Hello Portable World!");
}
[Fact]
public void BuildTestPackages()
{
}
private string SetupTestPackages()
{
var directory = TestAssets.CreateTestDirectory(
testProjectName: string.Empty,
callingMethod: "TestPackages",
identifier: string.Empty);
string testPackagesDirectory = Path.Combine(directory.FullName, "testPackages");
if (!Directory.Exists(testPackagesDirectory))
{
new DirectoryInfo(testPackagesDirectory).Create();
//Directory.CreateDirectory(testPackagesDirectory);
}
var testPackageNames = new[]
{
"dotnet-portable",
"dotnet-prefercliruntime",
"dotnet-dependency-tool-invoker"
};
foreach (var testPackageName in testPackageNames)
{
var assetInfo = TestAssets.Get(TestAssetKinds.TestPackages, testPackageName);
var testProjectDirectory = new DirectoryInfo(Path.Combine(directory.FullName, testPackageName));
if (!testProjectDirectory.Exists)
{
testProjectDirectory.Create();
}
var testInstance = new TestAssetInstance(assetInfo, testProjectDirectory)
.WithSourceFiles()
.WithRestoreFiles();
new PackCommand()
.WithWorkingDirectory(testProjectDirectory)
.Execute()
.Should()
.Pass();
string nupkgFilePathInOutput = Directory.GetFiles(Path.Combine(testProjectDirectory.FullName, "bin", "Debug"), "*.nupkg")
.Single();
string nupkgFile = Path.Combine(testPackagesDirectory, Path.GetFileName(nupkgFilePathInOutput));
File.Copy(nupkgFilePathInOutput, nupkgFile);
}
return testPackagesDirectory;
}
}
}

View file

@ -40,8 +40,6 @@ namespace EndToEnd
{
var _testInstance = TestAssets.Get("TestAppSimple")
.CreateInstance(identifier: packageName + "_" + minorVersion)
// scope the feed to only dotnet-core feed to avoid flaky when different feed has a newer / lower version
.WithNuGetConfig(new RepoDirectoriesProvider().TestPackages)
.WithSourceFiles();
string projectDirectory = _testInstance.Root.FullName;

View file

@ -141,9 +141,8 @@ namespace EndToEnd
public void WeCoverLatestNetCoreAppRollForward()
{
// Run "dotnet new console", get TargetFramework property, and make sure it's covered in SupportedNetCoreAppVersions
using (DisposableDirectory directory = Temp.CreateDirectory())
{
string projectDirectory = directory.Path;
var directory = TestAssets.CreateTestDirectory();
string projectDirectory = directory.FullName;
new NewCommandShim()
.WithWorkingDirectory(projectDirectory)
@ -163,15 +162,14 @@ namespace EndToEnd
.Should().Contain(targetFramework, $"the {nameof(SupportedNetCoreAppVersions)}.{nameof(SupportedNetCoreAppVersions.Versions)} property should include the default version " +
"of .NET Core created by \"dotnet new\"");
}
}
[Fact]
public void WeCoverLatestAspNetCoreAppRollForward()
{
var directory = TestAssets.CreateTestDirectory();
string projectDirectory = directory.FullName;
// Run "dotnet new web", get TargetFramework property, and make sure it's covered in SupportedAspNetCoreAppVersions
using (DisposableDirectory directory = Temp.CreateDirectory())
{
string projectDirectory = directory.Path;
new NewCommandShim()
.WithWorkingDirectory(projectDirectory)
@ -191,7 +189,7 @@ namespace EndToEnd
.Should().Contain(targetFramework, $"the {nameof(SupportedAspNetCoreVersions)} should include the default version " +
"of Microsoft.AspNetCore.App used by the templates created by \"dotnet new web\"");
}
}
}

View file

@ -1,19 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<!-- Use this key because that's what Microsoft.DotNet.Cli.Utils is using for InternalsVisibleTo-->
<AssemblyOriginatorKeyFile>$(RepoRoot)eng\Key.snk</AssemblyOriginatorKeyFile>
<!-- Stop the arcade SDK from overriding the key -->
<StrongNameKeyId>Custom</StrongNameKeyId>
<PublicKey>0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb</PublicKey>
<PublicKeyToken>adb9793829ddae60</PublicKeyToken>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.DotNet.Cli.Utils" Version="$(MicrosoftDotNetCliUtilsPackageVersion)" />
</ItemGroup>
</Project>

View file

@ -1,6 +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.Reflection;
[assembly: AssemblyMetadataAttribute("Serviceable", "True")]

View file

@ -238,9 +238,6 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
psi.Environment[item.Key] = item.Value;
#endif
}
// Flow the TEST_PACKAGES environment variable to the child process
psi.Environment["TEST_PACKAGES"] = System.Environment.GetEnvironmentVariable("TEST_PACKAGES");
}
private void AddWorkingDirectoryTo(ProcessStartInfo psi)

View file

@ -25,16 +25,6 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
}
}
public static string WithBackwardsCompatibleRuntimes
{
get
{
return Path.Combine(
new RepoDirectoriesProvider().Stage2WithBackwardsCompatibleRuntimesDirectory,
"dotnet");
}
}
public static bool IsLocalized()
{
for (var culture = CultureInfo.CurrentUICulture; !culture.Equals(CultureInfo.InvariantCulture); culture = culture.Parent)

View file

@ -3,10 +3,6 @@
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Microsoft.DotNet.TestFramework\Microsoft.DotNet.TestFramework.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="FluentAssertions" Version="4.18.0" />
<PackageReference Include="xunit" Version="2.2.0" />

View file

@ -4,6 +4,7 @@
using System;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Xml.Linq;
using Microsoft.DotNet.PlatformAbstractions;
@ -11,27 +12,13 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
{
public class RepoDirectoriesProvider
{
private static string s_repoRoot;
private static string s_buildRid;
public readonly static string RepoRoot;
private string _artifacts;
private string _dotnetRoot;
private string _builtDotnet;
private string _nugetPackages;
private string _stage2Sdk;
private string _stage2WithBackwardsCompatibleRuntimesDirectory;
private string _testPackages;
private string _testWorkingFolder;
private string _testArtifactsFolder;
public readonly static string TestWorkingFolder;
public readonly static string DotnetUnderTest;
public static string RepoRoot
static RepoDirectoriesProvider()
{
get
{
if (!string.IsNullOrEmpty(s_repoRoot))
{
return s_repoRoot;
}
#if NET451
string directory = AppDomain.CurrentDomain.BaseDirectory;
@ -49,90 +36,30 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
directory = Directory.GetParent(directory)?.FullName;
}
if (directory == null)
RepoRoot = directory;
TestWorkingFolder = Environment.GetEnvironmentVariable("CORESDK_TEST_FOLDER");
if (string.IsNullOrEmpty(TestWorkingFolder))
{
throw new Exception("Cannot find the git repository root");
TestWorkingFolder = Path.Combine(AppContext.BaseDirectory, "Tests");
}
s_repoRoot = directory;
return s_repoRoot;
}
}
public static string BuildRid
DotnetUnderTest = Environment.GetEnvironmentVariable("DOTNET_UNDER_TEST");
string dotnetExtension = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ".exe" : "";
if (string.IsNullOrEmpty(DotnetUnderTest))
{
get
if (RepoRoot == null)
{
if (string.IsNullOrEmpty(s_buildRid))
DotnetUnderTest = "dotnet" + dotnetExtension;
}
else
{
var buildInfoPath = Path.Combine(RepoRoot, "bin", "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 DotnetRoot => _dotnetRoot;
public string NugetPackages => _nugetPackages;
public string Stage2Sdk => _stage2Sdk;
public string Stage2WithBackwardsCompatibleRuntimesDirectory => _stage2WithBackwardsCompatibleRuntimesDirectory;
public string TestPackages => _testPackages;
public string TestWorkingFolder => _testWorkingFolder;
public string TestArtifactsFolder => _testArtifactsFolder;
public RepoDirectoriesProvider(
string artifacts = null,
string builtDotnet = null,
string nugetPackages = null,
string corehostPackages = null,
string corehostDummyPackages = null)
{
// Ideally this wouldn't be hardcoded, so that you could use stage n to build stage n + 1, and then use stage n + 1 to run tests
int previousStage = 2;
_artifacts = artifacts ?? Path.Combine(RepoRoot,
"bin",
previousStage.ToString(),
BuildRid);
_builtDotnet = builtDotnet ?? Path.Combine(_artifacts, "intermediate", "sharedFrameworkPublish");
_dotnetRoot = Path.Combine(_artifacts, "dotnet");
_nugetPackages = nugetPackages ?? Path.Combine(RepoRoot, ".nuget", "packages");
_stage2Sdk = Directory
.EnumerateDirectories(Path.Combine(_artifacts, "dotnet", "sdk"))
.First(d => !d.Contains("NuGetFallbackFolder"));
_stage2WithBackwardsCompatibleRuntimesDirectory =
Path.Combine(_artifacts, "dotnetWithBackwardsCompatibleRuntimes");
_testPackages = Environment.GetEnvironmentVariable("TEST_PACKAGES");
if (string.IsNullOrEmpty(_testPackages))
{
_testPackages = Path.Combine(_artifacts, "test", "packages");
}
_testArtifactsFolder = Path.Combine(_artifacts, "test", "artifacts");
_testWorkingFolder = Path.Combine(RepoRoot,
"bin",
(previousStage + 1).ToString(),
BuildRid,
"test");
string configuration = new DirectoryInfo(AppContext.BaseDirectory).Parent.Name;
// TODO: Don't put in framework-specific folder (so we don't need to sync TFM here)
DotnetUnderTest = Path.Combine(RepoRoot, "artifacts", "bin", "redist", configuration, "netcoreapp3.0", "publish", "dotnet" + dotnetExtension);
}
}
}
}
}

View file

@ -12,6 +12,7 @@ using System.Threading.Tasks;
using System.Xml.Linq;
using Microsoft.DotNet.Cli.Utils;
using Microsoft.DotNet.Tools.Common;
using Microsoft.DotNet.Tools.Test.Utilities;
namespace Microsoft.DotNet.TestFramework
{
@ -29,8 +30,6 @@ namespace Microsoft.DotNet.TestFramework
private bool _built = false;
public static string CurrentRuntimeFrameworkVersion = new Muxer().SharedFxVersion;
public TestAssetInstance(TestAssetInfo testAssetInfo, DirectoryInfo root)
{
if (testAssetInfo == null)
@ -171,23 +170,6 @@ namespace Microsoft.DotNet.TestFramework
return this;
}
public TestAssetInstance UseCurrentRuntimeFrameworkVersion()
{
return WithProjectChanges(project =>
{
var ns = project.Root.Name.Namespace;
var propertyGroup = project.Root.Elements(ns + "PropertyGroup").LastOrDefault();
if (propertyGroup == null)
{
propertyGroup = new XElement(ns + "PropertyGroup");
project.Root.Add(propertyGroup);
}
propertyGroup.Add(new XElement(ns + "RuntimeFrameworkVersion", CurrentRuntimeFrameworkVersion));
});
}
private static string RebasePath(string path, string oldBaseDirectory, string newBaseDirectory)
{
path = Path.IsPathRooted(path) ? PathUtility.GetRelativePath(PathUtility.EnsureTrailingSlash(oldBaseDirectory), path) : path;
@ -285,18 +267,7 @@ namespace Microsoft.DotNet.TestFramework
.CaptureStdErr()
.Execute();
int exitCode = commandResult.ExitCode;
if (exitCode != 0)
{
Console.WriteLine(commandResult.StdOut);
Console.WriteLine(commandResult.StdErr);
string message = string.Format($"TestAsset Restore '{TestAssetInfo.AssetName}'@'{projectFile.FullName}' Failed with {exitCode}");
throw new Exception(message);
}
commandResult.Should().Pass();
}
private void RestoreAllProjects()

View file

@ -1,33 +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;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
using Microsoft.DotNet.Cli.Utils;
using Microsoft.DotNet.TestFramework;
using Microsoft.DotNet.Tools.Common;
namespace Microsoft.DotNet.Tools.Test.Utilities
{
public static class TestAssetInstanceExtensions
{
public static TestAssetInstance WithNuGetConfigAndExternalRestoreSources(
this TestAssetInstance testAssetInstance, string nugetCache)
{
var externalRestoreSourcesForTests = Path.Combine(
new RepoDirectoriesProvider().TestArtifactsFolder, "ExternalRestoreSourcesForTestsContainer.txt");
var externalRestoreSources = File.Exists(externalRestoreSourcesForTests) ?
File.ReadAllText(externalRestoreSourcesForTests) :
string.Empty;
return testAssetInstance.WithNuGetConfig(nugetCache, externalRestoreSources);
}
}
}

View file

@ -18,5 +18,7 @@ namespace Microsoft.DotNet.TestFramework
public static string TestProjects = "TestProjects";
public static string NonRestoredTestProjects = "NonRestoredTestProjects";
public static string TestPackages = "TestPackages";
}
}

View file

@ -64,7 +64,7 @@ namespace Microsoft.DotNet.TestFramework
this);
}
public DirectoryInfo CreateTestDirectory(string testProjectName = "temp", [CallerMemberName] string callingMethod = "", string identifier = "")
public DirectoryInfo CreateTestDirectory(string testProjectName = "", [CallerMemberName] string callingMethod = "", string identifier = "")
{
var testDestination = GetTestDestinationDirectoryPath(testProjectName, callingMethod, identifier);
@ -85,7 +85,12 @@ namespace Microsoft.DotNet.TestFramework
// Find the name of the assembly the test comes from based on the the base directory and how the output path has been constructed
string testAssemblyName = new DirectoryInfo(baseDirectory).Parent.Parent.Name;
return Path.Combine(_testWorkingFolder, testAssemblyName, callingMethod + identifier, testProjectName);
string directory = Path.Combine(_testWorkingFolder, testAssemblyName, callingMethod + identifier);
if (!string.IsNullOrEmpty(testProjectName))
{
directory = Path.Combine(directory, testProjectName);
}
return directory;
}
}
}

View file

@ -53,7 +53,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
s_testAssets = new TestAssets(
new DirectoryInfo(assetsRoot),
new FileInfo(new Muxer().MuxerPath),
new RepoDirectoriesProvider().TestWorkingFolder);
RepoDirectoriesProvider.TestWorkingFolder);
}
return s_testAssets;