All test reported as skipped if not applicable to the platform#2892
All test reported as skipped if not applicable to the platform#2892
Conversation
3d16d8d to
a2a01e9
Compare
208bfcd to
1cb266e
Compare
Fixed files:
powershell\Modules\Microsoft.PowerShell.Management\Clear-EventLog.Tests.ps1:1:if
($IsWindows -and !$IsCoreCLR) {
powershell\Modules\Microsoft.PowerShell.Management\Get-ComputerInfo.Tests.ps1:1325:
return
powershell\Modules\Microsoft.PowerShell.Management\Get-EventLog.Tests.ps1:1:if
($IsWindows -and !$IsCoreCLR) {
powershell\Modules\Microsoft.PowerShell.Management\New-EventLog.Tests.ps1:1:if
($IsWindows -and !$IsCoreCLR) {
powershell\Modules\Microsoft.PowerShell.Management\Registry.Tests.ps1:7:
if ($IsWindows -eq $false) {
powershell\Modules\Microsoft.PowerShell.Management\Registry.Tests.ps1:167:
if ($IsWindows -eq $false) {
powershell\Modules\Microsoft.PowerShell.Management\Remove-EventLog.Tests.ps1:1:if
($IsWindows -and !$IsCoreCLR) {
powershell\Modules\Microsoft.PowerShell.Management\TimeZone.Tests.ps1:17:if
($IsWindows) {
powershell\Modules\Microsoft.PowerShell.Security\FileCatalog.Tests.ps1:6:if
($IsWindows) {
powershell\engine\Help\HelpSystem.Tests.ps1:112: if ($IsWindows)
1cb266e to
de1cd67
Compare
mirichmo
left a comment
There was a problem hiding this comment.
Thanks for the PR. This is a helpful and needed contribution.
| helpContext = "[@id='FileSystem' or @ID='FileSystem']" | ||
| verb = 'Add' | ||
| noun = 'Content' | ||
| pending = if ($IsWindows) { $false } else { $true } |
There was a problem hiding this comment.
How about
pending = !$IsWindows
instead?
| $originalTimeZoneId | ||
| BeforeAll { | ||
| $originalTimeZoneId = (Get-TimeZone).Id | ||
| if ($IsWindows) { |
There was a problem hiding this comment.
The pattern is inconsistent here. Can you please keep consistency and use $IsNotSkipped here as well?
There was a problem hiding this comment.
😕 $IsNotSkipped is not used anywhere in the file. I do not see inconsistent here.
There was a problem hiding this comment.
The file is internally consistent, so it passes review. I was thinking about more consistent application of skipping patterns across all test files. The reason I favor $IsNotSkipped over $IsWindows is that $IsNotSkipped enables a single definition of the skipping condition, so any future modifications of it happen via a single line change. Using or modifying $IsWindows requires modifying every use of it throughout the file.
There was a problem hiding this comment.
Our direction is porting, i.e. skipping tests must generally be disappear in the future and $IsWindows and $IsNotSkipped should stay in the past :-)
|
|
||
| BeforeAll { | ||
| $defaultParamValues = $PSdefaultParameterValues.Clone() | ||
| $IsNotSkipped = ($IsWindows -and !$IsCoreCLR) |
There was a problem hiding this comment.
Is IsNotSkipped used anywhere else? If not, it should be removed.
|
|
||
| BeforeAll { | ||
| $defaultParamValues = $PSdefaultParameterValues.Clone() | ||
| $IsNotSkipped = ($IsWindows -and !$IsCoreCLR) |
| New-Item -Path $testKey > $null | ||
| New-Item -Path $testKey2 > $null | ||
| New-ItemProperty -Path $testKey -Name $testPropertyName -Value $testPropertyValue > $null | ||
| if ($IsWindows) { |
There was a problem hiding this comment.
I have a preference for $IsNotSkipped here since it is easier to read. It will also maintain consistency across this PR
There was a problem hiding this comment.
😕 $IsNotSkipped is not used anywhere in the file. There is no need to create a variable to use it once. Yes?
And in general there is no overall style between these files. Each file has its own style.
There was a problem hiding this comment.
Looking at this more closely, I'd like to see the try-finally technique used to surround both Describes (like you did in FileCatalog.Tests.ps1). It'll result in the de-duplication of a few lines and more complete grouping of actions in the BeforeAll and AfterAll blocks.
|
|
||
| AfterAll { | ||
| #restore the previous environment | ||
| Set-Location -Path $restoreLocation |
There was a problem hiding this comment.
This is one of the spots I had in mind when I mentioned "more complete grouping of actions...". A principle I'd like the tests to follow: if a Describe is being skipped, it should not do anything. In this case, it is saving and restoring the location; an action that can be bypassed with if ($IsNotSkipped). It won't happen in this specific instance, but I'd like to protect against skipped tests accidentally causing side-effects for other tests.
There was a problem hiding this comment.
Clear. Thanks!
(My policy was to preserve original test style and add minimal changes.)
Fixed.
|
@mirichmo Thanks for the code review and useful comments! |
…Shell#2892) * All test reported as skipped if not applicable to the platform Fixed files: powershell\Modules\Microsoft.PowerShell.Management\Clear-EventLog.Tests.ps1:1:if ($IsWindows -and !$IsCoreCLR) { powershell\Modules\Microsoft.PowerShell.Management\Get-ComputerInfo.Tests.ps1:1325: return powershell\Modules\Microsoft.PowerShell.Management\Get-EventLog.Tests.ps1:1:if ($IsWindows -and !$IsCoreCLR) { powershell\Modules\Microsoft.PowerShell.Management\New-EventLog.Tests.ps1:1:if ($IsWindows -and !$IsCoreCLR) { powershell\Modules\Microsoft.PowerShell.Management\Registry.Tests.ps1:7: if ($IsWindows -eq $false) { powershell\Modules\Microsoft.PowerShell.Management\Registry.Tests.ps1:167: if ($IsWindows -eq $false) { powershell\Modules\Microsoft.PowerShell.Management\Remove-EventLog.Tests.ps1:1:if ($IsWindows -and !$IsCoreCLR) { powershell\Modules\Microsoft.PowerShell.Management\TimeZone.Tests.ps1:17:if ($IsWindows) { powershell\Modules\Microsoft.PowerShell.Security\FileCatalog.Tests.ps1:6:if ($IsWindows) { powershell\engine\Help\HelpSystem.Tests.ps1:112: if ($IsWindows) * Fix test after code review * Move skiping to common 'try'
Close #2887
Fixed files:
powershell\Modules\Microsoft.PowerShell.Management\Clear-EventLog.Tests.ps1:1:if
($IsWindows -and !$IsCoreCLR) {
powershell\Modules\Microsoft.PowerShell.Management\Get-ComputerInfo.Tests.ps1:1325:
return
powershell\Modules\Microsoft.PowerShell.Management\Get-EventLog.Tests.ps1:1:if
($IsWindows -and !$IsCoreCLR) {
powershell\Modules\Microsoft.PowerShell.Management\New-EventLog.Tests.ps1:1:if
($IsWindows -and !$IsCoreCLR) {
powershell\Modules\Microsoft.PowerShell.Management\Registry.Tests.ps1:7:
if ($IsWindows -eq $false) {
powershell\Modules\Microsoft.PowerShell.Management\Registry.Tests.ps1:167:
if ($IsWindows -eq $false) {
powershell\Modules\Microsoft.PowerShell.Management\Remove-EventLog.Tests.ps1:1:if
($IsWindows -and !$IsCoreCLR) {
powershell\Modules\Microsoft.PowerShell.Management\TimeZone.Tests.ps1:17:if
($IsWindows) {
powershell\Modules\Microsoft.PowerShell.Security\FileCatalog.Tests.ps1:6:if
($IsWindows) {
powershell\engine\Help\HelpSystem.Tests.ps1:112: if ($IsWindows)