49 lines
2.8 KiB
PowerShell
49 lines
2.8 KiB
PowerShell
param(
|
|
[Parameter(Mandatory=$true)][string]$Executable,
|
|
[Parameter(Mandatory=$true)][string]$OutputDirectory,
|
|
[string]$Query='交流',
|
|
[string]$Target='消息测试专用群组',
|
|
[int]$ExpectedCount=10
|
|
)
|
|
$ErrorActionPreference='Stop'
|
|
$exe=(Resolve-Path $Executable).Path
|
|
if(Test-Path $OutputDirectory){throw 'Use a fresh evidence directory.'}
|
|
$directory=(New-Item -ItemType Directory $OutputDirectory).FullName
|
|
& $exe doctor | Out-File "$directory\doctor.json" -Encoding UTF8
|
|
$doctorCode=$LASTEXITCODE
|
|
& $exe inspect-ui --output "$directory\baseline-ui.json" | Out-Null
|
|
$baselineCode=$LASTEXITCODE
|
|
& $exe smoke --output "$directory\smoke-ui.json" | Out-File "$directory\smoke.json" -Encoding UTF8
|
|
$smokeCode=$LASTEXITCODE
|
|
$search=(& $exe session search --query $Query --ui-output "$directory\expanded-ui.json" --timeout 30 | Out-String) | ConvertFrom-Json
|
|
$searchCode=$LASTEXITCODE
|
|
$rows=@($search.results)
|
|
$targetInQuery=@($rows | Where-Object {$_.Name -ceq $Target}).Count
|
|
$negativeCode=$null
|
|
if($targetInQuery -eq 0){
|
|
$negative=(& $exe session open --query $Query --name $Target --timeout 30 | Out-String) | ConvertFrom-Json
|
|
$negativeCode=$LASTEXITCODE
|
|
$negativeAccepted=($negativeCode -ne 0 -and $negative.error -eq 'ControlNotFound')
|
|
}else{$negativeAccepted=$true}
|
|
$opened=(& $exe session open --query $Target --name $Target --timeout 30 | Out-String) | ConvertFrom-Json
|
|
$openCode=$LASTEXITCODE
|
|
$current=(& $exe session current --timeout 20 | Out-String) | ConvertFrom-Json
|
|
$currentCode=$LASTEXITCODE
|
|
& $exe inspect-ui --output "$directory\selected-ui.json" | Out-Null
|
|
$inspectCode=$LASTEXITCODE
|
|
$result=@{
|
|
DoctorExit=$doctorCode;BaselineInspectExit=$baselineCode;SmokeExit=$smokeCode;SearchExit=$searchCode;
|
|
ExpandedCount=$rows.Count;ExpectedCount=$ExpectedCount;TargetInKeywordResults=$targetInQuery;
|
|
LocalCategoriesOnly=(@($rows | Where-Object {$_.Category -notin @('群聊','联系人','功能','最常使用')}).Count -eq 0);
|
|
MissingExactTargetRejected=$negativeAccepted;NegativeExit=$negativeCode;
|
|
OpenExit=$openCode;OpenError=$opened.error;OpenMessage=$opened.message;CurrentExit=$currentCode;InspectExit=$inspectCode;
|
|
OpenedTargetMatches=($opened.Name -ceq $Target);CurrentTargetMatches=($current.session.Name -ceq $Target);
|
|
GroupMessagesSent=0;BinarySha256=(Get-FileHash $exe -Algorithm SHA256).Hash
|
|
}
|
|
$result.Success=($doctorCode -eq 0 -and $baselineCode -eq 0 -and $smokeCode -eq 0 -and
|
|
$searchCode -eq 0 -and $rows.Count -eq $ExpectedCount -and $result.LocalCategoriesOnly -and
|
|
$negativeAccepted -and $openCode -eq 0 -and $currentCode -eq 0 -and $inspectCode -eq 0 -and
|
|
$result.OpenedTargetMatches -and $result.CurrentTargetMatches)
|
|
$result | ConvertTo-Json -Depth 5 | Set-Content "$directory\summary.json" -Encoding UTF8
|
|
if(!$result.Success){exit 1}
|