Skip to content

Commit

Permalink
ci: win: enable powershell's strict mode
Browse files Browse the repository at this point in the history
Give variables a default value to pass strict mode.
$ErrorActionPreference defines the default behavior
if a powershell command fails.
If it's set to 'stop', then it aborts the script
on the first unresolved error.
This behavior extends to native programs like cmake.
  • Loading branch information
janlazo committed Oct 23, 2018
1 parent 8f2ebd1 commit db9b690
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions ci/build.ps1
@@ -1,4 +1,5 @@
Set-PSDebug -Trace 1
$ErrorActionPreference = 'stop'
Set-PSDebug -Strict -Trace 1

$env:CONFIGURATION -match '^(?<compiler>\w+)_(?<bits>32|64)(?:-(?<option>\w+))?$'
$compiler = $Matches.compiler
Expand All @@ -12,6 +13,7 @@ $nvimCmakeVars = @{
CMAKE_BUILD_TYPE = $cmakeBuildType;
BUSTED_OUTPUT_TYPE = 'nvim';
}
$uploadToCodeCov = $false

# For pull requests, skip some build configurations to save time.
if ($env:APPVEYOR_PULL_REQUEST_HEAD_COMMIT -and $env:CONFIGURATION -match '^(MSVC_64|MINGW_32|MINGW_64-gcov)$') {
Expand All @@ -20,6 +22,7 @@ if ($env:APPVEYOR_PULL_REQUEST_HEAD_COMMIT -and $env:CONFIGURATION -match '^(MSV

function exitIfFailed() {
if ($LastExitCode -ne 0) {
Set-PSDebug -Off
exit $LastExitCode
}
}
Expand Down Expand Up @@ -104,10 +107,10 @@ Set-PSDebug -Off
cmake --build . --config $cmakeBuildType --target functionaltest -- $cmakeGeneratorArgs 2>&1 |
foreach { $failed = $failed -or
$_ -match 'functional tests failed with error'; $_ }
Set-PSDebug -Trace 1
if ($failed) {
exit $LastExitCode
}
Set-PSDebug -Strict -Trace 1


if ($uploadToCodecov) {
Expand Down

0 comments on commit db9b690

Please sign in to comment.