Skip to content
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

Merged
merged 3 commits into from
Apr 5, 2019

Conversation

SteveL-MSFT
Copy link
Member

@SteveL-MSFT SteveL-MSFT commented Apr 3, 2019

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
Collaborator

PoshChan commented Apr 3, 2019

@SteveL-MSFT, your last commit had failures in PowerShell-CI-windows

@PoshChan
Copy link
Collaborator

PoshChan commented Apr 3, 2019

@SteveL-MSFT, your last commit had failures in PowerShell-CI-linux

@PoshChan
Copy link
Collaborator

PoshChan commented Apr 3, 2019

@SteveL-MSFT, your last commit had failures in PowerShell-CI-macos

@PoshChan
Copy link
Collaborator

PoshChan commented Apr 3, 2019

@SteveL-MSFT, your last commit had failures in PowerShell-CI-macos

@PoshChan
Copy link
Collaborator

PoshChan commented Apr 3, 2019

@SteveL-MSFT, your last commit had failures in PowerShell-CI-linux

@PoshChan
Copy link
Collaborator

PoshChan commented Apr 3, 2019

@SteveL-MSFT, your last commit had failures in PowerShell-CI-windows

@@ -1,12 +1,16 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

Import-Module HelpersCommon
Copy link
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
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
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
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
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
Member Author

@TravisEz13 the related issue above links to the product issues we should change

@SteveL-MSFT
Copy link
Member Author

@PoshChan Please get failures

@PoshChan
Copy link
Collaborator

PoshChan commented Apr 4, 2019

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

PoshChan commented Apr 4, 2019

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

PoshChan commented Apr 4, 2019

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

@PoshChan
Copy link
Collaborator

PoshChan commented Apr 4, 2019

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

@SteveL-MSFT
Copy link
Member Author

@PoshChan Please retry windows

@PoshChan
Copy link
Collaborator

PoshChan commented Apr 4, 2019

@SteveL-MSFT, successfully started retry of PowerShell-CI-Windows

@iSazonov
Copy link
Collaborator

iSazonov commented Apr 4, 2019

It seems in last days CI-Windows fail frequently.

@TravisEz13
Copy link
Member

TravisEz13 commented Apr 4, 2019

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

iSazonov commented Apr 5, 2019

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

@TravisEz13
Copy link
Member

TravisEz13 commented Apr 5, 2019

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

@TravisEz13 TravisEz13 merged commit b8317de into PowerShell:master Apr 5, 2019
@SteveL-MSFT SteveL-MSFT deleted the pshome-readonly branch April 5, 2019 16:32
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 TravisEz13 added the CL-Test Indicates that a PR should be marked as a test change in the Change Log label Apr 7, 2019
@TravisEz13 TravisEz13 added this to the 7.0.0-preview.1 milestone Apr 7, 2019
@TravisEz13 TravisEz13 modified the milestones: 7.0.0-preview.1, 6.2.1 Apr 15, 2019
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>
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>
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.

None yet

4 participants