@@ -177,15 +177,6 @@ $formatted = '{name: Ada, active: true}' | Format-Yaml
177177if ($formatted -cne "---`n`"name`": `"Ada`"`n`"active`": true") {
178178 throw 'The imported formatter did not normalize YAML.'
179179}
180- $merged = Merge-Yaml -InputObject @(
181- 'service: { image: example:v1, ports: [80] }',
182- 'service: { image: example:v2, ports: [443] }'
183- )
184- $mergedValue = $merged | ConvertFrom-Yaml -AsHashtable
185- if ($mergedValue['service']['image'] -cne 'example:v2' -or
186- $mergedValue['service']['ports'][0] -ne 443) {
187- throw 'The imported merge command did not apply later stream precedence.'
188- }
189180$shared = [ordered]@{ value = 1 }
190181$roundTrip = [ordered]@{ first = $shared; second = $shared } |
191182 ConvertTo-Yaml |
@@ -217,6 +208,7 @@ if (-not (Test-Yaml -Yaml $deepYaml -Depth 128 -MaxNodes 300)) {
217208'@ .Replace(' __MANIFEST__' , $artifactManifestPath.Replace (" '" , " ''" ))
218209
219210 $output = @ (& pwsh - NoLogo - NoProfile - Command $script )
211+ $LASTEXITCODE | Should - Be 0
220212 $runtime = $output | Where-Object { $_ -like ' powershell-runtime=*' } |
221213 Select-Object - Last 1
222214
@@ -228,6 +220,47 @@ if (-not (Test-Yaml -Yaml $deepYaml -Depth 128 -MaxNodes 300)) {
228220 ([version ] $runtimeMatch.Groups [' Version' ].Value) -lt [version ] ' 7.6' |
229221 Should - BeFalse
230222 Write-Information - MessageData $runtime - InformationAction Continue
223+ }
224+
225+ It ' merges complete streams in a fresh PowerShell 7.6 Core process' `
226+ - Skip:($skipArtifactTests -or $null -eq (Get-Command pwsh - ErrorAction SilentlyContinue)) {
227+ $script = @'
228+ $ErrorActionPreference = 'Stop'
229+ $ps = $PSVersionTable.PSVersion
230+ if ($ps -lt [version] '7.6') {
231+ throw "Expected PowerShell 7.6 or newer but got $ps."
232+ }
233+ if ($PSVersionTable.PSEdition -cne 'Core') {
234+ throw "Expected PowerShell Core but got $($PSVersionTable.PSEdition)."
235+ }
236+ Import-Module -Name '__MANIFEST__' -Force
237+ $merged = Merge-Yaml -InputObject @(
238+ 'service: { image: example:v1, ports: [80] }',
239+ 'service: { image: example:v2, ports: [443] }'
240+ )
241+ if ($merged -match "`r" -or $merged.EndsWith("`n", [System.StringComparison]::Ordinal)) {
242+ throw 'The imported merge command did not normalize its output contract.'
243+ }
244+ $mergedValue = $merged | ConvertFrom-Yaml -AsHashtable
245+ if ($mergedValue['service']['image'] -cne 'example:v2' -or
246+ $mergedValue['service']['ports'][0] -ne 443) {
247+ throw 'The imported merge command did not apply later stream precedence.'
248+ }
249+ "merge-runtime=$ps;edition=$($PSVersionTable.PSEdition)"
250+ '@ .Replace(' __MANIFEST__' , $artifactManifestPath.Replace (" '" , " ''" ))
251+
252+ $output = @ (& pwsh - NoLogo - NoProfile - Command $script )
231253 $LASTEXITCODE | Should - Be 0
254+ $runtime = $output | Where-Object { $_ -like ' merge-runtime=*' } |
255+ Select-Object - Last 1
256+
257+ $runtimeMatch = [regex ]::Match(
258+ [string ] $runtime ,
259+ ' ^merge-runtime=(?<Version>\d+(?:\.\d+){1,3});edition=Core$'
260+ )
261+ $runtimeMatch.Success | Should - BeTrue
262+ ([version ] $runtimeMatch.Groups [' Version' ].Value) -lt [version ] ' 7.6' |
263+ Should - BeFalse
264+ Write-Information - MessageData $runtime - InformationAction Continue
232265 }
233266}
0 commit comments