Files
silver_pose/v2/scripts/build-v2-release-bat.test.ps1
T

57 lines
2.4 KiB
PowerShell

$ErrorActionPreference = 'Stop'
Set-StrictMode -Version Latest
$batchEntrypoint = Join-Path $PSScriptRoot 'build-v2-release.bat'
$powerShellEntrypoint = Join-Path $PSScriptRoot 'build-v2-release.ps1'
if (-not (Test-Path -LiteralPath $batchEntrypoint -PathType Leaf)) {
throw "Batch entrypoint is missing: $batchEntrypoint"
}
$sandbox = Join-Path ([System.IO.Path]::GetTempPath()) ("silver-pose-v2-bat-test-" + [guid]::NewGuid().ToString('N'))
try {
New-Item -ItemType Directory -Path $sandbox | Out-Null
$inputs = @{
OnnxPath = Join-Path $sandbox 'best.onnx'
OrtDllPath = Join-Path $sandbox 'onnxruntime.dll'
FfmpegPath = Join-Path $sandbox 'ffmpeg.exe'
FfprobePath = Join-Path $sandbox 'ffprobe.exe'
}
$inputs.Values | ForEach-Object { New-Item -ItemType File -Path $_ | Out-Null }
$output = Join-Path $sandbox 'non-empty-output'
New-Item -ItemType Directory -Path $output | Out-Null
New-Item -ItemType File -Path (Join-Path $output 'sentinel.txt') | Out-Null
$directArgs = @(
'-NoLogo',
'-NoProfile',
'-ExecutionPolicy', 'Bypass',
'-File', $powerShellEntrypoint,
'-OnnxPath', $inputs.OnnxPath,
'-OrtDllPath', $inputs.OrtDllPath,
'-FfmpegPath', $inputs.FfmpegPath,
'-FfprobePath', $inputs.FfprobePath,
'-OutputDirectory', $output
)
$directOutput = & powershell.exe @directArgs 2>&1 | Out-String
$directExitCode = $LASTEXITCODE
$batchCommand = '"{0}" -OnnxPath "{1}" -OrtDllPath "{2}" -FfmpegPath "{3}" -FfprobePath "{4}" -OutputDirectory "{5}"' -f $batchEntrypoint, $inputs.OnnxPath, $inputs.OrtDllPath, $inputs.FfmpegPath, $inputs.FfprobePath, $output
$batchOutput = & cmd.exe /d /c $batchCommand 2>&1 | Out-String
$batchExitCode = $LASTEXITCODE
if ($directExitCode -eq 0 -or $directOutput -notmatch 'OutputDirectory must be empty') {
throw "The PowerShell release script did not reject the non-empty output directory. Output: $directOutput"
}
if ($batchExitCode -eq 0 -or $batchOutput -notmatch 'OutputDirectory must be empty') {
throw "The batch entrypoint did not forward release arguments and exit status. Output: $batchOutput"
}
Write-Output 'PASS: batch release entrypoint forwards arguments to the PowerShell release script.'
exit 0
} finally {
if (Test-Path -LiteralPath $sandbox) {
Remove-Item -LiteralPath $sandbox -Recurse -Force
}
}