param([string]$DataDir = 'D:\web\dj\integration-work\hd-test', [string]$Port = '18879') $ErrorActionPreference = 'Stop' $stage = 'D:\web\dj\integration-work\stage-4.0.11\app' $test = [IO.Path]::GetFullPath($DataDir) if (-not $test.StartsWith('D:\web\dj\integration-work\hd-test', [StringComparison]::OrdinalIgnoreCase)) { throw 'Test path outside isolated test directory' } $env:ELECTRON_RUN_AS_NODE = '1' $env:PORT = $Port $env:HUOBAO_DESKTOP = '1' $env:HUOBAO_VERSION = '4.0.11-test' $env:HUOBAO_DATA_DIR = $test $env:SQLITE_PATH = Join-Path $test 'huobao.sqlite3' $env:WORKSPACE_PATH = Join-Path $stage 'resources\workspace-template' $env:FRONTEND_DIST = Join-Path $stage 'resources\frontend' $env:FFMPEG_BIN = Join-Path $stage 'resources\bin\ffmpeg.exe' $env:FFPROBE_BIN = Join-Path $stage 'resources\bin\ffprobe.exe' $process = Start-Process -FilePath (Join-Path $stage 'HuobaoDrama.exe') -ArgumentList (Join-Path $stage 'resources\app.asar\build\backend.mjs') -WorkingDirectory $test -WindowStyle Hidden -RedirectStandardOutput (Join-Path $test 'backend.log') -RedirectStandardError (Join-Path $test 'backend.err') -PassThru $process.Id | Set-Content (Join-Path $test 'pid.txt') Write-Output "Test backend PID: $($process.Id)"