Skip to content

Commit 9a792f2

Browse files
authored
Reenable framework unit tests on helix (#19975)
1 parent 7946b91 commit 9a792f2

File tree

9 files changed

+89
-14
lines changed

9 files changed

+89
-14
lines changed

eng/helix/content/InstallAppRuntime.ps1

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ $ProgressPreference = 'SilentlyContinue' # Workaround PowerShell/PowerShell#2138
3030

3131
Set-StrictMode -Version 1
3232

33-
Write-Host "Extracting to $InstallDir"
34-
3533
$zipPackage = [io.path]::ChangeExtension($AppRuntimePath, ".zip")
3634
Write-Host "Renaming to $zipPackage"
3735
Rename-Item -Path $AppRuntimePath -NewName $zipPackage
@@ -46,8 +44,9 @@ else {
4644
[System.IO.Compression.ZipFile]::ExtractToDirectory($zipPackage, ".\tmpRuntime")
4745
}
4846

49-
Get-ChildItem -Path ".\tmpRuntime" -Recurse
50-
47+
New-Item -ItemType Directory -Force -Path $InstallDir
48+
Write-Host "Copying *.txt to $InstallDir"
49+
Copy-Item -Path ".\tmpRuntime\*.txt" $InstallDir
5150
Write-Host "Copying managed files to $InstallDir"
5251
Copy-Item -Path ".\tmpRuntime\runtimes\$RuntimeIdentifier\lib\$Framework\*" $InstallDir
5352
Write-Host "Copying native files to $InstallDir"
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<#
2+
.SYNOPSIS
3+
Unzips an AspNetCore.App.Ref nupkg
4+
.DESCRIPTION
5+
This script unzips an AspNetCore.App.Ref nupkg
6+
.PARAMETER RefPath
7+
The path to the AspNetCore.App.Ref package to install.
8+
.PARAMETER InstallDir
9+
The directory to install to.
10+
#>
11+
param(
12+
[Parameter(Mandatory = $true)]
13+
$RefPath,
14+
15+
[Parameter(Mandatory = $true)]
16+
$InstallDir
17+
)
18+
19+
$ErrorActionPreference = 'Stop'
20+
$ProgressPreference = 'SilentlyContinue' # Workaround PowerShell/PowerShell#2138
21+
22+
Set-StrictMode -Version 1
23+
24+
Write-Host "Extracting to $InstallDir"
25+
26+
$zipPackage = [io.path]::ChangeExtension($RefPath, ".zip")
27+
Write-Host "Renaming to $zipPackage"
28+
Rename-Item -Path $RefPath -NewName $zipPackage
29+
if (Get-Command -Name 'Microsoft.PowerShell.Archive\Expand-Archive' -ErrorAction Ignore) {
30+
# Use built-in commands where possible as they are cross-plat compatible
31+
Microsoft.PowerShell.Archive\Expand-Archive -Path $zipPackage -DestinationPath "$InstallDir" -Force
32+
}
33+
else {
34+
Remove-Item "$InstallDir" -Recurse -ErrorAction Ignore
35+
# Fallback to old approach for old installations of PowerShell
36+
Add-Type -AssemblyName System.IO.Compression.FileSystem
37+
[System.IO.Compression.ZipFile]::ExtractToDirectory($zipPackage, "$InstallDir")
38+
}
39+
40+
Get-ChildItem -Path "$InstallDir" -Recurse

eng/helix/content/RunTests/TestRunner.cs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,25 +65,25 @@ public bool SetupEnvironment()
6565
}
6666
}
6767

68-
public void DisplayContents()
68+
public void DisplayContents(string path = "./")
6969
{
7070
try
7171
{
7272
Console.WriteLine();
73-
Console.WriteLine("Displaying directory contents:");
74-
foreach (var file in Directory.EnumerateFiles("./"))
73+
Console.WriteLine($"Displaying directory contents for {path}:");
74+
foreach (var file in Directory.EnumerateFiles(path))
7575
{
7676
Console.WriteLine(Path.GetFileName(file));
7777
}
78-
foreach (var file in Directory.EnumerateDirectories("./"))
78+
foreach (var file in Directory.EnumerateDirectories(path))
7979
{
8080
Console.WriteLine(Path.GetFileName(file));
8181
}
8282
Console.WriteLine();
8383
}
8484
catch (Exception e)
8585
{
86-
Console.WriteLine($"Exception in DisplayInitialState: {e.ToString()}");
86+
Console.WriteLine($"Exception in DisplayContents: {e.ToString()}");
8787
}
8888
}
8989

@@ -95,11 +95,17 @@ public async Task<bool> InstallAspNetAppIfNeededAsync()
9595
if (Directory.Exists("Microsoft.AspNetCore.App"))
9696
{
9797
var appRuntimePath = $"{Options.DotnetRoot}/shared/Microsoft.AspNetCore.App/{Options.RuntimeVersion}";
98+
Console.WriteLine($"Creating directory: {appRuntimePath}");
99+
Directory.CreateDirectory(appRuntimePath);
98100
Console.WriteLine($"Found Microsoft.AspNetCore.App/, copying to {appRuntimePath}");
101+
Console.WriteLine($"Set ASPNET_RUNTIME_PATH: {appRuntimePath}");
102+
EnvironmentVariables.Add("ASPNET_RUNTIME_PATH", appRuntimePath);
99103
foreach (var file in Directory.EnumerateFiles("Microsoft.AspNetCore.App", "*.*", SearchOption.AllDirectories))
100104
{
101-
File.Copy(file, Path.Combine(appRuntimePath, file), overwrite: true);
105+
File.Copy(file, Path.Combine(appRuntimePath, Path.GetFileName(file)), overwrite: true);
102106
}
107+
108+
DisplayContents(appRuntimePath);
103109

104110
Console.WriteLine($"Adding current directory to nuget sources: {Options.HELIX_WORKITEM_ROOT}");
105111

eng/helix/content/installappruntime.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@ mkdir -p $tmpDir
1616
unzip sharedFx.zip -d $tmpDir
1717
mkdir -p $output_dir
1818
echo "Copying to $output_dir"
19+
cp $tmpDir/*.txt $output_dir
1920
cp $tmpDir/runtimes/$rid/lib/$framework/* $output_dir
2021
cp $tmpDir/runtimes/$rid/native/* $output_dir

eng/helix/content/installaspnetref.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env bash
2+
3+
# Cause the script to fail if any subcommand fails
4+
set -e
5+
6+
refPath=$1
7+
output_dir=$2
8+
tmpDir=./tmpRuntime
9+
10+
echo "Installing ref package from $refPath"
11+
cp $refPath sharedFx.zip
12+
13+
mkdir -p $output_dir
14+
echo "Unzip to $output_dir"
15+
unzip sharedFx.zip -d $output_dir

eng/targets/Helix.targets

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@
1616
<HelixPreCommand Include="call RunPowershell.cmd InstallNode.ps1 $(NodeVersion) %25HELIX_CORRELATION_PAYLOAD%25\node\bin || exit /b 1" />
1717
</ItemGroup>
1818

19+
<ItemGroup Condition="'$(IsHelixJob)' == 'true' AND '$(IsWindowsHelixQueue)' == 'true' AND '$(TestDependsOnAspNetRef)' == 'true' AND '$(IsTargetingPackBuilding)' == 'true'">
20+
<HelixContent Include="$(RepoRoot)artifacts\packages\Release\Shipping\Microsoft.AspNetCore.App.Ref.$(AppRuntimeVersion).nupkg" />
21+
<HelixPreCommand Include="call RunPowershell.cmd InstallAspNetRef.ps1 Microsoft.AspNetCore.App.Ref.$(AppRuntimeVersion).nupkg Microsoft.AspNetCore.App.Ref || exit /b 1" />
22+
</ItemGroup>
23+
24+
<ItemGroup Condition="'$(IsHelixJob)' == 'true' AND '$(IsWindowsHelixQueue)' == 'false' AND '$(TestDependsOnAspNetRef)' == 'true' AND '$(IsTargetingPackBuilding)' == 'true'">
25+
<HelixContent Include="$(RepoRoot)artifacts\packages\Release\Shipping\Microsoft.AspNetCore.App.Ref.$(AppRuntimeVersion).nupkg" />
26+
<HelixPreCommand Include="./installaspnetref.sh Microsoft.AspNetCore.App.Ref.$(AppRuntimeVersion).nupkg Microsoft.AspNetCore.App.Ref || exit /b 1" />
27+
</ItemGroup>
28+
1929
<ItemGroup Condition="'$(IsHelixJob)' == 'true' AND '$(IsWindowsHelixQueue)' == 'true' AND '$(TestDependsOnAspNetRuntime)' == 'true'">
2030
<HelixContent Include="$(RepoRoot)artifacts\packages\Release\Shipping\Microsoft.AspNetCore.App.Runtime.win-x64.$(AppRuntimeVersion).nupkg" />
2131
<HelixPreCommand Include="call RunPowershell.cmd InstallAppRuntime.ps1 Microsoft.AspNetCore.App.Runtime.win-x64.$(AppRuntimeVersion).nupkg Microsoft.AspNetCore.App netcoreapp5.0 win-x64 || exit /b 1" />

src/Framework/test/Microsoft.AspNetCore.App.UnitTests.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
<PropertyGroup>
44
<TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework>
55
<RootNamespace>Microsoft.AspNetCore</RootNamespace>
6-
<!-- https://github.com/dotnet/aspnetcore/issues/7939: This unit test requires the shared framework be available in Helix. -->
7-
<BuildHelixPayload>false</BuildHelixPayload>
86
<VerifyAncmBinary Condition="'$(TargetOsName)' == 'win' AND '$(TargetArchitecture)' != 'arm'">true</VerifyAncmBinary>
7+
<TestDependsOnAspNetRuntime>true</TestDependsOnAspNetRuntime>
8+
<TestDependsOnAspNetRef>true</TestDependsOnAspNetRef>
99
</PropertyGroup>
1010

1111
<ItemGroup>

src/Framework/test/SharedFxTests.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ public SharedFxTests(ITestOutputHelper output)
2323
_output = output;
2424
_expectedTfm = "netcoreapp" + TestData.GetSharedFxVersion().Substring(0, 3);
2525
_expectedRid = TestData.GetSharedFxRuntimeIdentifier();
26-
_sharedFxRoot = Path.Combine(TestData.GetTestDataValue("SharedFrameworkLayoutRoot"), "shared", "Microsoft.AspNetCore.App", TestData.GetTestDataValue("RuntimePackageVersion"));
26+
_sharedFxRoot = string.IsNullOrEmpty(Environment.GetEnvironmentVariable("ASPNET_RUNTIME_PATH"))
27+
? Path.Combine(TestData.GetTestDataValue("SharedFrameworkLayoutRoot"), "shared", TestData.GetTestDataValue("RuntimePackageVersion"))
28+
: Environment.GetEnvironmentVariable("ASPNET_RUNTIME_PATH");
2729
}
2830

2931
[Fact]

src/Framework/test/TargetingPackTests.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ public TargetingPackTests(ITestOutputHelper output)
2626
{
2727
_output = output;
2828
_expectedRid = TestData.GetSharedFxRuntimeIdentifier();
29-
_targetingPackRoot = Path.Combine(TestData.GetTestDataValue("TargetingPackLayoutRoot"), "packs", "Microsoft.AspNetCore.App.Ref", TestData.GetTestDataValue("TargetingPackVersion"));
29+
_targetingPackRoot = string.IsNullOrEmpty(Environment.GetEnvironmentVariable("helix"))
30+
? Path.Combine(TestData.GetTestDataValue("TargetingPackLayoutRoot"), "packs", "Microsoft.AspNetCore.App.Ref", TestData.GetTestDataValue("TargetingPackVersion"))
31+
: Path.Combine(Environment.GetEnvironmentVariable("HELIX_WORKITEM_ROOT"), "Microsoft.AspNetCore.App.Ref");
3032
_isTargetingPackBuilding = bool.Parse(TestData.GetTestDataValue("IsTargetingPackBuilding"));
3133
}
3234

0 commit comments

Comments
 (0)