Preserve signed WinGet exit code bits
This commit is contained in:
parent
40039a4171
commit
83a4ad15c6
2
TASKS.md
2
TASKS.md
|
|
@ -121,3 +121,5 @@ open until it is run on disposable machines with the required account setups.
|
|||
|
||||
- [x] Add a one-command config-only updater using the saved machine and a fresh repository revision, with failure and cleanup tests.
|
||||
- [x] Simplify the README around setup and web config updates; move detailed CLI workflows into an advanced guide.
|
||||
|
||||
- [x] Preserve signed WinGet HRESULT bits without UInt32 overflow and test diagnostic capture.
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ function Invoke-WingetCapture {
|
|||
$process = Start-Process -FilePath 'winget.exe' -ArgumentList $Arguments -Wait -PassThru -NoNewWindow -RedirectStandardOutput $outputPath -RedirectStandardError $errorPath
|
||||
$output = ((Get-Content -LiteralPath $outputPath -Raw -ErrorAction SilentlyContinue), (Get-Content -LiteralPath $errorPath -Raw -ErrorAction SilentlyContinue) -join [Environment]::NewLine).Trim()
|
||||
if ($LogPath) { $output | Add-Content -LiteralPath $LogPath -Encoding utf8 }
|
||||
[pscustomobject]@{ exitCode = $process.ExitCode; unsignedExitCode = [uint32]$process.ExitCode; output = $output }
|
||||
[pscustomobject]@{ exitCode = $process.ExitCode; unsignedExitCode = [BitConverter]::ToUInt32([BitConverter]::GetBytes([int32]$process.ExitCode), 0); output = $output }
|
||||
}
|
||||
finally {
|
||||
Remove-Item -LiteralPath $outputPath, $errorPath -Force -ErrorAction SilentlyContinue
|
||||
|
|
|
|||
|
|
@ -34,3 +34,36 @@ Describe 'Package planning' {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
Describe 'WinGet signed process exit codes' {
|
||||
It 'preserves the HRESULT bits and diagnostics for a negative exit code' {
|
||||
InModuleScope Packages {
|
||||
Mock Start-Process {
|
||||
'WinGet diagnostic' | Set-Content -LiteralPath $RedirectStandardError
|
||||
[pscustomobject]@{ ExitCode = -1978335189 }
|
||||
}
|
||||
$result = Invoke-WingetCapture -Arguments @('export')
|
||||
$result.exitCode | Should -Be -1978335189
|
||||
$result.unsignedExitCode | Should -Be 2316632107
|
||||
$result.output | Should -Match 'WinGet diagnostic'
|
||||
{ $result | ConvertTo-Json } | Should -Not -Throw
|
||||
}
|
||||
}
|
||||
It 'recognizes a signed no-applicable-upgrade result' {
|
||||
InModuleScope Packages {
|
||||
Mock Start-Process { [pscustomobject]@{ ExitCode = -1978335189 } }
|
||||
$operation = [pscustomobject]@{
|
||||
action = 'Upgrade'; name = 'Test.App'
|
||||
package = [pscustomobject]@{ id = 'Test.App'; source = 'winget' }
|
||||
}
|
||||
(Invoke-PackageOperation -Operation $operation).status | Should -Be 'Unchanged'
|
||||
}
|
||||
}
|
||||
It 'preserves ordinary reboot exit codes' {
|
||||
InModuleScope Packages {
|
||||
Mock Start-Process { [pscustomobject]@{ ExitCode = 3010 } }
|
||||
$result = Invoke-WingetCapture -Arguments @('install')
|
||||
$result.unsignedExitCode | Should -Be 3010
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue