Skip to content

Update tests to account for when $PSHOME is readonly - #9279

Merged
Travis Plunk (TravisEz13) merged 3 commits into
PowerShell:masterfrom
SteveL-MSFT:pshome-readonly
Apr 5, 2019
Merged

Travis Plunk (TravisEz13) merged 3 commits into
PowerShell:masterfrom
SteveL-MSFT:pshome-readonly

Conversation

@SteveL-MSFT

@SteveL-MSFT Steve Lee (SteveL-MSFT) commented Apr 3, 2019 •

Copy link
Copy Markdown
Member

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

@PoshChan

Copy link
Copy Markdown
Collaborator

Steve Lee (@SteveL-MSFT), your last commit had failures in PowerShell-CI-windows

@PoshChan

Copy link
Copy Markdown
Collaborator

Steve Lee (@SteveL-MSFT), your last commit had failures in PowerShell-CI-linux

@PoshChan

Copy link
Copy Markdown
Collaborator

Steve Lee (@SteveL-MSFT), your last commit had failures in PowerShell-CI-macos

@PoshChan

Copy link
Copy Markdown
Collaborator

Steve Lee (@SteveL-MSFT), your last commit had failures in PowerShell-CI-macos

@PoshChan

Copy link
Copy Markdown
Collaborator

Steve Lee (@SteveL-MSFT), your last commit had failures in PowerShell-CI-linux

@PoshChan

Copy link
Copy Markdown
Collaborator

Steve Lee (@SteveL-MSFT), your last commit had failures in PowerShell-CI-windows

# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

Import-Module HelpersCommon

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't autoloading work?

Copy link
Copy Markdown
Member Author

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

Copy link
Copy Markdown
Collaborator

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.

Copy link
Copy Markdown
Member Author

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.

@TravisEz13

Copy link
Copy Markdown
Member

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>
@SteveL-MSFT

Copy link
Copy Markdown
Member Author

Travis Plunk (@TravisEz13) the related issue above links to the product issues we should change

@SteveL-MSFT

Copy link
Copy Markdown
Member Author

PoshChan-Bot (@PoshChan) Please get failures

@PoshChan

Copy link
Copy Markdown
Collaborator

Steve Lee (@SteveL-MSFT), your last commit had 4 failures in PowerShell-CI-linux
JEA session Transcript script test.Configuration name should be in the transcript header

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

@PoshChan

Copy link
Copy Markdown
Collaborator

Steve Lee (@SteveL-MSFT), your last commit had 4 failures in PowerShell-CI-macos
JEA session Transcript script test.Configuration name should be in the transcript header

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

@PoshChan

Copy link
Copy Markdown
Collaborator

Steve Lee (@SteveL-MSFT), test results were not published for PowerShell-CI-static-analysis at vstfs:///Build/Build/19330

@PoshChan

Copy link
Copy Markdown
Collaborator

Steve Lee (@SteveL-MSFT), test results were not published for PowerShell-CI-windows at vstfs:///Build/Build/19331

@SteveL-MSFT

Copy link
Copy Markdown
Member Author

PoshChan-Bot (@PoshChan) Please retry windows

@PoshChan

Copy link
Copy Markdown
Collaborator

Steve Lee (@SteveL-MSFT), successfully started retry of PowerShell-CI-Windows

@iSazonov

Copy link
Copy Markdown
Collaborator

It seems in last days CI-Windows fail frequently.

@TravisEz13

Travis Plunk (TravisEz13) commented Apr 4, 2019 •

Copy link
Copy Markdown
Member

Ilya (@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

image

Failures for the last 30 days
image

@iSazonov

Copy link
Copy Markdown
Collaborator

Travis Plunk (@TravisEz13) Thanks! Why is there 200% "200% of pipeline failures are due to failures in task - Test"?

@TravisEz13

Travis Plunk (TravisEz13) commented Apr 5, 2019 •

Copy link
Copy Markdown
Member

Ilya (@iSazonov) The Pipeline pass rate analysis is in beta. I assume it is a bug.

@TravisEz13
Travis Plunk (TravisEz13) merged commit b8317de into PowerShell:master Apr 5, 2019
@SteveL-MSFT
Steve Lee (SteveL-MSFT) deleted the pshome-readonly branch April 5, 2019 16:32
Travis Plunk (TravisEz13) added a commit that referenced this pull request Apr 6, 2019
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>
@TravisEz13 Travis Plunk (TravisEz13) added the CL-Test Indicates that a PR should be marked as a test change in the Change Log label Apr 7, 2019
Travis Plunk (TravisEz13) added a commit that referenced this pull request Apr 15, 2019

Co-Authored-By: SteveL-MSFT <slee@microsoft.com>


Co-authored-by: Travis Plunk <travis.plunk@microsoft.com>
Travis Plunk (TravisEz13) added a commit that referenced this pull request Apr 15, 2019
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>
Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj-contribs/PowerShell that referenced this pull request Aug 6, 2026

Co-Authored-By: SteveL-MSFT <slee@microsoft.com>


Co-authored-by: Travis Plunk <travis.plunk@microsoft.com>
Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj-contribs/PowerShell that referenced this pull request Aug 6, 2026
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 PowerShell#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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-Test Indicates that a PR should be marked as a test change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants