From 833fcb97ff7148258d51d45c5fb69d9b07cfffde Mon Sep 17 00:00:00 2001
From: Alessio Caiazza <acaiazza@gitlab.com>
Date: Fri, 17 Aug 2018 16:20:49 +0200
Subject: [PATCH] Extract windows testing into a powershell script

---
 .gitlab-ci.yml      |  6 ++----
 ci/test_windows.ps1 | 16 ++++++++++++++++
 2 files changed, 18 insertions(+), 4 deletions(-)
 create mode 100644 ci/test_windows.ps1

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index ef348ef61..2dbc42c44 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -258,10 +258,8 @@ integration windows:
   - cmd /c mklink /D $target_path $current_path
   - cd $GODIR\gitlab-runner
   script:
-  - $packages = (go list ./... | findstr -v "\/vendor\/" | Out-String | %{$_ -replace "\r\n"," "})
-  - $testCommand = "go test $packages"
-  - Invoke-Expression $testCommand
-  - if ( $LASTEXITCODE -ne 0 ) { exit $LASTEXITCODE }
+  - $script = Join-Path -Path "ci" -ChildPath "test_windows.ps1"
+  - Invoke-Expression $script
   allow_failure: true
   only:
   - /.*/@gitlab-org/gitlab-runner
diff --git a/ci/test_windows.ps1 b/ci/test_windows.ps1
new file mode 100644
index 000000000..28113be81
--- /dev/null
+++ b/ci/test_windows.ps1
@@ -0,0 +1,16 @@
+param([string]$testOpts = "")
+
+$failed = @()
+go list ./... | Select-String -Pattern "gitlab.com/gitlab-org/gitlab-runner/vendor/" -NotMatch | ForEach-Object {
+    $pkg = %{$_ -replace "\r\n", "" }
+    $testCmd = "go test $testOpts $pkg"
+    Invoke-Expression $testCmd
+    if ( $LASTEXITCODE -ne 0 ) { $failed += $pkg }
+}
+
+if ($failed.count -ne 0) {
+    Write-Host "Failed packages"
+    $failed | Out-String | Write-Host
+
+    exit 1
+}
-- 
GitLab