summaryrefslogtreecommitdiff
path: root/plugins/code-modernization/scripts/tests
diff options
context:
space:
mode:
authorMorgan Lunt <morganl@anthropic.com>2026-09-24 21:03:17 -0700
committerMorgan Lunt <morganl@anthropic.com>2026-09-24 21:03:17 -0700
commitd6af0c04d89ad7b0c75e21b8ae7f15585e805b08 (patch)
treed659939579cb7752a08e0ee48a5f50d1fcbe12df /plugins/code-modernization/scripts/tests
parent0c186cf8c54bdf925cb2572e871ec16d04aa8425 (diff)
code-modernization: a next step on the report, and tables that keep words whole
The report is the page people open first, but it never said what to do next. It now shows one command with a copy button and a one-line reason, decided from which artifacts exist (preflight through brief, a rule review before the plan when rules look wrong, verify after a build, harden, then status). Short words and verdict pills no longer break inside narrow table cells ("sam" and "e", "Calculatio" and "n"): only paths and hashes break anywhere.
Diffstat (limited to 'plugins/code-modernization/scripts/tests')
-rw-r--r--plugins/code-modernization/scripts/tests/test_report_next.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/plugins/code-modernization/scripts/tests/test_report_next.py b/plugins/code-modernization/scripts/tests/test_report_next.py
new file mode 100644
index 00000000..e73536ba
--- /dev/null
+++ b/plugins/code-modernization/scripts/tests/test_report_next.py
@@ -0,0 +1,43 @@
+"""Tests for the report's next-step decision (scripts/build_report.py next_step)."""
+import os
+import sys
+import unittest
+
+HERE = os.path.dirname(os.path.abspath(__file__))
+sys.path.insert(0, os.path.join(os.path.dirname(HERE)))
+import build_report as br # noqa: E402
+
+ALL = dict(preflight=True, assess=True, map=True, rules=True, brief=True, build=True, harden=True)
+
+
+class NextStep(unittest.TestCase):
+ def cmd(self, done, glance=None):
+ return br.next_step("sys", dict(ALL, **done), glance or {})["command"]
+
+ def test_the_path_in_order(self):
+ order = ["preflight", "assess", "map", "rules"]
+ for i, key in enumerate(order):
+ done = {k: False for k in order[i:]}
+ done.update(brief=False, build=False, harden=False)
+ self.assertTrue(self.cmd(done).startswith("/code-modernization:modernize-" + ["preflight", "assess", "map", "extract-rules"][i]))
+
+ def test_flagged_rules_go_to_review_once_and_then_on(self):
+ flagged = {"rules": {"defects": 2}}
+ self.assertIn("modernize-review", self.cmd({"brief": False}, flagged))
+ reviewed = {"rules": {"defects": 2, "reviews": {"confirmed": 1}}}
+ self.assertIn("modernize-brief", self.cmd({"brief": False}, reviewed))
+
+ def test_a_build_is_verified_before_anything_else(self):
+ self.assertIn("modernize-verify", self.cmd({"harden": False}))
+ self.assertIn("modernize-verify", self.cmd({"harden": False}, {"proof": {"verdict": "NOT PROVEN"}}))
+ self.assertIn("modernize-harden", self.cmd({"harden": False}, {"proof": {"verdict": "PROVEN"}}))
+
+ def test_everything_done_points_at_status_and_text_is_bounded(self):
+ step = br.next_step("s", ALL, {"proof": {"verdict": "PROVEN"}})
+ self.assertIn("modernize-status", step["command"])
+ hostile = br.next_step("s", ALL, {"proof": {"verdict": "X" * 5000}})
+ self.assertLess(len(hostile["why"]), 200)
+
+
+if __name__ == "__main__":
+ unittest.main()