CI: Fix Windows ctest retry to only rerun failing tests

libeigen/eigen!2430

Co-authored-by: Rasmus Munk Larsen <rmlarsen@gmail.com>
diff --git a/ci/scripts/test.windows.script.ps1 b/ci/scripts/test.windows.script.ps1
index ba46ef1..b5041ac 100644
--- a/ci/scripts/test.windows.script.ps1
+++ b/ci/scripts/test.windows.script.ps1
@@ -13,11 +13,11 @@
   $target = "-L","${EIGEN_CI_CTEST_LABEL}"
 }
 
-$ctest_cmd = { ctest ${EIGEN_CI_CTEST_ARGS} --parallel ${NPROC} --output-on-failure --no-compress-output --build-noclean ${target} }
+$ctest_cmd = { ctest ${EIGEN_CI_CTEST_ARGS} --parallel ${NPROC} --output-on-failure --no-compress-output --build-noclean ${target} @args }
 
 Write-Host "Running initial tests..."
 
-& $ctest_cmd "-T test"
+& $ctest_cmd "-T" "test"
 $exit_code = $LASTEXITCODE
 
 if ($exit_code -eq 0) {
@@ -25,16 +25,12 @@
 }
 else {
   Write-Host "Initial tests failed with exit code $exit_code. Retrying up to $EIGEN_CI_CTEST_REPEAT times..."
-  # TODO: figure out how to use --repeat until-pass
-  for ($i = 1; $i -le $EIGEN_CI_CTEST_REPEAT; $i++) {
-    & $ctest_cmd "--rerun-failed"
-    $exit_code = $LASTEXITCODE
+  & $ctest_cmd "--rerun-failed" "--repeat" "until-pass:$EIGEN_CI_CTEST_REPEAT"
+  $exit_code = $LASTEXITCODE
 
-    if ($exit_code -eq 0) {
-      Write-Host "Tests passed on retry."
-      $exit_code = 42
-      break
-    }
+  if ($exit_code -eq 0) {
+    Write-Host "Tests passed on retry."
+    $exit_code = 42
   }
 }