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:
parent
de6a452f63
commit
615eca6fd5
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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:\"
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in a new issue