summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2019-06-23 20:22:29 +0100
committerEdward Thomson <ethomson@edwardthomson.com>2019-06-24 22:54:10 +0100
commitc7b4ce55e065b1a4e50564f99b1832c0f3f38a18 (patch)
treea6002d4ee27bf1d5f4c5322ca944c23d8e1bff33
parent6d8a34ad338eea7e5fe6c72b6a6dce7d4076cf09 (diff)
downloadlibgit2-ethomson/flaky_ci.tar.gz
ci: add flaky test re-execution on Windowsethomson/flaky_ci
Our online tests are occasionally flaky since they hit real network endpoints. Re-run them up to 5 times if they fail, to allow us to avoid having to fail the whole build.
-rw-r--r--ci/test.ps130
1 files changed, 28 insertions, 2 deletions
diff --git a/ci/test.ps1 b/ci/test.ps1
index 68b53e269..0c9e795f0 100644
--- a/ci/test.ps1
+++ b/ci/test.ps1
@@ -29,8 +29,32 @@ function run_test {
$TestCommand = (ctest -N -V -R "^$TestName$") -join "`n" -replace "(?ms).*\n^[0-9]*: Test command: ","" -replace "\n.*",""
$TestCommand += " -r${BuildDir}\results_${TestName}.xml"
- Invoke-Expression $TestCommand
- if ($LastExitCode -ne 0) { $global:Success = $false }
+ if ($Env:GITTEST_FLAKY_RETRY -gt 0) {
+ $AttemptsRemain = $Env:GITTEST_FLAKY_RETRY
+ } else {
+ $AttemptsRemain = 1
+ }
+
+ $Failed = 0
+ while ($AttemptsRemain -ne 0) {
+ if ($Failed -eq 1) {
+ Write-Host ""
+ Write-Host "Re-running flaky $TestName tests..."
+ Write-Host ""
+ }
+
+ Invoke-Expression $TestCommand
+ if ($LastExitCode -eq 0) {
+ $Failed = 0
+ break
+ } else {
+ $Failed = 1
+ }
+
+ $AttemptsRemain = $AttemptsRemain - 1
+ }
+
+ if ($Failed -eq 1) { $global:Success = $false }
}
Write-Host "##############################################################################"
@@ -79,7 +103,9 @@ if (-not $Env:SKIP_ONLINE_TESTS) {
Write-Host "## Running (online) tests"
Write-Host "##############################################################################"
+ $Env:GITTEST_FLAKY_RETRY=5
run_test online
+ $Env:GITTEST_FLAKY_RETRY=0
}
if (-not $Env:SKIP_PROXY_TESTS) {