fix(test): 测试脚本改为位置无关,去除本地绝对路径
This commit is contained in:
@@ -1,12 +1,18 @@
|
||||
# 数据可移植性测试:单文件、只拷 daili.db 无损迁移、删库即重置
|
||||
# 用法: powershell -NoProfile -ExecutionPolicy Bypass -File scripts\portability-test.ps1
|
||||
param(
|
||||
[string]$Exe = 'F:\hupeE的代肝平台\daili.exe',
|
||||
[string]$Work = 'F:\hupeE的代肝平台\portable-run',
|
||||
[string]$Exe = '',
|
||||
[string]$Work = '',
|
||||
[int]$PortA = 17781,
|
||||
[int]$PortB = 17782
|
||||
)
|
||||
|
||||
$Root = Split-Path -Parent $PSScriptRoot
|
||||
if (-not $Exe) { $Exe = Join-Path $Root 'daili.exe' }
|
||||
if (-not $Work) { $Work = Join-Path $Root 'portability-run' }
|
||||
$Evidence = Join-Path $Root 'test-evidence'
|
||||
if (-not (Test-Path $Exe)) { throw "找不到被测程序:$Exe(先构建或已用 -Exe 指定)" }
|
||||
|
||||
$ErrorActionPreference = 'Continue'
|
||||
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
|
||||
Add-Type -AssemblyName System.Net.Http
|
||||
@@ -153,8 +159,8 @@ Stop-App $hA2
|
||||
$pass = @($script:results | Where-Object { $_ -like 'PASS|*' }).Count
|
||||
$fail = @($script:results | Where-Object { $_ -like 'FAIL|*' }).Count
|
||||
Write-Host "`n=== 汇总:通过 $pass 项,失败 $fail 项 ===" -ForegroundColor ($(if ($fail -eq 0) { 'Green' } else { 'Red' }))
|
||||
New-Item -ItemType Directory -Force -Path 'F:\hupeE的代肝平台\test-evidence' | Out-Null
|
||||
$script:results | Set-Content 'F:\hupeE的代肝平台\test-evidence\portability-result.txt' -Encoding UTF8
|
||||
New-Item -ItemType Directory -Force -Path $Evidence | Out-Null
|
||||
$script:results | Set-Content (Join-Path $Evidence 'portability-result.txt') -Encoding UTF8
|
||||
Remove-Item -Recurse -Force $Work -ErrorAction SilentlyContinue
|
||||
if ($fail -gt 0) { exit 1 }
|
||||
exit 0
|
||||
|
||||
Reference in New Issue
Block a user