fix(capabilities): read Python exit code directly
This commit is contained in:
1 parent
c2bf5888d0
commit
9e74b9be4a
2 files changed
+14
-2
No files matched your search
@@ -13,8 +13,9 @@ Require-Command jq
|
|||||||
$pythonVersion = $null
|
$pythonVersion = $null
|
||||||
foreach ($python in @('python', 'python3')) {
|
foreach ($python in @('python', 'python3')) {
|
||||||
if (-not (Get-Command $python -ErrorAction SilentlyContinue)) { continue }
|
if (-not (Get-Command $python -ErrorAction SilentlyContinue)) { continue }
|
||||||
$candidate = (& $python --version 2>$null | Select-Object -First 1) -replace '^Python\s+', ''
|
$candidate = & $python --version 2>$null
|
||||||
if ($LASTEXITCODE -eq 0) { $pythonVersion = $candidate; break }
|
$pythonExitCode = $LASTEXITCODE
|
||||||
|
if ($pythonExitCode -eq 0) { $pythonVersion = $candidate -replace '^Python\s+', ''; break }
|
||||||
}
|
}
|
||||||
if ($null -ne $pythonVersion) { Check-Version 'Python' $pythonVersion ([version]'3.11') } else { Fail 'Python 3.11 or newer is required' }
|
if ($null -ne $pythonVersion) { Check-Version 'Python' $pythonVersion ([version]'3.11') } else { Fail 'Python 3.11 or newer is required' }
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
[CmdletBinding()]
|
||||||
|
param([switch]$Summary)
|
||||||
|
$ErrorActionPreference = 'Stop'
|
||||||
|
$root = Split-Path (Split-Path $PSScriptRoot -Parent) -Parent
|
||||||
|
$content = Get-Content (Join-Path $root 'scripts/commands/check-capabilities.ps1') -Raw
|
||||||
|
|
||||||
|
if ($content -match '(?s)\(& \$python --version.*?Select-Object.*?\).*?\$LASTEXITCODE') {
|
||||||
|
throw 'Python capability detection must not read $LASTEXITCODE after a pipeline.'
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($Summary) { Write-Output 'Tests: PASS | capabilities' } else { Write-Output 'PASS capabilities: Python exit code is read without a pipeline' }
|
||||||
Reference in new issue
Block a user