From b003a50c87bd1895fd5b7c79a4af159a0b6e8408 Mon Sep 17 00:00:00 2001 From: Travis Plunk Date: Wed, 10 Jan 2018 16:37:51 -0800 Subject: [PATCH] tests: fix function to test for docker OS due to change to use linuxkit for mac (#5843) * Also, fix syntax issues to allow to work with released Pester --- docker/tests/container.tests.ps1 | 6 ++---- docker/tests/containerTestCommon.psm1 | 22 +++++++++++++++++++++- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/docker/tests/container.tests.ps1 b/docker/tests/container.tests.ps1 index 7c37b9ca481..2f4fb5e6481 100644 --- a/docker/tests/container.tests.ps1 +++ b/docker/tests/container.tests.ps1 @@ -57,8 +57,7 @@ Describe "Linux Containers run PowerShell" -Tags 'Behavior', 'Linux' { # prune unused volumes $null=Invoke-Docker -Command 'volume', 'prune' -Params '--force' -SuppressHostOutput } - BeforeEach - { + BeforeEach { Remove-Item $testContext.resolvedXmlPath -ErrorAction SilentlyContinue Remove-Item $testContext.resolvedLogPath -ErrorAction SilentlyContinue } @@ -82,8 +81,7 @@ Describe "Windows Containers run PowerShell" -Tags 'Behavior', 'Windows' { BeforeAll{ $testContext = Get-TestContext -type Windows } - BeforeEach - { + BeforeEach { Remove-Item $testContext.resolvedXmlPath -ErrorAction SilentlyContinue Remove-Item $testContext.resolvedLogPath -ErrorAction SilentlyContinue } diff --git a/docker/tests/containerTestCommon.psm1 b/docker/tests/containerTestCommon.psm1 index 333f252d912..68ae2f3491b 100644 --- a/docker/tests/containerTestCommon.psm1 +++ b/docker/tests/containerTestCommon.psm1 @@ -110,7 +110,27 @@ function Test-SkipWindows function Test-SkipLinux { - return !((Get-DockerEngineOs) -like 'Alpine Linux*') + $os = Get-DockerEngineOs + + switch -wildcard ($os) + { + '*Linux*' { + return $false + } + '*Mac' { + return $false + } + # Docker for Windows means we are running the linux kernel + 'Docker for Windows' { + return $false + } + 'Windows*' { + return $true + } + default { + throw "Unknow docker os '$os'" + } + } } function Get-TestContext