Enable Invoke-Item test for Windows
This commit is contained in:
parent
09f20879b8
commit
9a7199b05b
|
@ -2,14 +2,6 @@ using namespace System.Diagnostics
|
|||
|
||||
Describe "Invoke-Item" {
|
||||
|
||||
$tmpDirectory = $TestDrive
|
||||
$testfile = "testfile.txt"
|
||||
$testfolder = "newDirectory"
|
||||
$testlink = "testlink"
|
||||
$FullyQualifiedFile = Join-Path -Path $tmpDirectory -ChildPath $testfile
|
||||
$FullyQualifiedFolder = Join-Path -Path $tmpDirectory -ChildPath $testfolder
|
||||
$FullyQualifiedLink = Join-Path -Path $tmpDirectory -ChildPath $testlink
|
||||
|
||||
function NewProcessStartInfo([string]$CommandLine, [switch]$RedirectStdIn)
|
||||
{
|
||||
return [ProcessStartInfo]@{
|
||||
|
@ -39,38 +31,16 @@ Describe "Invoke-Item" {
|
|||
}
|
||||
}
|
||||
|
||||
function Clean-State
|
||||
{
|
||||
if (Test-Path $FullyQualifiedLink)
|
||||
{
|
||||
Remove-Item $FullyQualifiedLink -Force
|
||||
}
|
||||
|
||||
if (Test-Path $FullyQualifiedFile)
|
||||
{
|
||||
Remove-Item $FullyQualifiedFile -Force
|
||||
}
|
||||
|
||||
if (Test-Path $FullyQualifiedFolder)
|
||||
{
|
||||
Remove-Item $FullyQualifiedFolder -Force
|
||||
}
|
||||
}
|
||||
|
||||
BeforeAll {
|
||||
$powershell = Join-Path -Path $PsHome -ChildPath "powershell"
|
||||
Setup -File testfile.txt -Content "Hello World"
|
||||
$testfile = Join-Path $TestDrive testfile.txt
|
||||
}
|
||||
|
||||
#Both tests are pending due to a bug in Invoke-Item on Windows. Fixed for Linux
|
||||
|
||||
It "Should call the function without error" -Pending:$IsWindows {
|
||||
{ New-Item -Name $testfile -Path $tmpDirectory -ItemType file } | Should Not Throw
|
||||
}
|
||||
|
||||
It "Should invoke a text file without error" -Pending:$IsWindows {
|
||||
$debugfn = NewProcessStartInfo "-noprofile ""``Invoke-Item $FullyQualifiedFile`n" -RedirectStdIn
|
||||
It "Should invoke a text file without error" {
|
||||
$debugfn = NewProcessStartInfo "-noprofile ""``Invoke-Item $testfile`n" -RedirectStdIn
|
||||
$process = RunPowerShell $debugfn
|
||||
EnsureChildHasExited $process
|
||||
$process.ExitCode | Should Be 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue