-
Notifications
You must be signed in to change notification settings - Fork 7.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update tests to account for when $PSHOME is readonly #9279
Conversation
@SteveL-MSFT, your last commit had failures in |
@SteveL-MSFT, your last commit had failures in |
@SteveL-MSFT, your last commit had failures in |
3527532
to
adaa749
Compare
@SteveL-MSFT, your last commit had failures in |
@SteveL-MSFT, your last commit had failures in |
@SteveL-MSFT, your last commit had failures in |
adaa749
to
1849166
Compare
@@ -1,12 +1,16 @@ | |||
# Copyright (c) Microsoft Corporation. All rights reserved. | |||
# Licensed under the MIT License. | |||
|
|||
Import-Module HelpersCommon |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't autoloading work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only if you have the test modules in your PSModulePath. If you run the tests directly instead of via Invoke-PSPester, I figured not finding the module was a better error message than not finding the cmdlet
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder that we add this again because previously we removed all explicit import-module
from all test files. Calling Invoke-PSPester once in a session could resolves the problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm ok either way on this. Some of test scripts already explicitly import helper modules.
test/powershell/Modules/Microsoft.PowerShell.Security/ExecutionPolicy.Tests.ps1
Show resolved
Hide resolved
How many of these issues does the product rely on writing to $PSHome. We should file product bugs issue for these cases? |
…nPolicy.Tests.ps1 Co-Authored-By: SteveL-MSFT <slee@microsoft.com>
@TravisEz13 the related issue above links to the product issues we should change |
@PoshChan Please get failures |
@SteveL-MSFT, your last commit had 4 failures in The term 'Unregister-PSSessionConfiguration' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
at <ScriptBlock>, /home/vsts/work/1/s/test/powershell/engine/Remoting/RemoteSession.Basic.Tests.ps1: line 75
75: Unregister-PSSessionConfiguration -Name JEA -Force -ErrorAction SilentlyContinue
JEA session Get-Help test.Get-Help should work in JEA sessions The term 'Unregister-PSSessionConfiguration' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
at <ScriptBlock>, /home/vsts/work/1/s/test/powershell/engine/Remoting/RemoteSession.Basic.Tests.ps1: line 114
114: Unregister-PSSessionConfiguration -Name JEA -Force -ErrorAction SilentlyContinue
Validate Set-ExecutionPolicy -Scope (Admin).-Scope LocalMachine is Settable, but overridden Operation is not supported on this platform.
at <ScriptBlock>, /home/vsts/work/1/s/test/powershell/Modules/Microsoft.PowerShell.Security/ExecutionPolicy.Tests.ps1: line 1163
1163: Set-ExecutionPolicy -Scope Process -ExecutionPolicy Undefined
Validate Set-ExecutionPolicy -Scope (Admin).-Scope LocalMachine is Settable Operation is not supported on this platform.
at <ScriptBlock>, /home/vsts/work/1/s/test/powershell/Modules/Microsoft.PowerShell.Security/ExecutionPolicy.Tests.ps1: line 1175
1175: Set-ExecutionPolicy -Scope Process -ExecutionPolicy Undefined
|
@SteveL-MSFT, your last commit had 4 failures in The term 'Unregister-PSSessionConfiguration' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
at <ScriptBlock>, /Users/vsts/agent/2.149.2/work/1/s/test/powershell/engine/Remoting/RemoteSession.Basic.Tests.ps1: line 75
75: Unregister-PSSessionConfiguration -Name JEA -Force -ErrorAction SilentlyContinue
JEA session Get-Help test.Get-Help should work in JEA sessions The term 'Unregister-PSSessionConfiguration' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
at <ScriptBlock>, /Users/vsts/agent/2.149.2/work/1/s/test/powershell/engine/Remoting/RemoteSession.Basic.Tests.ps1: line 114
114: Unregister-PSSessionConfiguration -Name JEA -Force -ErrorAction SilentlyContinue
Validate Set-ExecutionPolicy -Scope (Admin).-Scope LocalMachine is Settable, but overridden Operation is not supported on this platform.
at <ScriptBlock>, /Users/vsts/agent/2.149.2/work/1/s/test/powershell/Modules/Microsoft.PowerShell.Security/ExecutionPolicy.Tests.ps1: line 1163
1163: Set-ExecutionPolicy -Scope Process -ExecutionPolicy Undefined
Validate Set-ExecutionPolicy -Scope (Admin).-Scope LocalMachine is Settable Operation is not supported on this platform.
at <ScriptBlock>, /Users/vsts/agent/2.149.2/work/1/s/test/powershell/Modules/Microsoft.PowerShell.Security/ExecutionPolicy.Tests.ps1: line 1175
1175: Set-ExecutionPolicy -Scope Process -ExecutionPolicy Undefined
|
@SteveL-MSFT, test results were not published for PowerShell-CI-static-analysis at vstfs:///Build/Build/19330 |
@SteveL-MSFT, test results were not published for PowerShell-CI-windows at vstfs:///Build/Build/19331 |
@PoshChan Please retry windows |
@SteveL-MSFT, successfully started retry of |
It seems in last days CI-Windows fail frequently. |
@iSazonov You can dig into the failures here (I'm using the daily to remove failures caused by PRs): https://powershell.visualstudio.com/PowerShell/_build?definitionId=32&view=ms.vss-pipelineanalytics-web.new-build-definition-pipeline-analytics-view-cardmetrics |
@TravisEz13 Thanks! Why is there 200% "200% of pipeline failures are due to failures in task - Test"? |
@iSazonov The Pipeline pass rate analysis is in beta. I assume it is a bug. |
Moved check if able to write to $PSHome as way to skip test to `BeforeAll` which already contained a check if running on Windows. ## PR Context As part #9279, tests were updated to be skipped if the test requires writing to `$PSHome` but is not able to. However, these tests already had a skip mechanism in place so the additional check caused the test to run when it should have skipped. Co-authored-by: Travis Plunk <github@ez13.net>
Co-Authored-By: SteveL-MSFT <slee@microsoft.com> Co-authored-by: Travis Plunk <travis.plunk@microsoft.com>
Moved check if able to write to $PSHome as way to skip test to `BeforeAll` which already contained a check if running on Windows. ## PR Context As part #9279, tests were updated to be skipped if the test requires writing to `$PSHome` but is not able to. However, these tests already had a skip mechanism in place so the additional check caused the test to run when it should have skipped. Co-authored-by: Travis Plunk <github@ez13.net>
PR Summary
Add new
Test-CanWriteToPsHome
helper function to determine if current pwsh can write to $PSHOME. If it can't it will skip that test. Some other small test changes to account for differences running locally vs in CI.PR Context
Snap and AppX packages of PSCore6 have a $PSHOME that is read-only. Tests expect that when elevated/root it can write to $PSHOME which is not always the case so these tests fail.
Related #9278
PR Checklist
.h
,.cpp
,.cs
,.ps1
and.psm1
files have the correct copyright headerWIP:
or[ WIP ]
to the beginning of the title (theWIP
bot will keep its status check atPending
while the prefix is present) and remove the prefix when the PR is ready.