From 05ed03154d91d17798eff370b9305190506f1893 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 0ee22870b0..456968e7dc 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 37b3489172..7ce251166d 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