test harness: smoke-pass B-enforce, fix four issues
Harness now passes 9/9 across baseline + heal + idempotent phases on the win11 VM (Standard/Machine), with 6 drift scenarios applied + healed between the baseline and heal cycles in ~30s total. Fixes: 1. lib/qga-run.py - extracted the qga round-trip out of an inline `python3 - <<PY` heredoc. The inline form clobbered stdin (heredoc replaces stdin to feed python the script, leaving sys.stdin empty for the PowerShell snippet the function caller piped in). 2. lib/qga.sh - dropped `set -euo pipefail`. When sourced, it leaked into the harness shell. Then any captured `out=$(qga_run_ps ...)` that exited non-zero (verify-state.ps1 returns 1 on any FAIL, normal during drift phases) would silently abort the harness. Callers handle non-zero with `|| rc=$?`. 3. B-enforce/run.sh do_verify - rewritten to capture rc, parse summary line, distinguish expect_pass=true vs false, route to ok / fail helper without aborting the harness on a normal non-zero verify. 4. matrix.json WJF Defect Tracker entry - switched detection from File to Registry (uninstall key DisplayVersion). The MSI does not drop the Defect_Tracker.exe artifact at the documented path even though the manifest's File detection treats it as installed; the uninstall reg entry is the reliable install marker. v2 manifest's File detection path may also need fixing, separate task. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -114,30 +114,32 @@ if ($f) { Get-Content $f.FullName -Tail 25 } else { "no enforce log" }
|
||||
EOF
|
||||
}
|
||||
|
||||
run_verify() {
|
||||
local phase_label="$1"
|
||||
log "verify ($phase_label)..."
|
||||
if qga_run_ps <<'EOF' | tee /dev/stderr | grep -q '=== verify summary' && qga_run_ps <<'EOF2' | grep -qE '0/[0-9]+ passed|^=== verify summary: ([0-9]+)/\1 passed'; then :; fi
|
||||
& 'C:\Tools\test-harness\verify-state.ps1' -MatrixPath 'C:\Tools\test-harness\matrix.json' -PCType '$PCTYPE' -PCSubType '$PCSUBTYPE'
|
||||
EOF
|
||||
EOF2
|
||||
}
|
||||
|
||||
# Simpler verify wrapper: capture output, parse summary line
|
||||
# Verify wrapper: capture output, parse summary line. PS verify returns
|
||||
# rc=1 when any check fails - capture that without aborting the harness.
|
||||
do_verify() {
|
||||
local phase_label="$1" expect_pass="$2"
|
||||
log "verify ($phase_label, expect_pass=$expect_pass)"
|
||||
local out
|
||||
local out rc=0
|
||||
out=$(qga_run_ps <<EOF
|
||||
& 'C:\\Tools\\test-harness\\verify-state.ps1' -MatrixPath 'C:\\Tools\\test-harness\\matrix.json' -PCType '$PCTYPE' -PCSubType '$PCSUBTYPE'
|
||||
EOF
|
||||
)
|
||||
) || rc=$?
|
||||
echo "$out"
|
||||
if echo "$out" | grep -qE 'verify summary: [0-9]+/[0-9]+ passed' && echo "$out" | grep -qE '\[FAIL\]'; then
|
||||
# there are failures
|
||||
if [[ "$expect_pass" == "true" ]]; then fail "$phase_label: had failures, expected all pass"; fi
|
||||
elif echo "$out" | grep -qE 'verify summary: [0-9]+/[0-9]+ passed' && ! echo "$out" | grep -qE '\[FAIL\]'; then
|
||||
if [[ "$expect_pass" == "true" ]]; then ok "$phase_label: all pass"; fi
|
||||
local summary
|
||||
summary=$(echo "$out" | grep -oE 'verify summary: [0-9]+/[0-9]+ passed' | head -1)
|
||||
[[ -z "$summary" ]] && summary='(no summary line)'
|
||||
if echo "$out" | grep -qE '\[FAIL\]'; then
|
||||
if [[ "$expect_pass" == "true" ]]; then
|
||||
fail "$phase_label: $summary - failures present, expected all pass"
|
||||
else
|
||||
ok "$phase_label: $summary - failures present (expected)"
|
||||
fi
|
||||
else
|
||||
if [[ "$expect_pass" == "true" ]]; then
|
||||
ok "$phase_label: $summary"
|
||||
else
|
||||
fail "$phase_label: $summary - all pass, expected failures (drift not applied?)"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user