From 1eec123f48c1cccb78cce10b15cdbd47c6841b79 Mon Sep 17 00:00:00 2001 From: Steve Lee Date: Tue, 30 Oct 2018 22:06:19 -0700 Subject: [PATCH] Create $PROFILE if it does not exist for `-WorkingDirectory` processing test (#8152) --- 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 3d645ea6dd..3b41812dec 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 + } } } }