Skip to content

Commit edaca8e

Browse files
committed
Fix test failures
Some tests are checking ErrorVariable for parse errors which are now part of the output stream
1 parent 36061f5 commit edaca8e

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

Tests/Engine/InvokeScriptAnalyzer.tests.ps1

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,10 @@ Describe "Test ScriptDefinition" {
121121
Describe "Test Path" {
122122
Context "When given a single file" {
123123
It "Has the same effect as without Path parameter" {
124-
$withPath = Invoke-ScriptAnalyzer $directory\TestScript.ps1
125-
$withoutPath = Invoke-ScriptAnalyzer -Path $directory\TestScript.ps1
126-
$withPath.Count -eq $withoutPath.Count | Should -BeTrue
124+
$scriptPath = Join-Path $directory "TestScript.ps1"
125+
$withPath = Invoke-ScriptAnalyzer $scriptPath
126+
$withoutPath = Invoke-ScriptAnalyzer -Path $scriptPath
127+
$withPath.Count | Should -Be $withoutPath.Count
127128
}
128129

129130
It "Runs rules on script with more than 10 parser errors" {

Tests/Engine/ModuleDependencyHandler.tests.ps1

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,12 @@ Describe "Resolve DSC Resource Dependency" {
139139

140140
Context "Invoke-ScriptAnalyzer without switch" {
141141
It "Has parse errors" -skip:$skipTest {
142-
$dr = Invoke-ScriptAnalyzer -Path $violationFilePath -ErrorVariable parseErrors -ErrorAction SilentlyContinue
143-
$parseErrors.Count | Should -Be 1
142+
$dr = Invoke-ScriptAnalyzer -Path $violationFilePath -ErrorVariable analyzerErrors -ErrorAction SilentlyContinue
143+
$analyzerErrors.Count | Should -Be 0
144+
145+
$dr |
146+
Where-Object { $_.Severity -eq "ParseError" } |
147+
Get-Count | Should -Be 1
144148
}
145149
}
146150

@@ -182,10 +186,13 @@ Describe "Resolve DSC Resource Dependency" {
182186
Copy-Item -Recurse -Path $modulePath -Destination $tempModulePath
183187
}
184188

185-
It "Doesn't have parse errors" -skip:$skipTest {
189+
It "has a single parse error" -skip:$skipTest {
186190
# invoke script analyzer
187-
$dr = Invoke-ScriptAnalyzer -Path $violationFilePath -ErrorVariable parseErrors -ErrorAction SilentlyContinue
188-
$dr.Count | Should -Be 0
191+
$dr = Invoke-ScriptAnalyzer -Path $violationFilePath -ErrorVariable analyzerErrors -ErrorAction SilentlyContinue
192+
$analyzerErrors.Count | Should -Be 0
193+
$dr |
194+
Where-Object { $_.Severity -eq "ParseError" } |
195+
Get-Count | Should -Be 1
189196
}
190197

191198
It "Keeps PSModulePath unchanged before and after invocation" -skip:$skipTest {

Tests/Rules/AlignAssignmentStatement.tests.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ Configuration Sample_ChangeDescriptionAndPermissions
127127
# SilentlyContinue
128128
Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings -ErrorAction SilentlyContinue |
129129
Get-Count |
130+
Where-Object { $_.Severity -ne "ParseError" } |
130131
Should -Be 4
131132
}
132133
}

0 commit comments

Comments
 (0)