aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-06-21 02:16:42 -0400
committerCraig Jennings <c@cjennings.net>2026-06-21 02:16:42 -0400
commit4a8c572ba6a64be997be072b44ef5ff62674d820 (patch)
tree210e4e13238b4c73c4b62a3e4864827df64bec66 /tests
parent55922a54652d74d047a41728e5ce7b2f86d9a3d7 (diff)
downloaddotemacs-4a8c572ba6a64be997be072b44ef5ff62674d820.tar.gz
dotemacs-4a8c572ba6a64be997be072b44ef5ff62674d820.zip
fix: load games-config via the malyon hook, not an autoload chain
The previous deferral (03d8b587) autoloaded malyon to games-config, but games-config doesn't define malyon. It leaves the command to the malyon package, so M-x malyon loaded games-config, found malyon still undefined, and errored "Autoloading games-config.el failed to define function malyon". Emacs won't chain through a second autoload. malyon and 2048-game autoload their own commands via package.el, so games-config should never own them. init.el now loads games-config via (with-eval-after-load 'malyon ...), and games-config just sets malyon-stories-directory when malyon loads. M-x malyon loads the package as a real command, then games-config applies its config. The earlier batch check loaded the files by hand and missed the autoload failure. The new test resolves the autoload the way M-x does (autoload-do-load), so the real path is covered now.
Diffstat (limited to 'tests')
-rw-r--r--tests/test-init-defer-games.el36
1 files changed, 22 insertions, 14 deletions
diff --git a/tests/test-init-defer-games.el b/tests/test-init-defer-games.el
index 0b85a1ea7..f3ec94de8 100644
--- a/tests/test-init-defer-games.el
+++ b/tests/test-init-defer-games.el
@@ -1,10 +1,12 @@
;;; test-init-defer-games.el --- games-config Phase 4 deferral -*- lexical-binding: t; -*-
;;; Commentary:
-;; games-config is deferred (load-graph Phase 4): init.el autoloads `malyon'
-;; and `2048-game' instead of requiring the module eagerly. These tests guard
-;; that the game commands stay reachable with the module unloaded, and that
-;; loading the module still applies the one setting it owns.
+;; games-config is deferred (load-graph Phase 4): malyon and 2048-game autoload
+;; their own commands via package.el, and init.el loads games-config (which only
+;; supplies malyon's config) via `with-eval-after-load 'malyon'. These tests
+;; guard the command availability and exercise the real autoload-invocation path
+;; that M-x uses, which is where an earlier cut regressed ("Autoloading
+;; games-config.el failed to define function malyon").
;;; Code:
@@ -13,25 +15,31 @@
(ert-deftest test-init-defer-games-commands-autoload-without-module ()
"Normal: the game commands resolve with games-config unloaded.
-This is the safety net for the deferral -- dropping the eager require keeps
-malyon and 2048-game reachable only because the packages autoload their own
-commands, so assert that holds."
+Dropping the eager require keeps malyon and 2048-game reachable only because the
+packages autoload their own commands, so assert that holds."
(package-initialize)
(should-not (featurep 'games-config))
(should (commandp 'malyon))
(should (commandp '2048-game)))
-(ert-deftest test-init-defer-games-config-applies-malyon-stories-dir ()
- "Normal: loading games-config still applies malyon's stories directory.
-The module is the config owner; deferring it must not drop the one setting it
-adds (`malyon-stories-directory'), which use-package applies when malyon loads."
+(ert-deftest test-init-defer-games-malyon-loads-and-configures ()
+ "Normal: resolving malyon's autoload yields a real command and applies config.
+Reproduces the M-x malyon path via `autoload-do-load': malyon autoloads from its
+own package, init.el's `with-eval-after-load 'malyon' loads games-config, and
+games-config sets the stories directory. This is the regression guard for the
+earlier cut that autoloaded malyon to games-config, where Emacs errored that the
+load failed to define malyon."
(package-initialize)
(add-to-list 'load-path (expand-file-name "modules" default-directory))
(require 'user-constants)
+ (unless (and (fboundp 'malyon) (autoloadp (symbol-function 'malyon)))
+ (ert-skip "malyon package not available as an autoload"))
(let ((org-dir "/tmp/games-defer-test/"))
- (load "games-config" nil t)
- (unless (require 'malyon nil t)
- (ert-skip "malyon package not available"))
+ (with-eval-after-load 'malyon (require 'games-config)) ; the init.el wiring
+ (should-not (featurep 'games-config))
+ (should (functionp (autoload-do-load (symbol-function 'malyon) 'malyon)))
+ (should (commandp 'malyon))
+ (should (featurep 'games-config))
(should (equal malyon-stories-directory "/tmp/games-defer-test/text.games/"))))
(provide 'test-init-defer-games)