diff options
| author | Craig Jennings <c@cjennings.net> | 2026-06-21 01:57:44 -0400 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-06-21 01:57:44 -0400 |
| commit | 03d8b587b1f49073d94bd0c4114fe09e832183f8 (patch) | |
| tree | c4b1c5e2289206bbd70563c866f4882d19221ac8 /tests | |
| parent | c4a36132d537f7dd5a7c8e429cbd9b0ec4e44abe (diff) | |
| download | dotemacs-03d8b587b1f49073d94bd0c4114fe09e832183f8.tar.gz dotemacs-03d8b587b1f49073d94bd0c4114fe09e832183f8.zip | |
refactor: defer games-config behind autoloads (load-graph Phase 4)
init.el eagerly required games-config at startup just to configure two on-demand game packages. package.el already autoloads malyon and 2048-game, so the eager require bought nothing but the one setting the module adds (malyon-stories-directory).
init.el now autoloads malyon and 2048-game to games-config instead of requiring it. The first game command loads the module, which configures then loads the package. Startup no longer touches games-config, and both the commands and the stories-directory setting still work. This is the first module of the Phase 4 low-risk batch.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test-init-defer-games.el | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/test-init-defer-games.el b/tests/test-init-defer-games.el new file mode 100644 index 000000000..0b85a1ea7 --- /dev/null +++ b/tests/test-init-defer-games.el @@ -0,0 +1,38 @@ +;;; 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. + +;;; Code: + +(require 'ert) +(require 'package) + +(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." + (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." + (package-initialize) + (add-to-list 'load-path (expand-file-name "modules" default-directory)) + (require 'user-constants) + (let ((org-dir "/tmp/games-defer-test/")) + (load "games-config" nil t) + (unless (require 'malyon nil t) + (ert-skip "malyon package not available")) + (should (equal malyon-stories-directory "/tmp/games-defer-test/text.games/")))) + +(provide 'test-init-defer-games) +;;; test-init-defer-games.el ends here |
