From 9a7199b05b1055aaff93d1b96ac8a61a5f6f7860 Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Wed, 6 Jul 2016 15:53:36 -0700 Subject: [PATCH] Enable Invoke-Item test for Windows --- .../Invoke-Item.Tests.ps1 | 40 +++---------------- 1 file changed, 5 insertions(+), 35 deletions(-) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/Invoke-Item.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Utility/Invoke-Item.Tests.ps1 index efc9b7917..f17a71695 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Utility/Invoke-Item.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/Invoke-Item.Tests.ps1 @@ -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 - } + } }