From 592f897d21550e701d0cabaf1800a0f6b4db760b Mon Sep 17 00:00:00 2001 From: Steve Lee Date: Sat, 4 May 2019 07:44:30 -0700 Subject: [PATCH] allow test to work in cases where you can't create $profile --- test/powershell/Host/ConsoleHost.Tests.ps1 | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/test/powershell/Host/ConsoleHost.Tests.ps1 b/test/powershell/Host/ConsoleHost.Tests.ps1 index 8187e2e45..4e62fb462 100644 --- a/test/powershell/Host/ConsoleHost.Tests.ps1 +++ b/test/powershell/Host/ConsoleHost.Tests.ps1 @@ -269,8 +269,14 @@ Describe "ConsoleHost unit tests" -tags "Feature" { ){ param($switch) - Get-Content $profile -Raw | Should -Not -BeNullOrEmpty - & pwsh $switch -c exit | Should -BeExactly "profile-loaded" + if (Test-Path $profile) { + & pwsh $switch -command exit | Should -BeExactly "profile-loaded" + } + else { + # In CI, may not be able to write to $profile location, so just verify that the switch is accepted + # and no error message is in the output + & pwsh $switch -command exit *>&1 | Should -BeNullOrEmpty + } } }