Files
cutdex/tool/windows/test_windows_release.ps1
T
lingjhf 27e77fff39 feat: initial Cutdex application
Add the Flutter video editing application with project management, media
import, timeline editing, preview, AI assistance, diagnostics and settings.

Include shared UI and native host packages, platform runners, application
tests and release tooling.

Provide usage and contribution guides, the MIT license and third-party
notices. Exclude local credentials, build outputs and validation data.
2026-10-05 23:36:23 +08:00

101 lines
5.5 KiB
PowerShell

<#
.SYNOPSIS
Validates a normal and smoke release package on an interactive Windows desktop.
.DESCRIPTION
Requires App, SmokeApp, Inputs and Results paths. Writes result.json and process
logs to Results. Returns a nonzero status on failure; does not publish packages.
.EXAMPLE
Get-Help ./tool/windows/test_windows_release.ps1 -Full
.EXAMPLE
./tool/windows/test_windows_release.ps1 -App C:\Cutdex -SmokeApp C:\Smoke -Inputs C:\Inputs -Results C:\Results
#>
param(
[Parameter(Mandatory=$true)][string]$App,
[Parameter(Mandatory=$true)][string]$SmokeApp,
[Parameter(Mandatory=$true)][string]$Inputs,
[Parameter(Mandatory=$true)][string]$Results
)
$ErrorActionPreference = 'Stop'
New-Item -ItemType Directory -Force $Results | Out-Null
$report = @{ passed = $false; sandbox = ($env:USERNAME -eq 'WDAGUtilityAccount'); sessionId = (Get-Process -Id $PID).SessionId }
$normal = $null
try {
if ($report.sessionId -eq 0) { throw 'Interactive Windows desktop required; SSH Session 0 is not a display test.' }
foreach ($folder in @($App, $SmokeApp)) {
$manifest = Get-Content (Join-Path $folder 'checksums.json') -Raw | ConvertFrom-Json
foreach ($entry in $manifest.PSObject.Properties) {
if ((Get-FileHash -LiteralPath (Join-Path $folder $entry.Name) -Algorithm SHA256).Hash -ne $entry.Value) {
throw "Package checksum mismatch: $($entry.Name)"
}
}
}
Get-ChildItem Env:CUTDEX_* | Remove-Item
$env:PATH = "$env:SystemRoot\System32;$env:SystemRoot"
$env:PATHEXT = '.COM;.EXE;.BAT;.CMD'
$normal = Start-Process (Join-Path $App 'cutdex.exe') -WorkingDirectory $App -PassThru -RedirectStandardOutput (Join-Path $Results 'app.stdout.log') -RedirectStandardError (Join-Path $Results 'app.stderr.log')
Start-Sleep -Seconds 5
$normal.Refresh()
if ($normal.HasExited -or $normal.MainWindowHandle -eq 0) { throw 'Normal app did not create a window.' }
$loaded = @{}
foreach ($module in $normal.Modules) {
if ($module.ModuleName -match '^(msvcp140|vcruntime140(_1)?)\.dll$') {
$loaded[$module.ModuleName] = $module.FileName
if ([IO.Path]::GetFullPath([IO.Path]::GetDirectoryName($module.FileName)) -ne [IO.Path]::GetFullPath($App)) {
throw "VC runtime loaded outside app: $($module.FileName)"
}
}
}
foreach ($name in @('msvcp140.dll','vcruntime140.dll','vcruntime140_1.dll')) {
if (!$loaded.ContainsKey($name)) { throw "VC runtime module missing: $name" }
}
$report.loadedVcRuntime = $loaded
Stop-Process -Id $normal.Id
$normal = $null
& "$env:SystemRoot\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -ExecutionPolicy Bypass -File (Join-Path $App 'processing\verify.ps1') -Report (Join-Path $Results 'processing.json')
if ($LASTEXITCODE -ne 0) { throw 'Processing package verification failed.' }
$config = Get-Content (Join-Path $Inputs 'models.json') -Raw | ConvertFrom-Json
foreach ($configured in @($false, $true)) {
Get-ChildItem Env:CUTDEX_* | Remove-Item
$name = if ($configured) { 'with-models' } else { 'without-models' }
$caseDirectory = Join-Path $Results $name
New-Item -ItemType Directory -Force $caseDirectory | Out-Null
$env:LOCALAPPDATA = $caseDirectory
$env:APPDATA = $caseDirectory
$env:USERPROFILE = $caseDirectory
$env:CUTDEX_SMOKE_REPORT = Join-Path $caseDirectory 'result.json'
$env:CUTDEX_SMOKE_MODELS = [int]$configured
$env:CUTDEX_SMOKE_VIDEO = '1'
$env:CUTDEX_SMOKE_MEDIA = Join-Path $Inputs 'fixture.mp4'
if ($configured) {
$processing = Join-Path $caseDirectory 'Documents\Cutdex\Resources\Processing'
$whisperTarget = Join-Path $processing 'Transcription\whisper-turbo\1'
$translationTarget = Join-Path $processing 'Translation\m2m100-418m\1'
New-Item -ItemType Directory -Force $whisperTarget, $translationTarget | Out-Null
Copy-Item -Recurse -Force (Join-Path $config.whisper '*') $whisperTarget
Copy-Item -Recurse -Force (Join-Path $config.translation '*') $translationTarget
New-Item -ItemType Directory -Force (Join-Path $processing 'VocalSeparation\melband\1') | Out-Null
Copy-Item -Force $config.vocals (Join-Path $processing 'VocalSeparation\melband\1\melband.pt')
}
$process = Start-Process (Join-Path $SmokeApp 'cutdex.exe') -WorkingDirectory $SmokeApp -PassThru -RedirectStandardOutput (Join-Path $caseDirectory 'stdout.log') -RedirectStandardError (Join-Path $caseDirectory 'stderr.log')
# Retain the process handle before it exits so PowerShell 5.1 can read
# ExitCode after WaitForExit instead of returning null.
$null = $process.Handle
try {
if (!$process.WaitForExit(600000)) { throw "Smoke timed out: $name" }
if ($process.ExitCode -ne 0) { throw "Smoke failed: $name ($($process.ExitCode))" }
$result = Get-Content $env:CUTDEX_SMOKE_REPORT -Raw | ConvertFrom-Json
if (!$result.passed -or !$result.videoPreviewAndExport) { throw "Incomplete smoke: $name" }
$report[$name] = $result
} finally {
if (!$process.HasExited) { Stop-Process -Id $process.Id }
}
}
$report.passed = $true
} catch {
$report.error = $_.ToString()
throw
} finally {
if ($normal -and !$normal.HasExited) { Stop-Process -Id $normal.Id }
$report | ConvertTo-Json -Depth 12 | Set-Content -Encoding UTF8 (Join-Path $Results 'result.json')
}