Skip to content

Commit 34de32b

Browse files
committed
Fix linter tests
1 parent 531ff4b commit 34de32b

3 files changed

Lines changed: 16 additions & 15 deletions

File tree

test/Scoop-00Linting.Tests.ps1

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
BeforeDiscovery {
2-
$scriptDir = @('bin', 'lib', 'libexec', 'test')
3-
}
4-
51
Describe 'PSScriptAnalyzer' -Tag 'Linter' {
2+
BeforeDiscovery {
3+
$scriptDir = @('.', 'bin', 'lib', 'libexec', 'test')
4+
}
5+
66
BeforeAll {
77
$lintSettings = "$PSScriptRoot\..\PSScriptAnalyzerSettings.psd1"
88
}
99

1010
It 'PSScriptAnalyzerSettings.ps1 should exist' {
1111
$lintSettings | Should -Exist
1212
}
13+
1314
Context 'Linting all *.psd1, *.psm1 and *.ps1 files' {
1415
BeforeEach {
1516
$analysis = Invoke-ScriptAnalyzer -Path "$PSScriptRoot\..\$_" -Settings $lintSettings
@@ -23,8 +24,8 @@ Describe 'PSScriptAnalyzer' -Tag 'Linter' {
2324
'*.ps1' { $type = 'Script' }
2425
'*.psd1' { $type = 'Manifest' }
2526
}
26-
Write-Host -f Yellow " [*] $($result.Severity): $($result.Message)"
27-
Write-Host -f Yellow " $($result.RuleName) in $type`: $directory\$($result.ScriptName):$($result.Line)"
27+
Write-Warning " [*] $($result.Severity): $($result.Message)"
28+
Write-Warning " $($result.RuleName) in $type`: $directory\$($result.ScriptName):$($result.Line)"
2829
}
2930
}
3031
}

test/bin/init.ps1

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
#Requires -Version 5.1
2-
Write-Host "PowerShell: $($PSVersionTable.PSVersion)"
3-
Write-Host 'Check and install testsuite dependencies ...'
2+
Write-Output "PowerShell: $($PSVersionTable.PSVersion)"
3+
Write-Output 'Check and install testsuite dependencies ...'
44
if (Get-InstalledModule -Name Pester -MinimumVersion 5.2 -MaximumVersion 5.99 -ErrorAction SilentlyContinue) {
5-
Write-Host 'Pester 5 is already installed.'
5+
Write-Output 'Pester 5 is already installed.'
66
} else {
7-
Write-Host 'Installing Pester 5 ...'
7+
Write-Output 'Installing Pester 5 ...'
88
Install-Module -Repository PSGallery -Scope CurrentUser -Force -Name Pester -MinimumVersion 5.2 -MaximumVersion 5.99 -SkipPublisherCheck
99
}
1010
if (Get-InstalledModule -Name PSScriptAnalyzer -MinimumVersion 1.17 -ErrorAction SilentlyContinue) {
11-
Write-Host 'PSScriptAnalyzer is already installed.'
11+
Write-Output 'PSScriptAnalyzer is already installed.'
1212
} else {
13-
Write-Host 'Installing PSScriptAnalyzer ...'
13+
Write-Output 'Installing PSScriptAnalyzer ...'
1414
Install-Module -Repository PSGallery -Scope CurrentUser -Force -Name PSScriptAnalyzer -SkipPublisherCheck
1515
}
1616
if (Get-InstalledModule -Name BuildHelpers -MinimumVersion 2.0 -ErrorAction SilentlyContinue) {
17-
Write-Host 'BuildHelpers is already installed.'
17+
Write-Output 'BuildHelpers is already installed.'
1818
} else {
19-
Write-Host 'Installing BuildHelpers ...'
19+
Write-Output 'Installing BuildHelpers ...'
2020
Install-Module -Repository PSGallery -Scope CurrentUser -Force -Name BuildHelpers -SkipPublisherCheck
2121
}

test/bin/test.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#Requires -Modules @{ ModuleName = 'Pester'; ModuleVersion = '5.2.0' }
44
#Requires -Modules @{ ModuleName = 'PSScriptAnalyzer'; ModuleVersion = '1.17.1' }
55
param(
6-
[String] $TestPath = $(Convert-Path "$PSScriptRoot\..\")
6+
[String] $TestPath = "$PSScriptRoot\.."
77
)
88

99
$pesterConfig = New-PesterConfiguration -Hashtable @{

0 commit comments

Comments
 (0)