From c3420106b57b999db6526c62c1ce0e33c28ef121 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Fri, 15 May 2026 02:13:37 -0500 Subject: test(architecture): guard top-level timers + add startup-contract smoke test Add a tiny source-level architecture suite at tests/test-architecture-startup-contracts.el with two checks: - Only keybindings.el may globally own the exact C-; prefix. Catches accidental cross-module rebinding before it ships. - Top-level timer scheduling (run-with-timer / run-at-time / run-with-idle-timer) must be guarded by (unless noninteractive ...) so requiring a module in batch / test mode does not schedule startup timers. Timer calls inside defuns are exempt -- the test only rejects forms that execute their body when the module loads. Four modules had unguarded top-level timer scheduling and would have tripped the new test. Wrap their startup hooks/timers in (unless noninteractive ...): - modules/org-agenda-config.el: 10s idle cache build - modules/org-refile-config.el: 5s idle cache build - modules/quick-video-capture.el: after-init-hook + 2s fallback - modules/wrap-up.el: emacs-startup-hook bury-buffers delay The contract being protected is "requiring a module in batch should not start a clock running." Test failures will now point straight at the offending file/form. --- todo.org | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'todo.org') diff --git a/todo.org b/todo.org index 917cef5d0..4c7bfed0f 100644 --- a/todo.org +++ b/todo.org @@ -853,7 +853,8 @@ Done 2026-05-15: - Updated =tests/test-coverage-summary.el= to assert the policy and the displayed project-module percentage. -*** TODO [#B] Add a lightweight architecture smoke test for startup contracts :tests: +*** DONE [#B] Add a lightweight architecture smoke test for startup contracts :tests: +CLOSED: [2026-05-15 Fri] After the above refactors start, add one or two smoke tests that protect the architecture instead of individual functions. @@ -867,6 +868,17 @@ Candidate checks: Keep this small. The goal is to catch accidental return to hidden load-order coupling, not to build a full static analyzer. +Done 2026-05-15: +- Added =tests/test-architecture-startup-contracts.el= with two source-level + smoke checks: + - only =keybindings.el= may globally own the exact =C-;= prefix; + - top-level timer scheduling forms must be guarded by =noninteractive= so + batch/test loads do not schedule startup timers. +- Gated existing startup timers in =org-agenda-config.el=, + =org-refile-config.el=, =quick-video-capture.el=, and =wrap-up.el=. +- Focused tests passed for the new architecture smoke file and the affected + agenda/refile helpers. + ** PROJECT [#B] Module-by-module review and hardening :review: Review every file in =modules/= and capture concrete bugs, tests, refactors, -- cgit v1.2.3