From 88909811ff67b98648d28ef3ff551739e02418b4 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Wed, 7 Feb 2018 23:00:42 +0000 Subject: [PATCH] Msi installer: Add smoke test (#6105) PR 6043 broke the installer (issue #6095). To prevent this from happening in the future, add a smoke test that installs the msi in appveyor build and make build fail if installation failed. It uses the exit code to determine the success. The reason why it does not fail in the current state is because as I pointed out here, the failing custom action is not returning its exit code. --- tools/appveyor.psm1 | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tools/appveyor.psm1 b/tools/appveyor.psm1 index 7e68346018..ecb6a30a6e 100644 --- a/tools/appveyor.psm1 +++ b/tools/appveyor.psm1 @@ -445,6 +445,7 @@ function Get-ReleaseTag # Implements AppVeyor 'on_finish' step function Invoke-AppveyorFinish { + $exitCode = 0 try { $releaseTag = Get-ReleaseTag @@ -474,6 +475,19 @@ function Invoke-AppveyorFinish $preReleaseVersion = "$previewPrefix-$previewLabel.$env:APPVEYOR_BUILD_NUMBER" } + # Smoke Test MSI installer + Write-Verbose "Smoke-Testing MSI installer" -Verbose + $msi = $artifacts | Where-Object { $_.EndsWith(".msi") } + $msiLog = Join-Path (Get-Location) 'msilog.txt' + $msiExecProcess = Start-Process msiexec.exe -Wait -ArgumentList "/I $msi /quiet /l*vx $msiLog" -NoNewWindow -PassThru + if ($msiExecProcess.ExitCode -ne 0) + { + Push-AppveyorArtifact msiLog.txt + $exitCode = $msiExecProcess.ExitCode + throw "MSI installer failed and returned error code $exitCode. MSI Log was uploaded as artifact." + } + Write-Verbose "MSI smoke test was successful" -Verbose + # only publish assembly nuget packages if it is a daily build and tests passed if((Test-DailyBuild) -and $env:TestPassed -eq 'True') { @@ -527,4 +541,13 @@ function Invoke-AppveyorFinish catch { Write-Host -Foreground Red $_ } + finally { + # A throw statement would not make the build fail. This function is AppVeyor specific + # and is the only command executed in 'on_finish' phase, so it's safe that we request + # the current runspace to exit with the specified exit code. If the exit code is non-zero, + # AppVeyor will fail the build. + # See this link for details: + # https://help.appveyor.com/discussions/problems/4498-powershell-exception-in-test_script-does-not-fail-build + $host.SetShouldExit($exitCode) + } }