Skip to content

Commit 6f727eb

Browse files
committed
Enable components tests on helix
Update Helix.targets Include more test assets Update Microsoft.AspNetCore.Components.E2ETests.csproj Switch to npm from yarn Cleanup Update InstallNode.ps1 Update ServerFixture.cs Fix test site path Update ServerFixture.cs Update ServerFixture.cs Update ServerFixture.cs Make directory match project name Deal with commas Update ServerFixture.cs Fix ref Rename back Remove copy Update package.json Fix files Update BasicTestApp.csproj
1 parent ab973d2 commit 6f727eb

File tree

15 files changed

+720
-788
lines changed

15 files changed

+720
-788
lines changed

eng/helix/content/InstallChrome.ps1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
$InstallerPath = "$env:Temp\chrome_installer.exe";
2+
Invoke-WebRequest "http://dl.google.com/chrome/install/375.126/chrome_installer.exe" -OutFile $InstallerPath;
3+
Start-Process -FilePath $InstallerPath -Args "/silent /install" -Verb RunAs -Wait;
4+
Remove-Item $InstallerPath

eng/helix/content/InstallJdk.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,4 @@ Remove-Item -Force -Recurse $tempDir -ErrorAction Ignore | out-null
5959

6060
if ($env:TF_BUILD) {
6161
Write-Host "##vso[task.prependpath]$installDir\bin"
62-
}
62+
}

eng/helix/content/InstallNode.ps1

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,17 @@
55
This script installs NodeJs from http://nodejs.org/dist on a machine.
66
.PARAMETER Version
77
The version of NodeJS to install.
8-
.PARAMETER InstallDir
9-
The directory to install NodeJS to.
108
.LINK
119
https://nodejs.org/en/
1210
#>
1311
param(
1412
[Parameter(Mandatory = $true)]
15-
$Version,
16-
17-
[Parameter(Mandatory = $true)]
18-
$InstallDir
13+
$Version
1914
)
2015

2116
$ErrorActionPreference = 'Stop'
2217
$ProgressPreference = 'SilentlyContinue' # Workaround PowerShell/PowerShell#2138
18+
$InstallDir = '.' # Use workload directory always
2319

2420
Set-StrictMode -Version 1
2521

@@ -59,9 +55,8 @@ else {
5955

6056
Write-Host "Expanded NodeJs"
6157
New-Item -Path "$InstallDir" -ItemType "directory" -Force
62-
Write-Host "Copying $tempDir\$nodeFile\node.exe to $InstallDir"
63-
Copy-Item "$tempDir\$nodeFile\node.exe" "$InstallDir\node.exe"
64-
58+
Write-Host "Copying $tempDir\$nodeFile\* to $InstallDir"
59+
Copy-Item "$tempDir\$nodeFile\*" "$InstallDir" -Recurse
6560
if (Test-Path "$InstallDir\node.exe")
6661
{
6762
Write-Host "Node.exe copied to $InstallDir"
@@ -70,3 +65,9 @@ else
7065
{
7166
Write-Host "Node.exe not copied to $InstallDir"
7267
}
68+
if (Test-Path "package-lock.json")
69+
{
70+
$Env:Path += ";" + $Env:HELIX_CORRELATION_PAYLOAD + "\jdk\bin"
71+
Write-Host "Found package-lock.json, running $InstallDir\npm install"
72+
Invoke-Expression "$InstallDir\npm.cmd install"
73+
}

eng/helix/content/installnode.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,7 @@ echo "Installing node from $(basename $url) $url"
3939
mkdir $output_dir
4040
echo "Unpacking to $output_dir"
4141
tar --strip-components 1 -xzf "node-v$node_version-$platformarch.tar.gz" --no-same-owner --directory "$output_dir"
42+
if [ -f "package-lock.json" ]; then
43+
echo "Found package-lock.json, running npm install"
44+
npm install
45+
fi

eng/targets/Helix.targets

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,18 @@
1313
</ItemGroup>
1414

1515
<ItemGroup Condition="'$(TestDependsOnNode)' == 'true' AND '$(IsWindowsHelixQueue)' == 'true'">
16-
<HelixPreCommand Include="call RunPowershell.cmd InstallNode.ps1 $(NodeVersion) %25HELIX_CORRELATION_PAYLOAD%25\node\bin || exit /b 1" />
16+
<HelixPreCommand Include="call RunPowershell.cmd InstallNode.ps1 $(NodeVersion) || exit /b 1" />
1717
</ItemGroup>
1818

1919
<ItemGroup Condition=" '$(TestDependsOnAspNetRuntime)' == 'true' ">
2020
<!-- Grab all shipping packages. -->
2121
<HelixContent Include="$(RepoRoot)artifacts\packages\$(Configuration)\Shipping\*$(SharedFxVersion).nupkg" />
2222
</ItemGroup>
2323

24+
<ItemGroup Condition="'$(TestDependsOnChrome)' == 'true' AND '$(IsWindowsHelixQueue)' == 'true'">
25+
<HelixPreCommand Include="call RunPowershell.cmd InstallChrome.ps1 || exit /b 1" />
26+
</ItemGroup>
27+
2428
<ItemGroup>
2529
<!-- Java test projects do not use xUnit. -->
2630
<HelixContent Include="$(OutputPath)Microsoft.VisualStudio.TestPlatform.Extension.Xunit.Xml.TestAdapter.dll"

src/Components/test/E2ETest/Infrastructure/ServerFixtures/ServerFixture.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,21 @@ private static Dictionary<string, string> FindProjects()
4949

5050
public static string FindSampleOrTestSitePath(string projectName)
5151
{
52+
if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("helix")))
53+
{
54+
var comma = projectName.IndexOf(",");
55+
if (comma != -1)
56+
{
57+
projectName = projectName.Substring(0, comma);
58+
}
59+
var path = Path.Combine(AppContext.BaseDirectory, projectName);
60+
if (!Directory.Exists(path))
61+
{
62+
throw new ArgumentException($"Cannot find a sample or test site directory: '{path}'.");
63+
}
64+
return path;
65+
}
66+
5267
var projects = _projects.Value;
5368
if (projects.TryGetValue(projectName, out var dir))
5469
{

src/Components/test/E2ETest/Microsoft.AspNetCore.Components.E2ETests.csproj

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,16 @@
77
<TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework>
88
<TestGroupName>Components.E2ETests</TestGroupName>
99

10-
<!-- https://github.com/dotnet/aspnetcore/issues/6857 -->
11-
<BuildHelixPayload>false</BuildHelixPayload>
12-
1310
<!-- Run on platforms where we support Selenium -->
1411
<SkipTests Condition="'$(SeleniumE2ETestsSupported)' != 'true'">true</SkipTests>
1512
<SkipTests Condition="'$(SeleniumE2ETestsSupported)' == 'true'">false</SkipTests>
1613

17-
<!-- Tests do not work on Helix or when bin/ directory is not in project directory due to undeclared dependency on test content. -->
18-
<BaseOutputPath />
19-
20-
<OutputPath />
21-
2214
<!-- This project references the shared framework transitively. Prevent restore errors by setting this flag. -->
2315
<GenerateErrorForMissingTargetingPacks>false</GenerateErrorForMissingTargetingPacks>
16+
17+
<TestDependsOnNode>true</TestDependsOnNode>
18+
<TestDependsOnJava>true</TestDependsOnJava>
19+
<TestDependsOnChrome>true</TestDependsOnChrome>
2420
</PropertyGroup>
2521

2622
<ItemGroup>
@@ -45,6 +41,16 @@
4541
<ProjectReference Include="..\..\WebAssembly\testassets\Wasm.Authentication.Server\Wasm.Authentication.Server.csproj" />
4642
</ItemGroup>
4743

44+
<ItemGroup>
45+
<HelixContent Include="package.json" />
46+
<HelixContent Include="package-lock.json" />
47+
<HelixContent Include="..\..\..\Shared\E2ETesting\selenium-config.json" />
48+
<HelixContent Include="..\testassets\**\*" />
49+
<HelixContent Include="..\..\Blazor\testassets\StandaloneApp\**\*" />
50+
<!-- This is currently windows only -->
51+
<HelixProjectPlatform Remove="Linux;OSX" />
52+
</ItemGroup>
53+
4854
<!-- Shared testing infrastructure for running E2E tests using selenium -->
4955
<Import Project="$(SharedSourceRoot)E2ETesting\E2ETesting.targets" />
5056

0 commit comments

Comments
 (0)