Skip to content
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

The Ahead of time tests are not correctly propagating the failure. #17132

Merged
merged 7 commits into from
May 14, 2024
Merged
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
2 changes: 1 addition & 1 deletion azure-pipelines-PR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,7 @@ stages:
env:
NativeToolsOnMachine: true
displayName: Initial build and prepare packages.
- script: $(Build.SourcesDirectory)/tests/AheadOfTime/check.cmd
- powershell: $(Build.SourcesDirectory)/tests/AheadOfTime/check.ps1
displayName: Build, trim, publish and check the state of the trimmed app.
workingDirectory: $(Build.SourcesDirectory)/tests/AheadOfTime
- task: PublishPipelineArtifact@1
Expand Down
2 changes: 1 addition & 1 deletion eng/Build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ try {

if ($testAOT) {
Push-Location "$RepoRoot\tests\AheadOfTime"
./check.cmd
./check.ps1
Pop-Location
}

Expand Down
13 changes: 7 additions & 6 deletions tests/AheadOfTime/Equality/check.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,18 @@ $process = Start-Process `
-PassThru `
-RedirectStandardOutput $(Join-Path $PSScriptRoot output.txt)

# Checking that the test passed
$output = Get-Content $(Join-Path $PSScriptRoot output.txt)

# Checking that it is actually running.
$expected = "All tests passed"
if ($LASTEXITCODE -ne 0)
{
Write-Error "Test failed with exit code ${LASTEXITCODE}" -ErrorAction Stop
}

# Checking that the output is as expected.
$expected = "All tests passed"
if ($output -ne $expected)
if ($output -eq $expected)
{
Write-Host "Test passed"
}
else
{
Write-Error "Test failed with unexpected output:`nExpected:`n`t${expected}`nActual`n`t${output}" -ErrorAction Stop
}
27 changes: 15 additions & 12 deletions tests/AheadOfTime/Trimming/check.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,32 @@ function CheckTrim($root, $tfm, $outputfile, $expected_len) {

$cwd = Get-Location
Set-Location (Join-Path $PSScriptRoot "${root}")
$build_output = dotnet publish -restore -c release -f:$tfm $root.fsproj -bl:"../../../../artifacts/log/Release/AheadOfTime/Trimming/${root}_${tfm}.binlog"
$build_output = dotnet publish -restore -c release -f:$tfm "${root}.fsproj" -bl:"../../../../artifacts/log/Release/AheadOfTime/Trimming/${root}_${tfm}.binlog"
Set-Location ${cwd}
if (-not ($LASTEXITCODE -eq 0))
if ($LASTEXITCODE -ne 0)
{
Write-Error "Build failed with exit code ${LASTEXITCODE}"
Write-Error "${build_output}" -ErrorAction Stop
}

$process = Start-Process -FilePath $(Join-Path $PSScriptRoot "${root}\bin\release\${tfm}\win-x64\publish\${root}.exe") -Wait -NoNewWindow -PassThru -RedirectStandardOutput $(Join-Path $PSScriptRoot "output.txt")
$output = Get-Content $(Join-Path $PSScriptRoot "output.txt")
# Checking that it is actually running.
if (-not ($LASTEXITCODE -eq 0))

# Checking that the test passed
$output = Get-Content $(Join-Path $PSScriptRoot output.txt)
$expected = "All tests passed"
if ($LASTEXITCODE -ne 0)
{
Write-Error "Test failed with exit code ${LASTEXITCODE}" -ErrorAction Stop
}

# Checking that the output is as expected.
$expected = "All tests passed"
if (-not ($output -eq $expected))
if ($output -eq $expected)
{
Write-Host "Test passed"
}
else
{
Write-Error "Test failed with unexpected output:`nExpected:`n`t${expected}`nActual`n`t${output}" -ErrorAction Stop
}

# Checking that the trimmed outputfile binary is of expected size (needs adjustments if test is updated).
$file = Get-Item (Join-Path $PSScriptRoot "${root}\bin\release\${tfm}\win-x64\publish\${outputfile}")
$file_len = $file.Length
Expand All @@ -39,7 +42,7 @@ function CheckTrim($root, $tfm, $outputfile, $expected_len) {
# error NETSDK1124: Trimming assemblies requires .NET Core 3.0 or higher.

# Check net7.0 trimmed assemblies
CheckTrim -root "SelfContained_Trimming_Test" -tfm "net8.0" -outputfile "FSharp.Core.dll" -expected_len 284160
CheckTrim -root "SelfContained_Trimming_Test" -tfm "net8.0" -outputfile "FSharp.Core.dll" -expected_len 285184

# Check net8.0 trimmed assemblies
CheckTrim -root "StaticLinkedFSharpCore_Trimming_Test" -tfm "net8.0" -outputfile "StaticLinkedFSharpCore_Trimming_Test.dll" -expected_len 8817152
CheckTrim -root "StaticLinkedFSharpCore_Trimming_Test" -tfm "net8.0" -outputfile "StaticLinkedFSharpCore_Trimming_Test.dll" -expected_len 8818176
3 changes: 0 additions & 3 deletions tests/AheadOfTime/check.cmd

This file was deleted.

4 changes: 4 additions & 0 deletions tests/AheadOfTime/check.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Write-Host "AheadOfTime: check1.ps1"

Equality\check.ps1
Trimming\check.ps1
Loading