@@ -108,6 +108,40 @@ for bad in '<!-- cycle>=2 -->\nx\n<!-- cycle>=3 -->\ny\n<!-- /cycle -->' \
108108 fi
109109done
110110
111+ # A marker that is ALMOST right is the dangerous case, not an obviously broken one. An
112+ # unrecognised marker keeps its whole block and exits 0, so before this was an error a stray
113+ # indent or CRLF silently shipped the full nit-bearing prompt at cycle 6 -- indistinguishable
114+ # from the behaviour this script exists to remove. Each of these must exit non-zero.
115+ #
116+ # near_miss <description> <printf format producing the file>
117+ near_miss () {
118+ local desc=$1 body=$2 out
119+ # The assignment lives in the `if` condition on purpose: under `set -e` a bare
120+ # `out=$(failing command)` aborts this script instead of running the assertion.
121+ if out=$( printf ' %b' " $body " | bash " $RENDER " 1 2>&1 ) ; then
122+ fail " silently ignored a near-miss marker ($desc ); its block would leak at every cycle"
123+ elif printf ' %s' " $out " | grep -q ' malformed cycle marker' ; then
124+ pass " rejects near-miss marker: $desc "
125+ else
126+ fail " rejected $desc but without a malformed-marker message"
127+ fi
128+ }
129+ near_miss " CRLF line endings" ' keep\r\n<!-- cycle>=3 -->\r\nLATE\r\n<!-- /cycle -->\r\n'
130+ near_miss " trailing space on marker" ' keep\n<!-- cycle>=3 --> \nLATE\n<!-- /cycle -->\n'
131+ near_miss " indented marker" ' keep\n <!-- cycle>=3 -->\nLATE\n <!-- /cycle -->\n'
132+ near_miss " indented closing marker" ' keep\n<!-- cycle>=3 -->\nLATE\n <!-- /cycle -->\n'
133+ near_miss " missing space in marker" ' keep\n<!--cycle>=3-->\nLATE\n<!-- /cycle -->\n'
134+ near_miss " unknown operator" ' keep\n<!-- cycle!=3 -->\nLATE\n<!-- /cycle -->\n'
135+ near_miss " non-numeric bound" ' keep\n<!-- cycle>=x -->\nLATE\n<!-- /cycle -->\n'
136+
137+ # The real prompt must contain only strict markers, or CI is asserting against a file that
138+ # silently stopped being gated.
139+ if bash " $RENDER " 1 < " $PROMPT " > /dev/null 2>&1 ; then
140+ pass " the shipped prompt has no malformed markers"
141+ else
142+ fail " the shipped prompt contains a malformed marker"
143+ fi
144+
111145echo " -- shipped prompt, cycle 1 (full review) --"
112146has 1 " ### Documentation" " the Documentation criterion"
113147has 1 " ### Code Quality" " the Code Quality criterion"
0 commit comments