From 1c359729a8dc0f819f424514df65e6e1be6ea93a Mon Sep 17 00:00:00 2001 From: Julian lechner Date: Wed, 16 Sep 2026 16:54:43 +0200 Subject: [PATCH] test(scripts): add summary modes to validation tests --- scripts/test-build-validation.ps1 | 4 ++-- scripts/test-build-validation.sh | 9 ++++++++- scripts/test-managed-install.ps1 | 4 ++-- scripts/test-managed-install.sh | 9 ++++++++- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/scripts/test-build-validation.ps1 b/scripts/test-build-validation.ps1 index 069d47d..de821ff 100644 --- a/scripts/test-build-validation.ps1 +++ b/scripts/test-build-validation.ps1 @@ -1,5 +1,5 @@ [CmdletBinding()] -param() +param([switch]$Summary) $ErrorActionPreference = 'Stop' $root = Split-Path $PSScriptRoot -Parent $work = Join-Path ([System.IO.Path]::GetTempPath()) ("ai-config-build-validation-" + [Guid]::NewGuid()) @@ -48,5 +48,5 @@ Test-BuildFails 'leftover template placeholder' { } Remove-Item $work -Recurse -Force -ErrorAction SilentlyContinue -Write-Output 'PASS build validation: invalid JSON, duplicate agent, duplicate plugin, and leftover placeholders are all rejected' +if ($Summary) { Write-Output 'Tests: PASS | build validation' } else { Write-Output 'PASS build validation: invalid JSON, duplicate agent, duplicate plugin, and leftover placeholders are all rejected' } exit 0 diff --git a/scripts/test-build-validation.sh b/scripts/test-build-validation.sh index 5ef616f..d80bda5 100755 --- a/scripts/test-build-validation.sh +++ b/scripts/test-build-validation.sh @@ -1,5 +1,12 @@ #!/usr/bin/env bash set -euo pipefail +summary=false +while [ $# -gt 0 ]; do + case "$1" in + --summary) summary=true; shift ;; + *) printf 'Unknown argument: %s\n' "$1" >&2; exit 1 ;; + esac +done root=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd) work=$(mktemp -d) @@ -45,4 +52,4 @@ mutate_leftover_placeholder() { } test_build_fails 'leftover template placeholder' mutate_leftover_placeholder -printf 'PASS build validation: invalid JSON, duplicate agent, duplicate plugin, and leftover placeholders are all rejected\n' +if [ "$summary" = true ]; then printf 'Tests: PASS | build validation\n'; else printf 'PASS build validation: invalid JSON, duplicate agent, duplicate plugin, and leftover placeholders are all rejected\n'; fi diff --git a/scripts/test-managed-install.ps1 b/scripts/test-managed-install.ps1 index 4e990d4..d2f7225 100644 --- a/scripts/test-managed-install.ps1 +++ b/scripts/test-managed-install.ps1 @@ -1,5 +1,5 @@ [CmdletBinding()] -param() +param([switch]$Summary) $ErrorActionPreference = 'Stop' $root = Split-Path $PSScriptRoot -Parent . (Join-Path $PSScriptRoot 'lib/manifest.ps1') @@ -48,7 +48,7 @@ try { if (@($outSummary | Where-Object { $_ -like 'CREATE*' -or $_ -like 'UPDATE*' -or $_ -like 'UNCHANGED*' -or $_ -like 'BACKUP*' }).Count -ne 0) { throw "Summary mode must not print per-file lines: $($outSummary -join '; ')" } if (@($outSummary | Where-Object { $_ -match '^SYNC .* unchanged' }).Count -ne 1) { throw "Summary mode must print exactly one SYNC tally line: $($outSummary -join '; ')" } - Write-Output 'PASS managed manifest: idempotent, stale removal, modified-file protection, foreign files preserved, dry run side-effect free' + if ($Summary) { Write-Output 'Tests: PASS | managed install' } else { Write-Output 'PASS managed manifest: idempotent, stale removal, modified-file protection, foreign files preserved, dry run side-effect free' } } finally { Remove-Item $work -Recurse -Force -ErrorAction SilentlyContinue } diff --git a/scripts/test-managed-install.sh b/scripts/test-managed-install.sh index d362ea5..26041e9 100755 --- a/scripts/test-managed-install.sh +++ b/scripts/test-managed-install.sh @@ -1,5 +1,12 @@ #!/usr/bin/env bash set -euo pipefail +summary=false +while [ $# -gt 0 ]; do + case "$1" in + --summary) summary=true; shift ;; + *) printf 'Unknown argument: %s\n' "$1" >&2; exit 1 ;; + esac +done root=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd) . "$root/scripts/lib/manifest.sh" @@ -54,4 +61,4 @@ if [ "$(printf '%s\n' "$out_summary" | grep -c '^SYNC .* unchanged')" -ne 1 ]; t exit 1 fi -printf 'PASS managed manifest: idempotent, stale removal, modified-file protection, foreign files preserved, dry run side-effect free\n' +if [ "$summary" = true ]; then printf 'Tests: PASS | managed install\n'; else printf 'PASS managed manifest: idempotent, stale removal, modified-file protection, foreign files preserved, dry run side-effect free\n'; fi