@@ -22,7 +22,8 @@ BeforeAll {
2222 $loadedYamlModule = if (-not [string ]::IsNullOrWhiteSpace(
2323 $env: PSMODULE_YAML_TEST_ARTIFACT
2424 )) {
25- Import-Module - Name $env: PSMODULE_YAML_TEST_ARTIFACT - Force - Global - PassThru |
25+ Import-Module - Name $env: PSMODULE_YAML_TEST_ARTIFACT - Force - Global - PassThru `
26+ - ErrorAction Stop |
2627 Where-Object Name -EQ ' Yaml' |
2728 Select-Object - First 1
2829 } else {
@@ -55,10 +56,19 @@ Describe 'Dependency-free package source' {
5556
5657 $manifest.PowerShellVersion | Should - Be ' 7.6'
5758 @ ($manifest.CompatiblePSEditions ) | Should - Be @ (' Core' )
59+ @ ($manifest.CompatiblePSEditions ) | Should -Not - Contain ' Desktop'
5860 $manifest.ContainsKey (' DotNetFrameworkVersion' ) | Should - BeFalse
5961 $manifest.ContainsKey (' RequiredAssemblies' ) | Should - BeFalse
6062 }
6163
64+ It ' declares the generated artifact runtime once in module initialization' {
65+ $requirementPath = Join-Path $repositoryRoot ' src\init\requirements.ps1'
66+ $source = Get-Content - LiteralPath $requirementPath - Raw
67+
68+ $source | Should -Match ' (?m)^#Requires -Version 7\.6\r?$'
69+ $source | Should -Match ' (?m)^#Requires -PSEdition Core\r?$'
70+ }
71+
6272 It ' contains no external parser references or custom assembly loader' {
6373 $sourceFiles = Get-ChildItem - Path (Join-Path $repositoryRoot ' src' ) - Recurse - File
6474 $source = $sourceFiles |
@@ -125,24 +135,38 @@ Describe 'Generated artifact package' {
125135
126136 $manifest.PowerShellVersion | Should - Be ' 7.6'
127137 @ ($manifest.CompatiblePSEditions ) | Should - Be @ (' Core' )
138+ @ ($manifest.CompatiblePSEditions ) | Should -Not - Contain ' Desktop'
128139 $manifest.ContainsKey (' RequiredAssemblies' ) | Should - BeFalse
129140 $manifest.ContainsKey (' DotNetFrameworkVersion' ) | Should - BeFalse
130141 @ ($manifest.FunctionsToExport | Sort-Object ) |
131142 Should - Be @ (' ConvertFrom-Yaml' , ' ConvertTo-Yaml' , ' Test-Yaml' )
132143 @ ($manifest.FileList ) | Should - Contain ' Yaml.psm1'
144+ $packagedFiles = @ (
145+ Get-ChildItem - Path $moduleBase - Recurse - File |
146+ Where-Object FullName -NE $artifactManifestPath |
147+ ForEach-Object {
148+ [System.IO.Path ]::GetRelativePath($moduleBase , $_.FullName )
149+ } |
150+ Sort-Object
151+ )
152+ @ ($manifest.FileList | Sort-Object ) | Should - Be $packagedFiles
133153 @ ($manifest.FileList | Where-Object { $_ -match ' \.(?:dll|exe)$' }).Count | Should - Be 0
134154 @ ($manifest.FileList | Where-Object { $_ -match ' THIRD-PARTY|YamlDotNet' }).Count | Should - Be 0
155+ @ ($manifest.PrivateData.PSData.Tags ) | Should -Not - Contain ' PSEdition_Desktop'
135156 @ (Get-ChildItem - Path $moduleBase - Recurse - File - Filter ' *.dll' ).Count | Should - Be 0
136157 { Test-ModuleManifest - Path $artifactManifestPath } | Should -Not - Throw
137158 }
138159
139- It ' imports in a fresh PowerShell 7 process and preserves arrays, aliases, and depth' `
160+ It ' imports in a fresh PowerShell 7.6 Core process and preserves arrays, aliases, and depth' `
140161 - Skip:($skipArtifactTests -or $null -eq (Get-Command pwsh - ErrorAction SilentlyContinue)) {
141162 $script = @'
142163$ErrorActionPreference = 'Stop'
143164$ps = $PSVersionTable.PSVersion
144- if ($ps.Major -lt 7 -or ($ps.Major -eq 7 -and $ps.Minor -lt 6)) {
145- throw "Expected PowerShell 7.6+ but got $ps."
165+ if ($ps.Major -ne 7 -or $ps.Minor -ne 6) {
166+ throw "Expected PowerShell 7.6.x but got $ps."
167+ }
168+ if ($PSVersionTable.PSEdition -cne 'Core') {
169+ throw "Expected PowerShell Core but got $($PSVersionTable.PSEdition)."
146170}
147171Import-Module -Name '__MANIFEST__' -Force
148172$value = 'v: []' | ConvertFrom-Yaml -AsHashtable
@@ -179,11 +203,15 @@ $deepYaml = ConvertTo-Yaml -InputObject $atLimit -Depth 128 -MaxNodes 300
179203if (-not (Test-Yaml -Yaml $deepYaml -Depth 128 -MaxNodes 300)) {
180204 throw 'The public maximum serialization depth failed.'
181205}
182- ' powershell-7-ok'
206+ " powershell-runtime=$ps;edition=$($PSVersionTable.PSEdition)"
183207'@ .Replace(' __MANIFEST__' , $artifactManifestPath.Replace (" '" , " ''" ))
184208
185- (& pwsh - NoLogo - NoProfile - Command $script ) |
186- Should - Contain ' powershell-7-ok'
209+ $output = @ (& pwsh - NoLogo - NoProfile - Command $script )
210+ $runtime = $output | Where-Object { $_ -like ' powershell-runtime=*' } |
211+ Select-Object - Last 1
212+
213+ $runtime | Should -Match ' ^powershell-runtime=7\.6\.\d+;edition=Core$'
214+ Write-Information - MessageData $runtime - InformationAction Continue
187215 $LASTEXITCODE | Should - Be 0
188216 }
189217}
0 commit comments