From d3cbf438e1d7c14061cf3d835d4e0b39a707491d 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. --- modules/org-refile-config.el | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'modules/org-refile-config.el') diff --git a/modules/org-refile-config.el b/modules/org-refile-config.el index 63343e9f5..16b37bf98 100644 --- a/modules/org-refile-config.el +++ b/modules/org-refile-config.el @@ -101,13 +101,14 @@ so caching improves performance from 15-20 seconds to instant." (- (float-time) (float-time start-time))))))) (setq org-refile-targets targets))) -;; Build cache asynchronously after startup to avoid blocking Emacs -(run-with-idle-timer - 5 ; Wait 5 seconds after Emacs is idle - nil ; Don't repeat - (lambda () - (cj/log-silently "Building org-refile targets cache in background...") - (cj/build-org-refile-targets))) +;; Build cache asynchronously after startup to avoid blocking Emacs. +(unless noninteractive + (run-with-idle-timer + 5 ; Wait 5 seconds after Emacs is idle + nil ; Don't repeat + (lambda () + (cj/log-silently "Building org-refile targets cache in background...") + (cj/build-org-refile-targets)))) (defun cj/org-refile-refresh-targets () "Force rebuild of refile targets cache. -- cgit v1.2.3