maksit-webui/utils/Run-Tests/Run-Tests.ps1
2026-05-24 20:48:35 +02:00

77 lines
2.7 KiB
PowerShell

#requires -Version 7.0
#requires -PSEdition Core
<#
.SYNOPSIS
Plugin-driven test and coverage engine.
.DESCRIPTION
Loads scriptsettings.json, builds shared execution context, and runs configured
plugins in order. Each plugin implements Invoke-Plugin and receives its own
settings plus shared context on Settings.context.
.USAGE
pwsh -File .\Run-Tests.ps1
#>
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$utilsDir = Split-Path $scriptDir -Parent
$scriptConfigModulePath = Join-Path $utilsDir "ScriptConfig.psm1"
if (-not (Test-Path $scriptConfigModulePath)) {
Write-Error "ScriptConfig module not found at: $scriptConfigModulePath"
exit 1
}
Import-Module $scriptConfigModulePath -Force
$loggingModulePath = Join-Path $utilsDir "Logging.psm1"
if (-not (Test-Path $loggingModulePath)) {
Write-Error "Logging module not found at: $loggingModulePath"
exit 1
}
Import-Module $loggingModulePath -Force
$pluginSupportModulePath = Join-Path $scriptDir "PluginSupport.psm1"
if (-not (Test-Path $pluginSupportModulePath)) {
Write-Error "PluginSupport module not found at: $pluginSupportModulePath"
exit 1
}
Import-Module $pluginSupportModulePath -Force
$engineSupportModulePath = Join-Path $scriptDir "EngineSupport.psm1"
if (-not (Test-Path $engineSupportModulePath)) {
Write-Error "EngineSupport module not found at: $engineSupportModulePath"
exit 1
}
Import-Module $engineSupportModulePath -Force
$releaseContextModulePath = Join-Path $utilsDir "Release-Package\ReleaseContext.psm1"
if (-not (Test-Path $releaseContextModulePath)) {
Write-Error "ReleaseContext module not found at: $releaseContextModulePath"
exit 1
}
Import-Module $releaseContextModulePath -Force
$settings = Get-ScriptSettings -ScriptDir $scriptDir
$configuredPlugins = Get-ConfiguredPlugins -Settings $settings
$pluginsDir = Join-Path $scriptDir "CorePlugins"
Write-Log -Level "STEP" -Message "=================================================="
Write-Log -Level "STEP" -Message "TEST ENGINE"
Write-Log -Level "STEP" -Message "=================================================="
$engineContext = New-EngineContext -ScriptDir $scriptDir -UtilsDir $utilsDir -Settings $settings
if ($configuredPlugins.Count -eq 0) {
Write-Log -Level "WARN" -Message "No plugins configured in scriptsettings.json."
exit 0
}
foreach ($plugin in $configuredPlugins) {
Invoke-ConfiguredPlugin -Plugin $plugin -SharedSettings $engineContext -PluginsDirectory $pluginsDir -ContinueOnError:$false
}
Write-Log -Level "OK" -Message "=================================================="
Write-Log -Level "OK" -Message "TEST RUN COMPLETE"
Write-Log -Level "OK" -Message "=================================================="