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

Replace usage of $MyInvocation.MyCommand.Path with $PSScriptRoot and cleanup tests as a preparation for Pester v5 #1438

Merged
merged 4 commits into from Apr 16, 2020

Conversation

@bergmeister
Copy link
Collaborator

bergmeister commented Apr 12, 2020

PR Summary

Pester v5 won't support $MyInvocation.MyCommand.Path in the BeforeAll block any more (in Pester v5 all code will need to be moved into Pester controlled blocks) because of scoping issues, therefore changing to $PSScriptRoot and replacing test variables called $directory with a direct call to it for better readability and easier maintenance.
Also cleanup some tests that import the PSScriptAnalyzerTestHelper.psm1 module only for calling Test-PSEditionCoreCLR, which is just [bool] $IsCoreClr. Therefore inlining this expression for better readability and reduced maintenance. This change would be needed for Pester v5 as well because the -Skip expression is evaluated at discovery time where the module function wouldn't be available.

This will not make the repo ready for Pester v5 yet, this is just the necessary cleanup without making breaking changes.

PR Checklist

Tests/Engine/CustomizedRule.tests.ps1 Outdated Show resolved Hide resolved
@bergmeister bergmeister merged commit b1c40cd into PowerShell:master Apr 16, 2020
12 checks passed
12 checks passed
PSScriptAnalyzer-CI Build #20200416.5 succeeded
Details
PSScriptAnalyzer-CI (Build Full_Build) Build Full_Build succeeded
Details
PSScriptAnalyzer-CI (Test Ubuntu_16_04) Test Ubuntu_16_04 succeeded
Details
PSScriptAnalyzer-CI (Test Ubuntu_18_04) Test Ubuntu_18_04 succeeded
Details
PSScriptAnalyzer-CI (Test Windows_Server2016_PowerShell_5_1) Test Windows_Server2016_PowerShell_5_1 succeeded
Details
PSScriptAnalyzer-CI (Test Windows_Server2016_PowerShell_Core) Test Windows_Server2016_PowerShell_Core succeeded
Details
PSScriptAnalyzer-CI (Test Windows_Server2019_PowerShell_5_1) Test Windows_Server2019_PowerShell_5_1 succeeded
Details
PSScriptAnalyzer-CI (Test Windows_Server2019_PowerShell_Core) Test Windows_Server2019_PowerShell_Core succeeded
Details
PSScriptAnalyzer-CI (Test macOS_10_14_Mojave) Test macOS_10_14_Mojave succeeded
Details
PSScriptAnalyzer-CI (Test macOS_10_15_Catalina) Test macOS_10_15_Catalina succeeded
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
license/cla All CLA requirements met.
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.