Fix the gate self-tests my cadence rule broke, and control it both ways
Some checks failed
ci / check (push) Failing after 3s
Some checks failed
ci / check (push) Failing after 3s
The previous commit added the cadence rule and left `make all` red: the gate-registry self-tests expect exactly one finding each, and their fixture gates declared no cadence, so they got two. I committed without re-running the gate to the end. Fixtures now declare a cadence, and the rule has three controls of its own: a cadence=all gate absent from `make all` is caught, a gate with no declared cadence is caught, and declaring `manual` clears it — without that last one the rule would fire on every manual gate. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
43e93126e0
commit
feb68027f9
1 changed files with 32 additions and 2 deletions
|
|
@ -587,7 +587,8 @@ def self_test():
|
|||
fh.write("all: coverage newthing\ncoverage:\n\techo\n")
|
||||
with open(os.path.join(tmp, "gates.toml"), "w") as fh:
|
||||
fh.write('not_control_gates = []\n\n[[gate]]\nid = "G"\n'
|
||||
'name = "n"\ntarget = "coverage"\nchecks = "c"\n'
|
||||
'name = "n"\ntarget = "coverage"\ncadence = "all"\n'
|
||||
'checks = "c"\n'
|
||||
'added = "2026-01-01"\nreview_by = "2026-02-01"\n'
|
||||
'retire_if = "r"\n')
|
||||
f = check_gate_registry(tmp)
|
||||
|
|
@ -595,12 +596,41 @@ def self_test():
|
|||
len(f) == 1 and "newthing" in f[0].detail, f"{len(f)} finding(s)")
|
||||
with open(os.path.join(tmp, "gates.toml"), "w") as fh:
|
||||
fh.write('not_control_gates = ["newthing", "coverage"]\n\n[[gate]]\nid = "G"\n'
|
||||
'name = "n"\ntarget = "ghost"\nchecks = "c"\n'
|
||||
'name = "n"\ntarget = "ghost"\ncadence = "manual"\n'
|
||||
'checks = "c"\n'
|
||||
'added = "2026-01-01"\nreview_by = "2026-02-01"\n'
|
||||
'retire_if = "r"\n')
|
||||
f = check_gate_registry(tmp)
|
||||
check("gate registry detects an entry naming a missing target",
|
||||
len(f) == 1 and "ghost" in f[0].detail, f"{len(f)} finding(s)")
|
||||
|
||||
# CB-REV-0002 #7 generalised: a gate that does not run is not a
|
||||
# gate. Both directions, because a rule that cannot say NO is
|
||||
# decoration and one that cannot say YES fires on everything.
|
||||
with open(os.path.join(tmp, "Makefile"), "w") as fh:
|
||||
fh.write("all: coverage\ncoverage:\n\techo\npanels:\n\techo\n")
|
||||
with open(os.path.join(tmp, "gates.toml"), "w") as fh:
|
||||
fh.write('not_control_gates = []\n\n[[gate]]\nid = "G"\n'
|
||||
'name = "n"\ntarget = "coverage"\ncadence = "all"\n'
|
||||
'checks = "c"\n\n[[gate]]\nid = "P"\nname = "p"\n'
|
||||
'target = "panels"\ncadence = "all"\nchecks = "c"\n')
|
||||
f = check_gate_registry(tmp)
|
||||
check("gates: a cadence=all gate absent from `make all` is caught",
|
||||
len(f) == 1 and "does not run it" in f[0].detail,
|
||||
"the panels gate passed lint while running nowhere")
|
||||
with open(os.path.join(tmp, "gates.toml"), "w") as fh:
|
||||
fh.write('not_control_gates = []\n\n[[gate]]\nid = "G"\n'
|
||||
'name = "n"\ntarget = "coverage"\nchecks = "c"\n')
|
||||
check("gates: a gate with no declared cadence is caught",
|
||||
any("declares no cadence" in x.detail for x in check_gate_registry(tmp)))
|
||||
with open(os.path.join(tmp, "gates.toml"), "w") as fh:
|
||||
fh.write('not_control_gates = []\n\n[[gate]]\nid = "G"\n'
|
||||
'name = "n"\ntarget = "panels"\ncadence = "manual"\n'
|
||||
'checks = "c"\n\n[[gate]]\nid = "C"\nname = "c"\n'
|
||||
'target = "coverage"\ncadence = "all"\nchecks = "c"\n')
|
||||
check("gates: a gate may be manual, and saying so clears it",
|
||||
not check_gate_registry(tmp),
|
||||
"without this every manual gate would fire")
|
||||
os.unlink(os.path.join(tmp, "gates.toml"))
|
||||
os.unlink(os.path.join(tmp, "Makefile"))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue