Skip to content

Commit 2a5307b

Browse files
committed
Skip PSScriptAnalyzer where it may be unsupported
See PowerShell/PSScriptAnalyzer#984
1 parent ccaf0d6 commit 2a5307b

File tree

2 files changed

+22
-18
lines changed

2 files changed

+22
-18
lines changed

test/setup.ps1

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,21 @@ If (-Not($nuget)) {
99
}
1010
Write-Host " - NuGet version: $($nuget.Version.ToString())"
1111

12-
$psScriptAnalyzer = Get-Module -Name PSScriptAnalyzer
13-
If (-Not($psScriptAnalyzer)) {
14-
$psScriptAnalyzer = Get-Module -ListAvailable | Where-Object { $_.Name -eq 'PSScriptAnalyzer' }
15-
If ($psScriptAnalyzer -is [array]) {
16-
$psScriptAnalyzer = $psScriptAnalyzer[0]
17-
}
18-
If (-Not($psScriptAnalyzer)) {
19-
Write-Host ' - installing PSScriptAnalyzer'
20-
Install-Module -Name PSScriptAnalyzer -Force
21-
$psScriptAnalyzer = Get-Module -ListAvailable | Where-Object { $_.Name -eq 'PSScriptAnalyzer' }
22-
}
12+
If ($PSVersionTable.PSEdition -ne 'Core') {
13+
$psScriptAnalyzer = Get-Module -Name PSScriptAnalyzer
14+
If (-Not($psScriptAnalyzer)) {
15+
$psScriptAnalyzer = Get-Module -ListAvailable | Where-Object { $_.Name -eq 'PSScriptAnalyzer' }
16+
If ($psScriptAnalyzer -is [array]) {
17+
$psScriptAnalyzer = $psScriptAnalyzer[0]
18+
}
19+
If (-Not($psScriptAnalyzer)) {
20+
Write-Host ' - installing PSScriptAnalyzer'
21+
Install-Module -Name PSScriptAnalyzer -Force
22+
$psScriptAnalyzer = Get-Module -ListAvailable | Where-Object { $_.Name -eq 'PSScriptAnalyzer' }
23+
}
24+
}
25+
Write-Host " - PSScriptAnalyzer version: $($psScriptAnalyzer.Version.ToString())"
2326
}
24-
Write-Host " - PSScriptAnalyzer version: $($psScriptAnalyzer.Version.ToString())"
2527

2628
$pester = Get-Module -Name Pester | Where-Object { $_.Version -ge '4.3' }
2729
If (-Not($pester)) {

test/tests/Syntax.Tests.ps1

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@ Describe 'Syntax' {
1111
$errors.Count | Should Be 0
1212
}
1313

14-
It -Name '<file> should pass PSScriptAnalyzer' -TestCases $testCases {
15-
param($file)
16-
$problems = @(Invoke-ScriptAnalyzer -Path $file.FullName -ExcludeRule PSUseShouldProcessForStateChangingFunctions -Severity Warning, Error)
17-
If ($problems) {
18-
$problems | Format-Table | Out-String | Write-Host
14+
If ($PSVersionTable.PSEdition -ne 'Core') {
15+
It -Name '<file> should pass PSScriptAnalyzer' -TestCases $testCases {
16+
param($file)
17+
$problems = @(Invoke-ScriptAnalyzer -Path $file.FullName -ExcludeRule PSUseShouldProcessForStateChangingFunctions -Severity Warning, Error)
18+
If ($problems) {
19+
$problems | Format-Table | Out-String | Write-Host
20+
}
21+
@($problems).Count | Should Be 0
1922
}
20-
@($problems).Count | Should Be 0
2123
}
2224
}

0 commit comments

Comments
 (0)