fix(test): 测试脚本改为位置无关,去除本地绝对路径
This commit is contained in:
+10
-4
@@ -1,11 +1,17 @@
|
||||
# 配置文件专项测试:验证 daili.ini 的生成、解析、覆盖与各项生效
|
||||
# 用法: powershell -NoProfile -ExecutionPolicy Bypass -File scripts\config-test.ps1
|
||||
param(
|
||||
[string]$Exe = 'F:\hupeE的代肝平台\daili.exe',
|
||||
[string]$Work = 'F:\hupeE的代肝平台\cfgtest-run',
|
||||
[string]$Exe = '',
|
||||
[string]$Work = '',
|
||||
[string]$LanIp = ''
|
||||
)
|
||||
|
||||
$Root = Split-Path -Parent $PSScriptRoot
|
||||
if (-not $Exe) { $Exe = Join-Path $Root 'daili.exe' }
|
||||
if (-not $Work) { $Work = Join-Path $Root 'config-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
|
||||
@@ -226,8 +232,8 @@ Stop-App $h
|
||||
$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\config-result.txt' -Encoding UTF8
|
||||
New-Item -ItemType Directory -Force -Path $Evidence | Out-Null
|
||||
$script:results | Set-Content (Join-Path $Evidence 'config-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