Skip to content

Commit 0c1a863

Browse files
🩹 [Patch]: Check for proc count (#50)
## Description - Check for how to get proc count - Fixes #48 ## Type of change <!-- Use the check-boxes [x] on the options that are relevant. --> - [ ] 📖 [Docs] - [ ] 🪲 [Fix] - [x] 🩹 [Patch] - [ ] ⚠️ [Security fix] - [ ] 🚀 [Feature] - [ ] 🌟 [Breaking change] ## Checklist <!-- Use the check-boxes [x] on the options that are relevant. --> - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas
1 parent dab91d8 commit 0c1a863

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

scripts/tests/PSModule/SourceCode.Tests.ps1

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ Param(
88
[string] $Path
99
)
1010

11+
BeforeAll {
12+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute(
13+
'PSUseDeclaredVarsMoreThanAssignments', 'scriptFiles',
14+
Justification = 'scriptFiles is used in the test.'
15+
)]
16+
$scriptFiles = Get-ChildItem -Path $Path -Filter '*.ps1' -Recurse -File
17+
}
18+
1119
Describe 'PSModule - SourceCode tests' {
1220

1321
Context 'function/filter' {
@@ -34,7 +42,7 @@ Describe 'PSModule - SourceCode tests' {
3442
" - $($_.filePath): Function/filter name [$($_.functionName)]. Change file name or function/filter name so they match."
3543
}
3644
$issues -join [Environment]::NewLine |
37-
Should -BeNullOrEmpty -Because 'the script files should be called the same as the function they contain'
45+
Should -BeNullOrEmpty -Because 'the script files should be called the same as the function they contain'
3846
}
3947

4048
# It 'Script file should only contain one function or filter' {}
@@ -67,4 +75,22 @@ Describe 'PSModule - SourceCode tests' {
6775
# It 'datatype for parameters and parameter name are separated by a single space' {}
6876
# It 'parameters are separated by a blank line' {}
6977
}
78+
79+
Context 'Compatability checks' {
80+
It "Should use '[System.Environment]::ProcessorCount' instead of '$env:NUMBER_OF_PROCESSORS'" {
81+
$issues = @('')
82+
$scriptFiles | ForEach-Object {
83+
Select-String -Path $_.FullName -Pattern '\$env:NUMBER_OF_PROCESSORS' -AllMatches | ForEach-Object {
84+
$issues += " - $($_.Path):L$($_.LineNumber)"
85+
}
86+
}
87+
$issues -join [Environment]::NewLine |
88+
Should -BeNullOrEmpty -Because 'the script should use [System.Environment]::ProcessorCount instead of $env:NUMBER_OF_PROCESSORS'
89+
}
90+
}
91+
92+
Context 'Module manifest' {
93+
# It 'Module Manifest exists (maifest.psd1 or modulename.psd1)' {}
94+
# It 'Module Manifest is valid' {}
95+
}
7096
}

0 commit comments

Comments
 (0)