Skip to content

Commit 20c2731

Browse files
fix: address review comments - move Write-Host, clarify dual-computation, fix fixture comment
1 parent 17372ea commit 20c2731

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

src/tests/Module/PSModule/PSModule.Tests.ps1

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ if ($hasClassExporter) {
4040
$expectedEnumNames = @([regex]::Matches($Matches[1], '\[([^\]]+)\]') | ForEach-Object { $_.Groups[1].Value })
4141
}
4242
}
43-
Write-Host "Has class exporter: $hasClassExporter"
44-
Write-Host "Expected classes: $($expectedClassNames -join ', ')"
45-
Write-Host "Expected enums: $($expectedEnumNames -join ', ')"
4643

47-
# Run-phase setup — recompute from $Path (available in both Discovery and Run phases).
48-
# Script-level variables above only exist during Discovery; BeforeAll runs only during Run.
44+
45+
# Run-phase setup — recompute from $Path so that It/Context blocks can use these variables.
46+
# Pester v5 Discovery and Run are separate executions. The script-scope variables above drive
47+
# -Skip and -ForEach during Discovery. This BeforeAll recomputes the same values for the Run
48+
# phase, where It blocks actually execute. The duplication is intentional and required.
4949
BeforeAll {
5050
$moduleName = Split-Path -Path (Split-Path -Path $Path -Parent) -Leaf
5151
$moduleManifestPath = Join-Path -Path $Path -ChildPath "$moduleName.psd1"
@@ -64,9 +64,9 @@ BeforeAll {
6464
$expectedEnumNames = @([regex]::Matches($Matches[1], '\[([^\]]+)\]') | ForEach-Object { $_.Groups[1].Value })
6565
}
6666
}
67-
Write-Host "Run phase - Module: $moduleName"
68-
Write-Host "Run phase - Manifest: $moduleManifestPath"
69-
Write-Host "Run phase - Has class exporter: $hasClassExporter"
67+
Write-Host "Has class exporter: $hasClassExporter"
68+
Write-Host "Expected classes: $($expectedClassNames -join ', ')"
69+
Write-Host "Expected enums: $($expectedEnumNames -join ', ')"
7070
}
7171

7272
Describe 'PSModule - Module tests' {

tests/outputTestRepo/outputs/module/PSModuleTest/PSModuleTest.psm1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ $TypeAcceleratorsClass = [psobject].Assembly.GetType(
383383
'System.Management.Automation.TypeAccelerators'
384384
)
385385
# Ensure none of the types would clobber an existing type accelerator.
386-
# If a type accelerator with the same name exists, throw an exception.
386+
# If a type accelerator with the same name already exists, skip adding it.
387387
$ExistingTypeAccelerators = $TypeAcceleratorsClass::Get
388388
# Define the types to export with type accelerators.
389389
$ExportableEnums = @(

0 commit comments

Comments
 (0)