Files
felhom-controller/controller/scripts/test_controller_gates.py
T
admin f946b0d0ca
gates / gates (push) Successful in 12s
gates: the newest release header must state its MinAgent; backfill v0.233.0-v0.236.0 (R-470, R-472)
From hub v0.112.0 a floor above the golden is served only with a declared
MinAgent, read from this CHANGELOG's newest `## vX.Y.Z` header. New fast,
blocking gate minagent_header_gate.py: that block must contain a line
starting `**MinAgent: X.Y.Z**`; prose, a code span or a non-bold mention
does not count (decoy test; red-proof F: relaxing the match to a body
mention fails test_decoy_body_mention_is_not_the_line).

Backfill: v0.233.0, v0.234.0, v0.235.0 and v0.236.0 carried no MinAgent
line. Each now reads `**MinAgent: 0.129.0** (unchanged)`, the value of the
nearest earlier header (v0.232.0). Proof it did not move: zero commits
under controller/internal/agentapi since 2026-09-01 (last: bb50e12,
2026-08-14), and the highest featureMinAgent entry is 0.129.0.
2026-09-13 17:09:33 +02:00

71 lines
2.9 KiB
Python

# -*- coding: utf-8 -*-
"""Seam test for scripts/controller_gates.py.
Run from controller/: python3 scripts/test_controller_gates.py
WHY THIS EXISTS. An entry point is a seam by definition: a runner that LISTS a gate but never
executes it is inert and fully green, and this project has shipped an inert seam four times. So
the assertion is on each member gate's OWN distinctive stdout — never on the runner's summary
line, which the runner can print without ever calling anything — plus the exit code, which is a
runner's actual effect.
Red-proofed 2026-08-02: replacing run_gate's body with `return 0` (the inert runner) turns
test_every_member_gate_actually_ran red while the summary still prints "all controller gates OK".
"""
import os
import subprocess
import sys
import unittest
SCRIPTS = os.path.dirname(os.path.abspath(__file__))
CTRL = os.path.dirname(SCRIPTS)
ENTRY = os.path.join(SCRIPTS, "controller_gates.py")
# (label, a substring only THAT gate can print)
FINGERPRINTS = [
("template-id", "integrity gate OK — every JS element-ID reference"),
("emoji", "emoji gate OK"),
("native-confirm", "native-confirm gate OK"),
("offbox-rename", "offbox rename gate OK"),
("app-row-dedup", "app_row_dedup_gate: OK"),
("mojibake", "mojibake_gate: OK"),
("docker-v", "docker -v gate OK"),
("debug-routes", "debug route gate OK"),
("reuse-refs", "cited paths — exact"),
("minagent-header", "minagent header gate OK"),
]
class ControllerGatesTest(unittest.TestCase):
@classmethod
def setUpClass(cls):
p = subprocess.run([sys.executable, ENTRY, "--fast"], cwd=CTRL,
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
cls.rc = p.returncode
cls.out = p.stdout.decode("utf-8", "replace")
def test_exit_code_is_zero(self):
self.assertEqual(self.rc, 0, self.out)
def test_every_member_gate_actually_ran(self):
for label, fingerprint in FINGERPRINTS:
self.assertIn(fingerprint, self.out,
"gate %r is listed but its own output never appeared — an inert runner "
"prints the summary without calling anything:\n%s" % (label, self.out))
def test_shared_reuse_checker_is_not_copied_into_this_repo(self):
"""It lives in felhom.eu/scripts/ and is invoked across the workspace. A copy here would
recreate exactly the drift it exists to detect."""
self.assertFalse(os.path.exists(os.path.join(SCRIPTS, "reuse_refs_check.py")),
"reuse_refs_check.py must NOT be copied into this repo")
def test_unknown_argument_is_rejected(self):
p = subprocess.run([sys.executable, ENTRY, "--nope"], cwd=CTRL,
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
self.assertEqual(p.returncode, 2, p.stdout.decode("utf-8", "replace"))
if __name__ == "__main__":
unittest.main(verbosity=2)