test(packages): verify compact output and rule deduplication
This commit is contained in:
1 parent
2ce60a86ab
commit
67c28d4b08
2 files changed
+39
-7
No files matched your search
@@ -1,4 +1,6 @@
|
|||||||
$ErrorActionPreference = 'Stop'
|
[CmdletBinding()]
|
||||||
|
param([switch]$Summary)
|
||||||
|
$ErrorActionPreference = 'Stop'
|
||||||
$root = Split-Path $PSScriptRoot -Parent
|
$root = Split-Path $PSScriptRoot -Parent
|
||||||
$powerShellHook = Get-Content -LiteralPath (Join-Path $root 'shared/hooks/flashbang.ps1') -Raw
|
$powerShellHook = Get-Content -LiteralPath (Join-Path $root 'shared/hooks/flashbang.ps1') -Raw
|
||||||
$bashHook = Get-Content -LiteralPath (Join-Path $root 'shared/hooks/flashbang.sh') -Raw
|
$bashHook = Get-Content -LiteralPath (Join-Path $root 'shared/hooks/flashbang.sh') -Raw
|
||||||
@@ -6,10 +8,11 @@ if ($powerShellHook -notmatch '\$HoldMs\s*=\s*250' -or $powerShellHook -notmatch
|
|||||||
$statusInput = '{"model":{"display_name":"Test Model"},"effort":{"level":"high"},"workspace":{"current_dir":"' + $root.Replace('\','\\') + '","repo":{"name":"TestRepo"}},"context_window":{"context_window_size":200000,"used_percentage":8.5,"total_input_tokens":15500,"total_output_tokens":1200}}'
|
$statusInput = '{"model":{"display_name":"Test Model"},"effort":{"level":"high"},"workspace":{"current_dir":"' + $root.Replace('\','\\') + '","repo":{"name":"TestRepo"}},"context_window":{"context_window_size":200000,"used_percentage":8.5,"total_input_tokens":15500,"total_output_tokens":1200}}'
|
||||||
$branch = & git -C $root branch --show-current
|
$branch = & git -C $root branch --show-current
|
||||||
$buildSummaryOutput = & (Join-Path $root 'scripts/build.ps1') -Summary
|
$buildSummaryOutput = & (Join-Path $root 'scripts/build.ps1') -Summary
|
||||||
if (@($buildSummaryOutput | Where-Object { $_ -eq 'PASS build: codex-windows, claude-windows, codex-linux, claude-linux' }).Count -ne 1) { throw "build.ps1 -Summary must still print the PASS line: $($buildSummaryOutput -join '; ')" }
|
if (@($buildSummaryOutput | Where-Object { $_ -eq 'Build: PASS | 4 packages' }).Count -ne 1) { throw "build.ps1 -Summary must still print the PASS line: $($buildSummaryOutput -join '; ')" }
|
||||||
$statusOutput = ($statusInput | & (Join-Path $root 'shared/statusline/statusline.ps1')) -join "`n"
|
$statusOutput = ($statusInput | & (Join-Path $root 'shared/statusline/statusline.ps1')) -join "`n"
|
||||||
$plainStatusOutput = [regex]::Replace($statusOutput, [char]27 + '\[[0-9;]*m', '')
|
$plainStatusOutput = [regex]::Replace($statusOutput, [char]27 + '\[[0-9;]*m', '')
|
||||||
$expectedStatusOutput = "Test Model $([char]0x00B7) high`nTestRepo on $branch $([char]0x00B7) 9% ctx (16.7k tok)"
|
$expectedStatusOutput = "Test Model $([char]0x00B7) high`nTestRepo on $branch $([char]0x00B7) 9% ctx (16.7k tok)"
|
||||||
|
if ($buildSummaryOutput.Count -ne 1) { throw 'Build summary must contain only one success line.' }
|
||||||
if ($plainStatusOutput -ne $expectedStatusOutput) { throw 'PowerShell status line output is incorrect.' }
|
if ($plainStatusOutput -ne $expectedStatusOutput) { throw 'PowerShell status line output is incorrect.' }
|
||||||
$sourceAgentCount = @(Get-ChildItem (Join-Path $root 'shared/agents') -Directory).Count
|
$sourceAgentCount = @(Get-ChildItem (Join-Path $root 'shared/agents') -Directory).Count
|
||||||
$sourceSkillCount = @(Get-ChildItem (Join-Path $root 'shared/skills') -Filter 'SKILL.md' -Recurse).Count
|
$sourceSkillCount = @(Get-ChildItem (Join-Path $root 'shared/skills') -Filter 'SKILL.md' -Recurse).Count
|
||||||
@@ -42,6 +45,7 @@ foreach ($platform in @('windows','linux')) {
|
|||||||
$docContent = Get-Content -LiteralPath (Join-Path $package $docFile) -Raw
|
$docContent = Get-Content -LiteralPath (Join-Path $package $docFile) -Raw
|
||||||
if (([regex]::Matches($docContent, [regex]::Escape('Apply instructions in this order'))).Count -ne 1) { throw "$client-$platform must embed the priority rule exactly once" }
|
if (([regex]::Matches($docContent, [regex]::Escape('Apply instructions in this order'))).Count -ne 1) { throw "$client-$platform must embed the priority rule exactly once" }
|
||||||
if ($client -eq 'codex' -and $docContent -match 'Always load and apply `rules/general\.md`') { throw "$package must not still instruct loading general.md by path" }
|
if ($client -eq 'codex' -and $docContent -match 'Always load and apply `rules/general\.md`') { throw "$package must not still instruct loading general.md by path" }
|
||||||
|
if ($client -eq 'claude' -and (Test-Path (Join-Path $package 'rules/general.md'))) { throw 'Claude must not automatically load a second copy of general rules.' }
|
||||||
foreach ($splitRule in @('angular','wpf','ui-ux')) {
|
foreach ($splitRule in @('angular','wpf','ui-ux')) {
|
||||||
$referencesDir = if ($client -eq 'codex') { Join-Path $package "rules/$splitRule/references" } else { Join-Path $package "skills/rules/rules-$splitRule/references" }
|
$referencesDir = if ($client -eq 'codex') { Join-Path $package "rules/$splitRule/references" } else { Join-Path $package "skills/rules/rules-$splitRule/references" }
|
||||||
if (-not (Test-Path $referencesDir) -or (Get-ChildItem $referencesDir -Filter '*.md').Count -eq 0) { throw "$package is missing reference files for $splitRule" }
|
if (-not (Test-Path $referencesDir) -or (Get-ChildItem $referencesDir -Filter '*.md').Count -eq 0) { throw "$package is missing reference files for $splitRule" }
|
||||||
@@ -54,7 +58,7 @@ foreach ($platformSelection in @('1','2')) {
|
|||||||
$script:answers.Enqueue($platformSelection)
|
$script:answers.Enqueue($platformSelection)
|
||||||
$script:answers.Enqueue($clientSelection)
|
$script:answers.Enqueue($clientSelection)
|
||||||
function Read-Host { param($Prompt) $answers.Dequeue() }
|
function Read-Host { param($Prompt) $answers.Dequeue() }
|
||||||
$output = & "$PSScriptRoot/install.ps1" -DryRun
|
$output = & "$PSScriptRoot/install.ps1" -DryRun 6>$null
|
||||||
if ($output -notcontains 'PASS install dry-run') { throw 'Dry-run did not finish.' }
|
if ($output -notcontains 'PASS install dry-run') { throw 'Dry-run did not finish.' }
|
||||||
$platform = if ($platformSelection -eq '1') { 'windows' } else { 'linux' }
|
$platform = if ($platformSelection -eq '1') { 'windows' } else { 'linux' }
|
||||||
if (($output -join "`n") -notmatch "-$platform") { throw 'Incorrect selected package.' }
|
if (($output -join "`n") -notmatch "-$platform") { throw 'Incorrect selected package.' }
|
||||||
@@ -63,6 +67,12 @@ foreach ($platformSelection in @('1','2')) {
|
|||||||
$doctorSummaryOutput = & (Join-Path $root 'scripts/doctor.ps1') -Summary
|
$doctorSummaryOutput = & (Join-Path $root 'scripts/doctor.ps1') -Summary
|
||||||
if (@($doctorSummaryOutput | Where-Object { $_ -match '^PASS ' }).Count -ne 0) { throw 'Doctor summary mode must not print individual PASS lines.' }
|
if (@($doctorSummaryOutput | Where-Object { $_ -match '^PASS ' }).Count -ne 0) { throw 'Doctor summary mode must not print individual PASS lines.' }
|
||||||
if (@($doctorSummaryOutput | Where-Object { $_ -match '^Doctor: PASS \| \d+ checks$' }).Count -ne 1) { throw "Doctor summary mode must print one 'Doctor: PASS | N checks' line: $($doctorSummaryOutput -join '; ')" }
|
if (@($doctorSummaryOutput | Where-Object { $_ -match '^Doctor: PASS \| \d+ checks$' }).Count -ne 1) { throw "Doctor summary mode must print one 'Doctor: PASS | N checks' line: $($doctorSummaryOutput -join '; ')" }
|
||||||
Write-Output 'PASS four platform packages and six PowerShell selections'
|
foreach ($entryPoint in @('install','update')) {
|
||||||
|
$preview = @(& "$PSScriptRoot/$entryPoint.ps1" -Summary -DryRun -Client Both -Platform Windows)
|
||||||
|
if ($preview -match '^(SOURCE|CREATE|UPDATE|UNCHANGED|BACKUP|DRYRUN|PASS) ') { throw "$entryPoint summary leaked per-item output." }
|
||||||
|
if (@($preview | Where-Object { $_ -match ('^' + $entryPoint + ': PASS') }).Count -ne 1) { throw "$entryPoint summary is missing." }
|
||||||
|
}
|
||||||
|
$doctorSummaryOutput | Where-Object { $_ -match '^WARN ' }
|
||||||
|
if ($Summary) { Write-Output 'Tests: PASS | platform packages' } else { Write-Output 'PASS four platform packages and six PowerShell selections' }
|
||||||
exit 0
|
exit 0
|
||||||
|
|
||||||
@@ -1,15 +1,23 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
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=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)
|
||||||
grep -Eq '\$HoldMs[[:space:]]*=[[:space:]]*250' "$root/shared/hooks/flashbang.ps1"
|
grep -Eq '\$HoldMs[[:space:]]*=[[:space:]]*250' "$root/shared/hooks/flashbang.ps1"
|
||||||
grep -Eq '\$FadeMs[[:space:]]*=[[:space:]]*250' "$root/shared/hooks/flashbang.ps1"
|
grep -Eq '\$FadeMs[[:space:]]*=[[:space:]]*250' "$root/shared/hooks/flashbang.ps1"
|
||||||
[ "$(grep -c 'default=250' "$root/shared/hooks/flashbang.sh")" -ge 2 ]
|
[ "$(grep -c 'default=250' "$root/shared/hooks/flashbang.sh")" -ge 2 ]
|
||||||
branch=$(git -C "$root" branch --show-current)
|
branch=$(git -C "$root" branch --show-current)
|
||||||
build_summary_output=$(bash "$root/scripts/build.sh" --summary)
|
build_summary_output=$(bash "$root/scripts/build.sh" --summary)
|
||||||
if ! printf '%s\n' "$build_summary_output" | grep -qx 'PASS build: codex-windows, claude-windows, codex-linux, claude-linux'; then
|
if ! printf '%s\n' "$build_summary_output" | grep -qx 'Build: PASS | 4 packages'; then
|
||||||
printf 'build.sh --summary must still print the PASS line: %s\n' "$build_summary_output" >&2
|
printf 'build.sh --summary must still print the PASS line: %s\n' "$build_summary_output" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
[ "$build_summary_output" = 'Build: PASS | 4 packages' ]
|
||||||
status_output=$(printf '{"model":{"display_name":"Test Model"},"effort":{"level":"high"},"workspace":{"current_dir":"%s","repo":{"name":"TestRepo"}},"context_window":{"context_window_size":200000,"used_percentage":8.5,"total_input_tokens":15500,"total_output_tokens":1200}}' "$root" | bash "$root/shared/statusline/statusline.sh")
|
status_output=$(printf '{"model":{"display_name":"Test Model"},"effort":{"level":"high"},"workspace":{"current_dir":"%s","repo":{"name":"TestRepo"}},"context_window":{"context_window_size":200000,"used_percentage":8.5,"total_input_tokens":15500,"total_output_tokens":1200}}' "$root" | bash "$root/shared/statusline/statusline.sh")
|
||||||
plain_status_output=$(printf '%s' "$status_output" | sed -E $'s/\x1b\\[[0-9;]*m//g')
|
plain_status_output=$(printf '%s' "$status_output" | sed -E $'s/\x1b\\[[0-9;]*m//g')
|
||||||
expected_status_output=$'Test Model \xc2\xb7 high\nTestRepo on '"$branch"$' \xc2\xb7 9% ctx (16.7k tok)'
|
expected_status_output=$'Test Model \xc2\xb7 high\nTestRepo on '"$branch"$' \xc2\xb7 9% ctx (16.7k tok)'
|
||||||
@@ -59,6 +67,10 @@ for platform in windows linux; do
|
|||||||
printf '%s must not still instruct loading general.md by path\n' "$package" >&2
|
printf '%s must not still instruct loading general.md by path\n' "$package" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
if [ "$client" = claude ] && [ -f "$package/rules/general.md" ]; then
|
||||||
|
printf 'Claude must not automatically load a second copy of general rules.\n' >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
for split_rule in angular wpf ui-ux; do
|
for split_rule in angular wpf ui-ux; do
|
||||||
if [ "$client" = codex ]; then
|
if [ "$client" = codex ]; then
|
||||||
references_dir="$package/rules/$split_rule/references"
|
references_dir="$package/rules/$split_rule/references"
|
||||||
@@ -74,7 +86,8 @@ for platform in windows linux; do
|
|||||||
done
|
done
|
||||||
for platform_selection in 1 2; do
|
for platform_selection in 1 2; do
|
||||||
for client_selection in 1 2 3; do
|
for client_selection in 1 2 3; do
|
||||||
output=$(printf '%s\n%s\n' "$platform_selection" "$client_selection" | bash "$root/scripts/install.sh" --dry-run)
|
output=$(printf '%s\n%s\n' "$platform_selection" "$client_selection" | bash "$root/scripts/install.sh" --dry-run 2>&1) || { printf '%s\n' "$output" >&2; exit 1; }
|
||||||
|
printf '%s\n' "$output" | grep -E 'WARN|FAIL|WARNING|ERROR' || true
|
||||||
[[ "$output" == *'PASS install dry-run'* ]]
|
[[ "$output" == *'PASS install dry-run'* ]]
|
||||||
platform=windows
|
platform=windows
|
||||||
[ "$platform_selection" != 2 ] || platform=linux
|
[ "$platform_selection" != 2 ] || platform=linux
|
||||||
@@ -90,5 +103,14 @@ if ! printf '%s\n' "$doctor_summary_output" | grep -Eq '^Doctor: PASS \| [0-9]+
|
|||||||
printf "Doctor summary mode must print one 'Doctor: PASS | N checks' line: %s\n" "$doctor_summary_output" >&2
|
printf "Doctor summary mode must print one 'Doctor: PASS | N checks' line: %s\n" "$doctor_summary_output" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
printf 'PASS four platform packages and six Bash selections\n'
|
for entry_point in install update; do
|
||||||
|
preview=$(bash "$root/scripts/$entry_point.sh" --summary --dry-run --client both --platform linux)
|
||||||
|
if printf '%s\n' "$preview" | grep -Eq '^(SOURCE|CREATE|UPDATE|UNCHANGED|BACKUP|DRYRUN|PASS) '; then
|
||||||
|
printf '%s summary leaked per-item output.\n' "$entry_point" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
printf '%s\n' "$preview" | grep -Eiq "^$entry_point: PASS"
|
||||||
|
done
|
||||||
|
printf '%s\n' "$doctor_summary_output" | grep '^WARN ' || true
|
||||||
|
if [ "$summary" = true ]; then printf 'Tests: PASS | platform packages\n'; else printf 'PASS four platform packages and six Bash selections\n'; fi
|
||||||
|
|
||||||
Reference in new issue
Block a user