From fc0a38e77d3bb571464b888645c946d22f5ba06d Mon Sep 17 00:00:00 2001 From: Steve Lee Date: Tue, 30 Oct 2018 18:22:24 -0700 Subject: [PATCH] [feature] fix test when $PROFILE doesn't exist --- test/powershell/Host/ConsoleHost.Tests.ps1 | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/test/powershell/Host/ConsoleHost.Tests.ps1 b/test/powershell/Host/ConsoleHost.Tests.ps1 index 3d645ea6ddf..3b41812dec9 100644 --- a/test/powershell/Host/ConsoleHost.Tests.ps1 +++ b/test/powershell/Host/ConsoleHost.Tests.ps1 @@ -583,7 +583,13 @@ foo It "-WorkingDirectory should be processed before profiles" { - $currentProfile = Get-Content $PROFILE + if (Test-Path $PROFILE) { + $currentProfile = Get-Content $PROFILE + } + else { + New-Item -ItemType File -Path $PROFILE -Force + } + @" (Get-Location).Path Set-Location $testdrive @@ -596,7 +602,12 @@ foo $out[1] | Should -BeExactly "$testdrive" } finally { - Set-Content $PROFILE -Value $currentProfile + if ($currentProfile) { + Set-Content $PROFILE -Value $currentProfile + } + else { + Remove-Item $PROFILE + } } } }