Files
BiLauncher/tests/scripts/smoke_installed.ps1
T
galeon 41599fa82f
tests / linux (push) Failing after 2m18s
tests / windows (push) Skipped
tests / macos (push) Skipped
tests / package-smoke-linux (push) Skipped
tests / package-smoke-windows (push) Skipped
tests / package-smoke-macos (push) Skipped
new unit tests, hehe 67
Signed-off-by: galeon <dertiellis@gmail.com>
2026-10-12 13:14:08 +03:00

67 lines
3.2 KiB
PowerShell
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Дымовая проверка установленного дерева (результат cmake --install) на Windows.
#
# powershell -File tests\scripts\smoke_installed.ps1 -Prefix C:\r\bl-smoke-stage
#
# Проверяет, что windeployqt положил всё нужное (DLL Qt, плагины платформ и QML),
# лаунчер запускается без окна и через 10 секунд ещё жив, а в логе нет ошибок
# загрузки модулей.
#
# На Windows лаунчер берёт папку профиля у системы, а не из переменных окружения,
# поэтому работает в настоящей %APPDATA%\BiLauncher учётной записи раннера. Если
# её до запуска не было, скрипт убирает её за собой.
param(
[Parameter(Mandatory = $true)][string]$Prefix,
[int]$RunSeconds = 10
)
$ErrorActionPreference = "Stop"
function Fail($message) { Write-Host "SMOKE FAIL: $message"; exit 1 }
$bin = Join-Path $Prefix "bin\BiLauncher.exe"
if (-not (Test-Path $bin)) { Fail "нет $bin" }
foreach ($required in @("bin\Qt6Core.dll", "bin\Qt6Quick.dll", "bin\Qt6Network.dll",
"bin\platforms\qwindows.dll", "bin\qml\QtQuick\Controls")) {
if (-not (Test-Path (Join-Path $Prefix $required))) { Fail "нет $required" }
}
if (-not (Get-ChildItem (Join-Path $Prefix "bin\tls") -Filter "*.dll" -ErrorAction SilentlyContinue)) {
Fail "нет TLS-плагина (bin\tls) — лаунчер не сможет ходить по https"
}
$profileRoot = Join-Path $env:APPDATA "BiLauncher"
$existedBefore = Test-Path $profileRoot
$log = Join-Path $env:TEMP ("bilauncher-smoke-" + [guid]::NewGuid().ToString("N"))
New-Item -ItemType Directory -Force $log | Out-Null
$stdout = Join-Path $log "stdout.log"
$stderr = Join-Path $log "stderr.log"
$env:QT_QPA_PLATFORM = "offscreen"
$env:QT_FORCE_STDERR_LOGGING = "1"
$env:QTWEBENGINE_CHROMIUM_FLAGS = "--disable-gpu"
try {
$process = Start-Process -FilePath $bin -PassThru -NoNewWindow `
-RedirectStandardOutput $stdout -RedirectStandardError $stderr
Start-Sleep -Seconds $RunSeconds
$alive = -not $process.HasExited
if ($alive) { Stop-Process -Id $process.Id -Force; $process.WaitForExit(5000) | Out-Null }
$text = ""
if (Test-Path $stderr) { $text += Get-Content $stderr -Raw }
if (Test-Path $stdout) { $text += Get-Content $stdout -Raw }
Write-Host "----- лог запуска -----"
Write-Host $text
if (-not $alive) { Fail "лаунчер завершился раньше чем через $RunSeconds с (код $($process.ExitCode))" }
if ($text -match "is not installed|Cannot load library|could not find the Qt platform plugin|QQmlApplicationEngine failed") {
Fail "в логе ошибки загрузки модулей"
}
if (-not (Test-Path (Join-Path $profileRoot "settings.json"))) { Fail "лаунчер не создал $profileRoot\settings.json" }
Write-Host "SMOKE OK: $bin"
}
finally {
Remove-Item -Recurse -Force $log -ErrorAction SilentlyContinue
if (-not $existedBefore) { Remove-Item -Recurse -Force $profileRoot -ErrorAction SilentlyContinue }
}