Use -Skip:$IsWindows

Uses the $IsWindows etc. booleans from the Microsoft.PowerShell.Platform
module instead of sourcing Test-Common repeatedly.
This commit is contained in:
Andrew Schwartzmeyer committed 2016-03-04 14:39:18 -08:00
1 parent de6a452f63
commit 615eca6fd5
7 files changed
+9 -49

No files matched your search

+1 -1
View File
@@ -1,5 +1,5 @@
Describe "Add-Type" { 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 { Add-Type -TypeDefinition "public static class foo { }" } | Should Not Throw
} }
} }
@@ -1,5 +1,4 @@
Describe "Environment-Variables" { Describe "Environment-Variables" {
$isWindows = [System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform([System.Runtime.InteropServices.OSPlatform]::Windows)
It "Should have environment variables" { It "Should have environment variables" {
Get-Item ENV: | Should Not BeNullOrEmpty Get-Item ENV: | Should Not BeNullOrEmpty
@@ -10,7 +9,7 @@
} }
It "Should contain /bin in the PATH" { It "Should contain /bin in the PATH" {
if ($isWindows) if ($IsWindows)
{ {
$ENV:PATH | Should Match "C:" $ENV:PATH | Should Match "C:"
} }
@@ -21,7 +20,7 @@
} }
It "Should have the correct HOME" { It "Should have the correct HOME" {
if ($isWindows) if ($IsWindows)
{ {
$expected = "\Users" $expected = "\Users"
Split-Path $ENV:HOMEPATH -Parent | Should Be $expected Split-Path $ENV:HOMEPATH -Parent | Should Be $expected
+1 -2
View File
@@ -1,5 +1,4 @@
Describe "Get-PSDrive" { Describe "Get-PSDrive" {
$isWindows = [System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform([System.Runtime.InteropServices.OSPlatform]::Windows)
It "Should not throw" { It "Should not throw" {
Get-PSDrive | Should Not BeNullOrEmpty Get-PSDrive | Should Not BeNullOrEmpty
@@ -27,7 +26,7 @@
(Get-PSDrive Env).Name | Should Be Env (Get-PSDrive Env).Name | Should Be Env
(Get-PSDrive Cert).Root | Should Be \ (Get-PSDrive Cert).Root | Should Be \
if ($isWindows) if ($IsWindows)
{ {
(Get-PSDrive C).Provider.Name | Should Be FileSystem (Get-PSDrive C).Provider.Name | Should Be FileSystem
} }
+2 -15
View File
@@ -17,7 +17,6 @@
} }
Describe "New-Item" { Describe "New-Item" {
$isWindows = [System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform([System.Runtime.InteropServices.OSPlatform]::Windows)
$tmpDirectory = $TestDrive $tmpDirectory = $TestDrive
$testfile = "testfile.txt" $testfile = "testfile.txt"
$testfolder = "newDirectory" $testfolder = "newDirectory"
@@ -101,13 +100,7 @@ Describe "New-Item" {
Test-Path $FullyQualifiedFile | Should Be $false Test-Path $FullyQualifiedFile | Should Be $false
} }
It "Should create a symbolic link of a file without error" { It "Should create a symbolic link of a file without error" -Skip:$IsWindows {
# Making symbolic links on Windows requires administrator access
if ($isWindows)
{
return
}
New-Item -Name $testfile -Path $tmpDirectory -ItemType file New-Item -Name $testfile -Path $tmpDirectory -ItemType file
Test-Path $FullyQualifiedFile | Should Be $true Test-Path $FullyQualifiedFile | Should Be $true
@@ -115,13 +108,7 @@ Describe "New-Item" {
Test-Path $FullyQualifiedLink | Should Be $true Test-Path $FullyQualifiedLink | Should Be $true
} }
It "Should create a symbolic link from directory without error" { It "Should create a symbolic link from directory without error" -Skip:$IsWindows {
# Making symbolic links on Windows requires administrator access
if ($isWindows)
{
return
}
New-Item -Name $testFolder -Path $tmpDirectory -ItemType directory New-Item -Name $testFolder -Path $tmpDirectory -ItemType directory
Test-Path $FullyQualifiedFolder | Should Be $true Test-Path $FullyQualifiedFolder | Should Be $true
+1 -2
View File
@@ -1,8 +1,7 @@
Describe "Set-Location" { Describe "Set-Location" {
$startDirectory = Get-Location $startDirectory = Get-Location
$isWindows = [System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform([System.Runtime.InteropServices.OSPlatform]::Windows)
if ($isWindows) if ($IsWindows)
{ {
$target = "C:\" $target = "C:\"
} }
+2 -4
View File
@@ -1,7 +1,5 @@
Describe "Split-Path" { Describe "Split-Path" {
$isWindows = [System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform([System.Runtime.InteropServices.OSPlatform]::Windows) if ($IsWindows)
if ($isWindows)
{ {
$qualifier = "C:" $qualifier = "C:"
} }
@@ -42,7 +40,7 @@
It "Should return the path when the noqualifier switch is used on a Linux system" { It "Should return the path when the noqualifier switch is used on a Linux system" {
{ Split-Path ${qualifier}usr/bin -NoQualifier } | Should Not Throw { Split-Path ${qualifier}usr/bin -NoQualifier } | Should Not Throw
if ($isWindows) if ($IsWindows)
{ {
Split-Path ${qualifier}usr/bin -NoQualifier | Should Be "usr/bin" Split-Path ${qualifier}usr/bin -NoQualifier | Should Be "usr/bin"
} }
-22
View File
@@ -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"
}
}