Files
cbb-refresh-verify-795/Test-CbbVerifyEnvironment.ps1
T
阿白叔 11a2b2e46e Import CBB refresh verify r4 stability baseline
Preserve tested Verify source, authoritative READY checks, bounded bridge retries, diagnostics and failure-only reporting. Include 336-test suite and packaging assets; exclude live Mentor samples, field logs, backups and distributions.
2026-09-29 15:05:20 +08:00

36 lines
1.8 KiB
PowerShell

[CmdletBinding()]
param(
[string]$MentorHome = $env:SDD_HOME,
[string]$DmsRoot = $env:DBEDIR,
[string]$DmsLoginConfig
)
Set-StrictMode -Version Latest
$items = @()
function Add-Check([string]$Name, [bool]$Present, [string]$Detail) {
$script:items += [pscustomobject]@{ name=$Name; present=$Present; detail=$Detail }
}
if ([string]::IsNullOrWhiteSpace($MentorHome)) { Add-Check 'SDD_HOME' $false 'Environment variable is empty.' }
else { Add-Check 'SDD_HOME' (Test-Path -LiteralPath $MentorHome -PathType Container) $MentorHome }
if ([string]::IsNullOrWhiteSpace($DmsRoot)) { Add-Check 'DBEDIR' $false 'Environment variable is empty.' }
else { Add-Check 'DBEDIR' (Test-Path -LiteralPath $DmsRoot -PathType Container) $DmsRoot }
$jvmCandidates = @()
if ($DmsRoot) { $jvmCandidates += (Join-Path $DmsRoot 'jre\bin\client\jvm.dll') }
if ($MentorHome) { $jvmCandidates += (Join-Path $MentorHome 'common\win32\jre\default\bin\client\jvm.dll') }
$jvm = $jvmCandidates | Where-Object { Test-Path -LiteralPath $_ -PathType Leaf } | Select-Object -First 1
Add-Check 'JVM' ($null -ne $jvm) ($(if ($jvm) { $jvm } else { ($jvmCandidates -join '; ') }))
$dmsBat = if ($DmsRoot) { Join-Path $DmsRoot 'bin\dmsdesktop.bat' } else { '' }
Add-Check 'DMS desktop launcher' (-not [string]::IsNullOrWhiteSpace($dmsBat) -and (Test-Path -LiteralPath $dmsBat -PathType Leaf)) $dmsBat
if ([string]::IsNullOrWhiteSpace($DmsLoginConfig)) { Add-Check 'DMS login config' $false 'Pass -DmsLoginConfig when running the real check.' }
else { Add-Check 'DMS login config' (Test-Path -LiteralPath $DmsLoginConfig -PathType Leaf) $DmsLoginConfig }
$result = [pscustomobject]@{ ready = (@($items | Where-Object { -not $_.present }).Count -eq 0); checks = @($items) }
$result | ConvertTo-Json -Depth 6
if (-not $result.ready) { exit 3 }
exit 0