diff --git a/azure-pipelines-PR.yml b/azure-pipelines-PR.yml index efd1253ee81..0493ebf411c 100644 --- a/azure-pipelines-PR.yml +++ b/azure-pipelines-PR.yml @@ -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 diff --git a/eng/Build.ps1 b/eng/Build.ps1 index 982d5f28717..470015bc32a 100644 --- a/eng/Build.ps1 +++ b/eng/Build.ps1 @@ -683,7 +683,7 @@ try { if ($testAOT) { Push-Location "$RepoRoot\tests\AheadOfTime" - ./check.cmd + ./check.ps1 Pop-Location } diff --git a/tests/AheadOfTime/Equality/check.ps1 b/tests/AheadOfTime/Equality/check.ps1 index 7913d24599c..b20d99a439f 100644 --- a/tests/AheadOfTime/Equality/check.ps1 +++ b/tests/AheadOfTime/Equality/check.ps1 @@ -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 } diff --git a/tests/AheadOfTime/Trimming/check.ps1 b/tests/AheadOfTime/Trimming/check.ps1 index 7412b21232c..4c0f2fbe6cb 100644 --- a/tests/AheadOfTime/Trimming/check.ps1 +++ b/tests/AheadOfTime/Trimming/check.ps1 @@ -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 @@ -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 diff --git a/tests/AheadOfTime/check.cmd b/tests/AheadOfTime/check.cmd deleted file mode 100644 index a52368e2c6f..00000000000 --- a/tests/AheadOfTime/check.cmd +++ /dev/null @@ -1,3 +0,0 @@ -@echo off -powershell -ExecutionPolicy ByPass -NoProfile -command "& """%~dp0Trimming\check.ps1"""" -powershell -ExecutionPolicy ByPass -NoProfile -command "& """%~dp0Equality\check.ps1"""" diff --git a/tests/AheadOfTime/check.ps1 b/tests/AheadOfTime/check.ps1 new file mode 100644 index 00000000000..e8fd72b57e5 --- /dev/null +++ b/tests/AheadOfTime/check.ps1 @@ -0,0 +1,4 @@ +Write-Host "AheadOfTime: check1.ps1" + +Equality\check.ps1 +Trimming\check.ps1