Create $PROFILE if it does not exist for -WorkingDirectory processing test (#8152)

This commit is contained in:
Steve Lee 2018-10-30 22:06:19 -07:00 committed by Aditya Patwardhan
parent d9803b24d8
commit 1eec123f48

View file

@ -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
}
}
}
}