Skip to content

Commit 98c7f6d

Browse files
committed
fix(test): generalize awk end-anchor to any ${VAR:?...} (agy P3)
agy follow-up review on PR #159 noted that the awk end-anchor was coupled to the specific variable name PROJECT_ID. If a future edit reorders the validation block (e.g. validates REPO before PROJECT_ID) or renames PROJECT_ID, the extraction would fail to terminate and the test would silently capture wrapper code beyond the init block. Generalize the regex to '\${[A-Z_]+:\\?' — matches any uppercase variable name in the `: "${VAR:?...}"` validation idiom that the wrappers use to gate startup on required config.
1 parent 6dfb7d0 commit 98c7f6d

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

tests/unit/test-wrapper-rebind-order.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,11 @@ simulate_wrapper() {
7878
echo "AUTONOMOUS_CONF='$conf_dir/autonomous.conf'"
7979
awk '
8080
/^SCRIPT_DIR=/ { capture = 1; next }
81-
/^: "\$\{PROJECT_ID:\?/ { capture = 0 }
81+
# End-anchor: any `: "${VAR:?...}"` style validation. Generalized
82+
# over a specific name so reordering or renaming the first
83+
# validated config var does not silently extend the capture into
84+
# the wrapper body. Per agy P3 follow-up review on PR #159.
85+
/^: "\$\{[A-Z_]+:\?/ { capture = 0 }
8286
capture { print }
8387
' "$wrapper"
8488
echo 'echo "AGENT_CMD=$AGENT_CMD"'

0 commit comments

Comments
 (0)