Skip to content

Commit bd942fc

Browse files
committed
Fix linter tests
1 parent 531ff4b commit bd942fc

3 files changed

Lines changed: 18 additions & 17 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: 3 additions & 3 deletions
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 = (Convert-Path "$PSScriptRoot\..")
77
)
88

99
$pesterConfig = New-PesterConfiguration -Hashtable @{
@@ -30,7 +30,7 @@ if ($env:CI -eq $true) {
3030
$commitMessage = $env:BHCommitMessage
3131

3232
# Check if tests are called from the Core itself, if so, adding excludes
33-
if ($TestPath -eq $(Convert-Path "$PSScriptRoot\..\")) {
33+
if ($TestPath -eq (Convert-Path "$PSScriptRoot\..")) {
3434
if ($commitMessage -match '!linter') {
3535
Write-Warning "Skipping code linting per commit flag '!linter'"
3636
$excludes += 'Linter'
@@ -90,7 +90,7 @@ if ($env:CI -eq $true) {
9090
}
9191

9292
# Display CI environment variables
93-
$buildVariables = ( Get-ChildItem -Path 'Env:' ).Where( { $_.Name -match '^(?:BH|CI(?:_|$)|APPVEYOR|GITHUB_|RUNNER_|SCOOP_)' } )
93+
$buildVariables = (Get-ChildItem -Path 'Env:').Where({ $_.Name -match '^(?:BH|CI(?:_|$)|APPVEYOR|GITHUB_|RUNNER_|SCOOP_)' })
9494
$details = $buildVariables |
9595
Where-Object -FilterScript { $_.Name -notmatch 'EMAIL' } |
9696
Sort-Object -Property 'Name' |

0 commit comments

Comments
 (0)