From 615eca6fd5267965d9f7c780c4548e164e1c4b33 Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Fri, 4 Mar 2016 14:39:18 -0800 Subject: [PATCH] Use -Skip:$IsWindows Uses the $IsWindows etc. booleans from the Microsoft.PowerShell.Platform module instead of sourcing Test-Common repeatedly. --- test/powershell/Add-Type.Tests.ps1 | 2 +- .../Environment-Variables.Tests.ps1 | 5 ++--- test/powershell/Get-PSDrive.Tests.ps1 | 3 +-- test/powershell/New-Item.Tests.ps1 | 17 ++------------ test/powershell/Set-Location.Tests.ps1 | 3 +-- test/powershell/Split-Path.Tests.ps1 | 6 ++--- test/powershell/Test-Common.ps1 | 22 ------------------- 7 files changed, 9 insertions(+), 49 deletions(-) delete mode 100644 test/powershell/Test-Common.ps1 diff --git a/test/powershell/Add-Type.Tests.ps1 b/test/powershell/Add-Type.Tests.ps1 index 8706186847..9b0b35e7a9 100644 --- a/test/powershell/Add-Type.Tests.ps1 +++ b/test/powershell/Add-Type.Tests.ps1 @@ -1,5 +1,5 @@ Describe "Add-Type" { - It -Pending "Should not throw given a simple class definition" { + It "Should not throw given a simple class definition" -Skip:$IsWindows { { Add-Type -TypeDefinition "public static class foo { }" } | Should Not Throw } } diff --git a/test/powershell/Environment-Variables.Tests.ps1 b/test/powershell/Environment-Variables.Tests.ps1 index c5d6cc4ebc..c0f26d5329 100644 --- a/test/powershell/Environment-Variables.Tests.ps1 +++ b/test/powershell/Environment-Variables.Tests.ps1 @@ -1,5 +1,4 @@ Describe "Environment-Variables" { - $isWindows = [System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform([System.Runtime.InteropServices.OSPlatform]::Windows) It "Should have environment variables" { Get-Item ENV: | Should Not BeNullOrEmpty @@ -10,7 +9,7 @@ } It "Should contain /bin in the PATH" { - if ($isWindows) + if ($IsWindows) { $ENV:PATH | Should Match "C:" } @@ -21,7 +20,7 @@ } It "Should have the correct HOME" { - if ($isWindows) + if ($IsWindows) { $expected = "\Users" Split-Path $ENV:HOMEPATH -Parent | Should Be $expected diff --git a/test/powershell/Get-PSDrive.Tests.ps1 b/test/powershell/Get-PSDrive.Tests.ps1 index 6323c7522d..da4c87d830 100644 --- a/test/powershell/Get-PSDrive.Tests.ps1 +++ b/test/powershell/Get-PSDrive.Tests.ps1 @@ -1,5 +1,4 @@ Describe "Get-PSDrive" { - $isWindows = [System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform([System.Runtime.InteropServices.OSPlatform]::Windows) It "Should not throw" { Get-PSDrive | Should Not BeNullOrEmpty @@ -27,7 +26,7 @@ (Get-PSDrive Env).Name | Should Be Env (Get-PSDrive Cert).Root | Should Be \ - if ($isWindows) + if ($IsWindows) { (Get-PSDrive C).Provider.Name | Should Be FileSystem } diff --git a/test/powershell/New-Item.Tests.ps1 b/test/powershell/New-Item.Tests.ps1 index ce02dd2b66..57baa612c0 100644 --- a/test/powershell/New-Item.Tests.ps1 +++ b/test/powershell/New-Item.Tests.ps1 @@ -17,7 +17,6 @@ } Describe "New-Item" { - $isWindows = [System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform([System.Runtime.InteropServices.OSPlatform]::Windows) $tmpDirectory = $TestDrive $testfile = "testfile.txt" $testfolder = "newDirectory" @@ -101,13 +100,7 @@ Describe "New-Item" { Test-Path $FullyQualifiedFile | Should Be $false } - It "Should create a symbolic link of a file without error" { - # Making symbolic links on Windows requires administrator access - if ($isWindows) - { - return - } - + It "Should create a symbolic link of a file without error" -Skip:$IsWindows { New-Item -Name $testfile -Path $tmpDirectory -ItemType file Test-Path $FullyQualifiedFile | Should Be $true @@ -115,13 +108,7 @@ Describe "New-Item" { Test-Path $FullyQualifiedLink | Should Be $true } - It "Should create a symbolic link from directory without error" { - # Making symbolic links on Windows requires administrator access - if ($isWindows) - { - return - } - + It "Should create a symbolic link from directory without error" -Skip:$IsWindows { New-Item -Name $testFolder -Path $tmpDirectory -ItemType directory Test-Path $FullyQualifiedFolder | Should Be $true diff --git a/test/powershell/Set-Location.Tests.ps1 b/test/powershell/Set-Location.Tests.ps1 index aeacbbaa33..e24f09e17b 100644 --- a/test/powershell/Set-Location.Tests.ps1 +++ b/test/powershell/Set-Location.Tests.ps1 @@ -1,8 +1,7 @@ Describe "Set-Location" { $startDirectory = Get-Location - $isWindows = [System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform([System.Runtime.InteropServices.OSPlatform]::Windows) - if ($isWindows) + if ($IsWindows) { $target = "C:\" } diff --git a/test/powershell/Split-Path.Tests.ps1 b/test/powershell/Split-Path.Tests.ps1 index 49d55a7b09..2c0f802aa0 100644 --- a/test/powershell/Split-Path.Tests.ps1 +++ b/test/powershell/Split-Path.Tests.ps1 @@ -1,7 +1,5 @@ Describe "Split-Path" { - $isWindows = [System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform([System.Runtime.InteropServices.OSPlatform]::Windows) - - if ($isWindows) + if ($IsWindows) { $qualifier = "C:" } @@ -42,7 +40,7 @@ It "Should return the path when the noqualifier switch is used on a Linux system" { { Split-Path ${qualifier}usr/bin -NoQualifier } | Should Not Throw - if ($isWindows) + if ($IsWindows) { Split-Path ${qualifier}usr/bin -NoQualifier | Should Be "usr/bin" } diff --git a/test/powershell/Test-Common.ps1 b/test/powershell/Test-Common.ps1 deleted file mode 100644 index a03a47eaca..0000000000 --- a/test/powershell/Test-Common.ps1 +++ /dev/null @@ -1,22 +0,0 @@ -Function IsWindows -{ - $pingCommand = Get-Command -CommandType Application ping - if ($pingCommand.Definition.IndexOf("\") -ne -1) - { - return 1; - } - return 0; -} - -Function GetTempDir -{ - if (IsWindows) - { - return $env:TEMP - } - else - { - return "/tmp" - } -} -