Skip to content

Add bundle tests that don't use the SDK #60058

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions eng/Subsets.props
Original file line number Diff line number Diff line change
Expand Up @@ -307,11 +307,11 @@

<!-- Host.tests subset (consumes live built libraries assets so needs to come after libraries) -->
<ItemGroup Condition="$(_subset.Contains('+host.tests+'))">
<TestProjectToBuild Include="$(InstallerProjectRoot)tests\Microsoft.NET.HostModel.Tests\AppHost.Bundle.Tests\AppHost.Bundle.Tests.csproj" />
<TestProjectToBuild Include="$(InstallerProjectRoot)tests\Microsoft.NET.HostModel.Tests\Microsoft.NET.HostModel.AppHost.Tests\Microsoft.NET.HostModel.AppHost.Tests.csproj" />
<TestProjectToBuild Include="$(InstallerProjectRoot)tests\Microsoft.NET.HostModel.Tests\Microsoft.NET.HostModel.Bundle.Tests\Microsoft.NET.HostModel.Bundle.Tests.csproj" />
<TestProjectToBuild Include="$(InstallerProjectRoot)tests\Microsoft.NET.HostModel.Tests\Microsoft.NET.HostModel.ComHost.Tests\Microsoft.NET.HostModel.ComHost.Tests.csproj" />
<TestProjectToBuild Include="$(InstallerProjectRoot)tests\HostActivation.Tests\HostActivation.Tests.csproj" />
<TestProjectToBuild Include="$(InstallerProjectRoot)tests\integration\Microsoft.NET.HostModel.Tests\AppHost.Bundle.Tests\AppHost.Bundle.Tests.csproj" />
<TestProjectToBuild Include="$(InstallerProjectRoot)tests\integration\Microsoft.NET.HostModel.Tests\Microsoft.NET.HostModel.AppHost.Tests\Microsoft.NET.HostModel.AppHost.Tests.csproj" />
<TestProjectToBuild Include="$(InstallerProjectRoot)tests\integration\Microsoft.NET.HostModel.Tests\Microsoft.NET.HostModel.Bundle.Tests\Microsoft.NET.HostModel.Bundle.Tests.csproj" />
<TestProjectToBuild Include="$(InstallerProjectRoot)tests\integration\Microsoft.NET.HostModel.Tests\Microsoft.NET.HostModel.ComHost.Tests\Microsoft.NET.HostModel.ComHost.Tests.csproj" />
<TestProjectToBuild Include="$(InstallerProjectRoot)tests\integration\HostActivation.Tests\HostActivation.Tests.csproj" />
<ProjectToBuild Include="@(TestProjectToBuild)" BuildInParallel="true" Test="true" Category="host" />
</ItemGroup>

Expand Down Expand Up @@ -347,7 +347,7 @@
</ItemGroup>

<ItemGroup Condition="$(_subset.Contains('+packs.tests+')) AND '$(PgoInstrument)' != 'true'">
<TestProjectToBuild Include="$(InstallerProjectRoot)tests\Microsoft.DotNet.CoreSetup.Packaging.Tests\Microsoft.DotNet.CoreSetup.Packaging.Tests.csproj" />
<TestProjectToBuild Include="$(InstallerProjectRoot)tests\integration\Microsoft.DotNet.CoreSetup.Packaging.Tests\Microsoft.DotNet.CoreSetup.Packaging.Tests.csproj" />
<ProjectToBuild Include="@(TestProjectToBuild)" BuildInParallel="true" Test="true" Category="packs" />
</ItemGroup>

Expand Down
257 changes: 137 additions & 120 deletions src/installer/Microsoft.DotNet.CoreSetup.sln

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public static string GenerateBundle(Bundler bundler, string sourceDir, string ou
// Bundle to a single-file
// In several tests, the single-file bundle is created explicitly using Bundle API
// instead of the SDK via /p:PublishSingleFile=true.
// This is necessary when the test needs the latest changes in the AppHost,
// This is necessary when the test needs the latest changes in the AppHost,
// which may not (yet) be available in the SDK.
public static Bundler BundleApp(TestProjectFixture fixture,
out string singleFile,
Expand Down Expand Up @@ -216,13 +216,13 @@ public static Bundler Bundle(TestProjectFixture fixture, BundleOptions options =
return BundleApp(fixture, out singleFile, options, copyExcludedFiles:false);
}

public static void AddLongNameContentToAppWithSubDirs(TestProjectFixture fixture)
public static void AddLongNameContentToAppWithSubDirs(string projectDirectory)
{
// For tests using the AppWithSubDirs, One of the sub-directories with a really long name
// is generated during test-runs rather than being checked in as a test asset.
// This prevents git-clone of the repo from failing if long-file-name support is not enabled on windows.
var longDirName = "This is a really, really, really, really, really, really, really, really, really, really, really, really, really, really long file name for punctuation";
var longDirPath = Path.Combine(fixture.TestProject.ProjectDirectory, "Sentence", longDirName);
var longDirPath = Path.Combine(projectDirectory, "Sentence", longDirName);
Directory.CreateDirectory(longDirPath);
using (var writer = File.CreateText(Path.Combine(longDirPath, "word")))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\TestUtils\TestUtils.csproj" />
<ProjectReference Include="..\..\..\managed\Microsoft.NET.HostModel\Microsoft.NET.HostModel.csproj" />
<ProjectReference Include="..\TestUtils\TestUtils.csproj" />
<ProjectReference Include="..\..\managed\Microsoft.NET.HostModel\Microsoft.NET.HostModel.csproj" />
</ItemGroup>

</Project>
6 changes: 5 additions & 1 deletion src/installer/tests/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<PropertyGroup>
<TestDir>$(InstallerProjectRoot)tests\</TestDir>
<TestAssetsDir>$(TestDir)Assets\</TestAssetsDir>
<TestAssetsDir>$(TestDir)integration\Assets\</TestAssetsDir>
<TestStabilizedLegacyPackagesDir>$(ArtifactsObjDir)TestStabilizedPackages\</TestStabilizedLegacyPackagesDir>
<TestRestorePackagesPath>$(ArtifactsObjDir)TestPackageCache\</TestRestorePackagesPath>
<TestRestoreNuGetConfigFile>$(ArtifactsObjDir)TestNuGetConfig\NuGet.config</TestRestoreNuGetConfigFile>
Expand All @@ -12,6 +12,10 @@
<TestInfraTargetFramework>$(NetCoreAppToolCurrent)</TestInfraTargetFramework>
<TestRunnerAdditionalArguments>-notrait category=failing</TestRunnerAdditionalArguments>
<RunAnalyzers>false</RunAnalyzers>
<TestRuntimeVersion>$(NetCoreAppCurrent)-$(TargetOS)-$(Configuration)-$(TargetArchitecture)</TestRuntimeVersion>
<TestHostPath>$([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'testhost', '$(TestRuntimeVersion)'))</TestHostPath>
<RuntimePackPath>$([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'runtime', '$(TestRuntimeVersion)'))</RuntimePackPath>
<CoreClrPath>$([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'coreclr', '$(TargetOs).$(TargetArchitecture).$(Configuration)'))</CoreClrPath>
</PropertyGroup>

</Project>
52 changes: 4 additions & 48 deletions src/installer/tests/Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -1,39 +1,8 @@
<Project>

<Target Name="RefreshProjectTestAssets"
Condition="'$(UsesTestAssets)' == 'true' and '$(SkipTests)' != 'true'"
DependsOnTargets="DetermineTestOutputDirectory"
BeforeTargets="RunTests">
<!-- Build PrepareTestAssets once for all tests. -->
<MSBuild
Projects="$(TestDir)PrepareTestAssets\PrepareTestAssets.proj"
Targets="PrepareTestAssets" />

<!--
Set up the shared framework copy this set of tests should use. There's no known reason to have
one per test project, but RepoDirectoriesProvider may need some tweaking to share.
-->
<MSBuild Projects="$(InstallerProjectRoot)pkg\sfx\bundle\Microsoft.NETCore.App.Bundle.bundleproj"
Targets="PublishToDisk"
Properties="OutputPath=$(TestsOutputDir)sharedFrameworkPublish/" />

<!-- Create files with a name that describes what a test dir is. Useful if path abbreviated. -->
<WriteLinesToFile
File="$(TestsOutputRootDir)$(TestsOutputName)-is-$(MSBuildProjectName).txt"
Overwrite="true"
Lines="$(MSBuildProjectName) intermediates are located in '$(TestsOutputName)'. Abbreviated to work around path limits on Windows."
Condition="'$(TestsOutputName)' != '$(MSBuildProjectName)'" />
<WriteLinesToFile
File="$(TestsOutputDir)$(MSBuildProjectName).txt"
Overwrite="true"
Lines="$(MSBuildProjectName) intermediates are located in '$(TestsOutputName)'. Abbreviated to work around path limits on Windows."
Condition="'$(TestsOutputName)' != '$(MSBuildProjectName)'" />
</Target>

<Target Name="SetupTestContextVariables"
DependsOnTargets="
GetProductVersions;
GetNETCoreAppRuntimePackVersion;
DetermineTestOutputDirectory"
BeforeTargets="Build">
<PropertyGroup>
Expand Down Expand Up @@ -73,13 +42,16 @@
<TestContextVariable Include="NUGET_PACKAGES=$(TestRestorePackagesPath)" />
<TestContextVariable Include="TEST_ARTIFACTS=$(SystemPathTestsOutputDir)" />
<TestContextVariable Include="TEST_TARGETRID=$(TestTargetRid)" />
<TestContextVariable Include="TESTHOST_PATH=$(TestHostPath)" />
<TestContextVariable Include="RUNTIME_PACK_PATH=$(RuntimePackPath)" />
<TestContextVariable Include="CORECLR_ARTIFACTS_PATH=$(CoreClrPath)" />
<TestContextVariable Include="BUILDRID=$(OutputRid)" />
<TestContextVariable Include="BUILD_ARCHITECTURE=$(TargetArchitecture)" />
<TestContextVariable Include="BUILD_CONFIGURATION=$(Configuration)" />
<TestContextVariable Include="MNA_VERSION=$(NETCoreAppRuntimePackageVersion)" />
<TestContextVariable Include="MNA_TFM=$(NetCoreAppCurrent)" />
<TestContextVariable Include="DOTNET_SDK_PATH=$(DotNetRoot)" />
<TestContextVariable Include="TEST_ASSETS=$(MSBuildThisFileDirectory)Assets" />
<TestContextVariable Include="TEST_ASSETS=$(TestAssetsDir)" />
</ItemGroup>

<WriteLinesToFile
Expand All @@ -88,22 +60,6 @@
Lines="@(TestContextVariable)" />
</Target>

<!--
Fetch the package version of 'Microsoft.NETCore.App.Runtime.<rid>'. The runtime nupkg project
always ships, so it may or may not have a stable version depending on product lifecycle.

Some test projects end in ".Tests", which Arcade detects and applies IsShipping=false. This
makes ProductVersion non-stable, so we can't rely on the test project's ProductVersion to be the
same as the package's version. Fetch this directly from the project to avoid guesswork.
-->
<Target Name="GetNETCoreAppRuntimePackVersion">
<MSBuild
Projects="$(InstallerProjectRoot)pkg\sfx\Microsoft.NETCore.App\Microsoft.NETCore.App.Runtime.sfxproj"
Targets="ReturnProductVersion">
<Output TaskParameter="TargetOutputs" PropertyName="NETCoreAppRuntimePackVersion" />
</MSBuild>
</Target>

<Target Name="DetermineTestOutputDirectory">
<PropertyGroup>
<TestTargetRid Condition="'$(TestTargetRid)' == ''">$(PackageRID)</TestTargetRid>
Expand Down
16 changes: 14 additions & 2 deletions src/installer/tests/TestUtils/RepoDirectoriesProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,14 @@

namespace Microsoft.DotNet.CoreSetup.Test
{
public class RepoDirectoriesProvider
public sealed class RepoDirectoriesProvider
{
public static readonly RepoDirectoriesProvider Default = new RepoDirectoriesProvider();

public string Tfm { get; }
public string RuntimePackPath { get; }
public string CoreClrPath { get; }
public string TestHostPath { get; }
public string BuildRID { get; }
public string BuildArchitecture { get; }
public string TargetRID { get; }
Expand All @@ -22,6 +28,7 @@ public class RepoDirectoriesProvider
public string BuiltDotnet { get; }
public string NugetPackages { get; }
public string DotnetSDK { get; }
public string TestArtifacts { get; }

private string _testContextVariableFilePath { get; }
private ImmutableDictionary<string, string> _testContextVariables { get; }
Expand All @@ -43,6 +50,10 @@ public RepoDirectoriesProvider(
line => line.Substring(line.IndexOf('=') + 1),
StringComparer.OrdinalIgnoreCase);

Tfm = GetTestContextVariable("MNA_TFM");
RuntimePackPath = GetTestContextVariable("RUNTIME_PACK_PATH");
CoreClrPath = GetTestContextVariable("CORECLR_ARTIFACTS_PATH");
TestHostPath = GetTestContextVariable("TESTHOST_PATH");
TargetRID = GetTestContextVariable("TEST_TARGETRID");
BuildRID = GetTestContextVariable("BUILDRID");
BuildArchitecture = GetTestContextVariable("BUILD_ARCHITECTURE");
Expand All @@ -63,7 +74,8 @@ public RepoDirectoriesProvider(

NugetPackages = GetTestContextVariable("NUGET_PACKAGES") ?? Path.Combine(RepoRoot, ".packages");

BuiltDotnet = builtDotnet ?? Path.Combine(GetTestContextVariable("TEST_ARTIFACTS"), "sharedFrameworkPublish");
TestArtifacts = GetTestContextVariable("TEST_ARTIFACTS");
BuiltDotnet = builtDotnet ?? Path.Combine(TestArtifacts, "sharedFrameworkPublish");
}

public string GetTestContextVariable(string name)
Expand Down
2 changes: 1 addition & 1 deletion src/installer/tests/TestUtils/TestArtifact.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ protected static string GetNewTestArtifactPath(string artifactName)
throw lastException;
}

protected static void CopyRecursive(string sourceDirectory, string destinationDirectory, bool overwrite = false)
public static void CopyRecursive(string sourceDirectory, string destinationDirectory, bool overwrite = false)
{
FileUtils.EnsureDirectoryExists(destinationDirectory);

Expand Down
4 changes: 4 additions & 0 deletions src/installer/tests/integration/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<Project>
<Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.props, $(MSBuildThisFileDirectory)..))" />

</Project>
51 changes: 51 additions & 0 deletions src/installer/tests/integration/Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<Project>

<Target Name="RefreshProjectTestAssets"
Condition="'$(UsesTestAssets)' == 'true' and '$(SkipTests)' != 'true'"
DependsOnTargets="DetermineTestOutputDirectory"
BeforeTargets="RunTests">
<!-- Build PrepareTestAssets once for all tests. -->
<MSBuild
Projects="$(TestDir)integration\PrepareTestAssets\PrepareTestAssets.proj"
Targets="PrepareTestAssets" />

<!--
Set up the shared framework copy this set of tests should use. There's no known reason to have
one per test project, but RepoDirectoriesProvider may need some tweaking to share.
-->
<MSBuild Projects="$(InstallerProjectRoot)pkg\sfx\bundle\Microsoft.NETCore.App.Bundle.bundleproj"
Targets="PublishToDisk"
Properties="OutputPath=$(TestsOutputDir)sharedFrameworkPublish/" />

<!-- Create files with a name that describes what a test dir is. Useful if path abbreviated. -->
<WriteLinesToFile
File="$(TestsOutputRootDir)$(TestsOutputName)-is-$(MSBuildProjectName).txt"
Overwrite="true"
Lines="$(MSBuildProjectName) intermediates are located in '$(TestsOutputName)'. Abbreviated to work around path limits on Windows."
Condition="'$(TestsOutputName)' != '$(MSBuildProjectName)'" />
<WriteLinesToFile
File="$(TestsOutputDir)$(MSBuildProjectName).txt"
Overwrite="true"
Lines="$(MSBuildProjectName) intermediates are located in '$(TestsOutputName)'. Abbreviated to work around path limits on Windows."
Condition="'$(TestsOutputName)' != '$(MSBuildProjectName)'" />
</Target>

<!--
Fetch the package version of 'Microsoft.NETCore.App.Runtime.<rid>'. The runtime nupkg project
always ships, so it may or may not have a stable version depending on product lifecycle.

Some test projects end in ".Tests", which Arcade detects and applies IsShipping=false. This
makes ProductVersion non-stable, so we can't rely on the test project's ProductVersion to be the
same as the package's version. Fetch this directly from the project to avoid guesswork.
-->
<Target Name="GetNETCoreAppRuntimePackVersion"
BeforeTargets="Build">
<MSBuild
Projects="$(InstallerProjectRoot)pkg\sfx\Microsoft.NETCore.App\Microsoft.NETCore.App.Runtime.sfxproj"
Targets="ReturnProductVersion">
<Output TaskParameter="TargetOutputs" PropertyName="NETCoreAppRuntimePackVersion" />
</MSBuild>
</Target>

<Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.targets, $(MSBuildThisFileDirectory)..))" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
<TestsOutputName>ha</TestsOutputName>
<UsesTestAssets>true</UsesTestAssets>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\TestUtils\TestUtils.csproj" />
<ProjectReference Include="..\..\managed\Microsoft.NET.HostModel\Microsoft.NET.HostModel.csproj" />
<ProjectReference Include="..\..\TestUtils\TestUtils.csproj" />
<ProjectReference Include="..\..\..\managed\Microsoft.NET.HostModel\Microsoft.NET.HostModel.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\TestUtils\TestUtils.csproj" />
<ProjectReference Include="..\..\TestUtils\TestUtils.csproj" />
<OrderProjectReference Include="@(PkgprojProjectToBuild)" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\TestUtils\TestUtils.csproj" />
<ProjectReference Include="..\..\..\managed\Microsoft.NET.HostModel\Microsoft.NET.HostModel.csproj" />
<ProjectReference Include="..\Helpers\BundleHelper.csproj" />
<ProjectReference Include="..\..\..\TestUtils\TestUtils.csproj" />
<ProjectReference Include="..\..\..\..\managed\Microsoft.NET.HostModel\Microsoft.NET.HostModel.csproj" />
<ProjectReference Include="..\..\..\BundleHelper\BundleHelper.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -201,30 +201,30 @@ public class SharedTestState : SharedTestStateBase, IDisposable
public SharedTestState()
{
TestFrameworkDependentFixture = new TestProjectFixture("AppWithSubDirs", RepoDirectories);
BundleHelper.AddLongNameContentToAppWithSubDirs(TestFrameworkDependentFixture);
BundleHelper.AddLongNameContentToAppWithSubDirs(TestFrameworkDependentFixture.TestProject.ProjectDirectory);
TestFrameworkDependentFixture
.EnsureRestoredForRid(TestFrameworkDependentFixture.CurrentRid)
.PublishProject(runtime: TestFrameworkDependentFixture.CurrentRid,
selfContained: false,
outputDirectory: BundleHelper.GetPublishPath(TestFrameworkDependentFixture));

TestSelfContainedFixture = new TestProjectFixture("AppWithSubDirs", RepoDirectories);
BundleHelper.AddLongNameContentToAppWithSubDirs(TestSelfContainedFixture);
BundleHelper.AddLongNameContentToAppWithSubDirs(TestSelfContainedFixture.TestProject.ProjectDirectory);
TestSelfContainedFixture
.EnsureRestoredForRid(TestSelfContainedFixture.CurrentRid)
.PublishProject(runtime: TestSelfContainedFixture.CurrentRid,
outputDirectory: BundleHelper.GetPublishPath(TestSelfContainedFixture));

TestAppWithEmptyFileFixture = new TestProjectFixture("AppWithSubDirs", RepoDirectories);
BundleHelper.AddLongNameContentToAppWithSubDirs(TestAppWithEmptyFileFixture);
BundleHelper.AddLongNameContentToAppWithSubDirs(TestAppWithEmptyFileFixture.TestProject.ProjectDirectory);
BundleHelper.AddEmptyContentToApp(TestAppWithEmptyFileFixture);
TestAppWithEmptyFileFixture
.EnsureRestoredForRid(TestAppWithEmptyFileFixture.CurrentRid)
.PublishProject(runtime: TestAppWithEmptyFileFixture.CurrentRid,
outputDirectory: BundleHelper.GetPublishPath(TestAppWithEmptyFileFixture));

TestSelfContainedFixtureComposite = new TestProjectFixture("AppWithSubDirs", RepoDirectories);
BundleHelper.AddLongNameContentToAppWithSubDirs(TestSelfContainedFixtureComposite);
BundleHelper.AddLongNameContentToAppWithSubDirs(TestSelfContainedFixtureComposite.TestProject.ProjectDirectory);
TestSelfContainedFixtureComposite
.EnsureRestoredForRid(TestSelfContainedFixtureComposite.CurrentRid)
.PublishProject(runtime: TestSelfContainedFixtureComposite.CurrentRid,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\TestUtils\TestUtils.csproj" />
<ProjectReference Include="..\..\..\managed\Microsoft.NET.HostModel\Microsoft.NET.HostModel.csproj" />
<ProjectReference Include="..\..\..\TestUtils\TestUtils.csproj" />
<ProjectReference Include="..\..\..\..\managed\Microsoft.NET.HostModel\Microsoft.NET.HostModel.csproj" />
</ItemGroup>

</Project>
Loading