diff options
| author | Craig Jennings <c@cjennings.net> | 2026-06-15 11:21:41 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-06-15 11:21:41 -0500 |
| commit | 4f0a8d80fe208e67f6debac430024053c6958729 (patch) | |
| tree | 2efe74803c693498f863c54a1fb6f5b4d59dee1b /tests | |
| parent | 7bcf6dad2b1078994346b61531bce281a75519f9 (diff) | |
| download | dotemacs-4f0a8d80fe208e67f6debac430024053c6958729.tar.gz dotemacs-4f0a8d80fe208e67f6debac430024053c6958729.zip | |
refactor(themes): retire dupre, fall back to modus-vivendi
WIP, the theme-studio export, is the active theme. dupre was only the fallback and a structural reference. Move the fallback to the built-in modus-vivendi, guaranteed present everywhere this config loads. Delete the three dupre files plus its test and palette assets, and fix the stale comments that pointed at dupre-faces.el for the auto-dim and org-keyword faces (those moved to org-faces-config.el). Repoint the dupre-clear-theme spec's palette reference to git history.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test-build-theme.el | 4 | ||||
| -rw-r--r-- | tests/test-dupre-theme.el | 261 | ||||
| -rw-r--r-- | tests/test-ui-theme-commands.el | 12 | ||||
| -rw-r--r-- | tests/test-ui-theme-persistence.el | 4 |
4 files changed, 9 insertions, 272 deletions
diff --git a/tests/test-build-theme.el b/tests/test-build-theme.el index 9221946e6..6c2fa3cf5 100644 --- a/tests/test-build-theme.el +++ b/tests/test-build-theme.el @@ -1,4 +1,4 @@ -;;; test-build-theme.el --- Tests for the theme.json -> dupre-*.el converter -*- lexical-binding: t -*- +;;; test-build-theme.el --- Tests for the theme.json -> deftheme converter -*- lexical-binding: t -*- ;;; Commentary: @@ -74,7 +74,7 @@ drift the way Craig's downloaded exports under scripts/theme-studio/ can.") (unwind-protect (progn ,@body) (delete-directory ,var t)))) -;; --- WCAG contrast helpers (mirror of the dupre-theme test helpers) --- +;; --- WCAG contrast helpers --- (defun test-build-theme--channel-luminance (c) "Linearize an 8-bit channel value C (0-255) per the WCAG formula." diff --git a/tests/test-dupre-theme.el b/tests/test-dupre-theme.el deleted file mode 100644 index 4d0e786cb..000000000 --- a/tests/test-dupre-theme.el +++ /dev/null @@ -1,261 +0,0 @@ -;;; test-dupre-theme.el --- Tests for dupre-theme -*- lexical-binding: t -*- - -;;; Commentary: - -;; ERT tests for the dupre-theme. - -;;; Code: - -(require 'ert) - -;; Add themes directory to load-path and custom-theme-load-path -(let ((themes-dir (expand-file-name "../themes" (file-name-directory (or load-file-name buffer-file-name))))) - (add-to-list 'load-path themes-dir) - (add-to-list 'custom-theme-load-path themes-dir)) - -(require 'dupre-palette) - -;;; Palette tests - -(ert-deftest dupre-palette-exists () - "Palette constant should be defined." - (should (boundp 'dupre-palette)) - (should (listp dupre-palette))) - -(ert-deftest dupre-palette-has-base-colors () - "Palette should contain essential base colors." - (should (assq 'bg dupre-palette)) - (should (assq 'fg dupre-palette)) - (should (assq 'bg+1 dupre-palette)) - (should (assq 'bg+2 dupre-palette))) - -(ert-deftest dupre-palette-has-accent-colors () - "Palette should contain accent colors." - (should (assq 'yellow dupre-palette)) - (should (assq 'blue dupre-palette)) - (should (assq 'green dupre-palette)) - (should (assq 'red dupre-palette))) - -(ert-deftest dupre-palette-colors-are-hex () - "All palette colors should be valid hex strings." - (dolist (entry dupre-palette) - (let ((color (cadr entry))) - (should (stringp color)) - (should (string-match-p "^#[0-9a-fA-F]\\{6\\}$" color))))) - -(ert-deftest dupre-get-color-base () - "dupre-get-color should retrieve base colors." - (should (string= (dupre-get-color 'bg) "#151311")) - (should (string= (dupre-get-color 'fg) "#f0fef0")) - (should (string= (dupre-get-color 'yellow) "#d7af5f"))) - -(ert-deftest dupre-get-color-semantic () - "dupre-get-color should resolve semantic mappings." - (should (string= (dupre-get-color 'accent) (dupre-get-color 'yellow))) - (should (string= (dupre-get-color 'err) (dupre-get-color 'intense-red))) - (should (string= (dupre-get-color 'success) (dupre-get-color 'green)))) - -(ert-deftest dupre-get-color-unknown-errors () - "dupre-get-color should error on unknown colors." - (should-error (dupre-get-color 'nonexistent-color))) - -(ert-deftest dupre-with-colors-binds-values () - "dupre-with-colors should bind palette colors as variables." - (dupre-with-colors - (should (string= bg "#151311")) - (should (string= fg "#f0fef0")) - (should (string= yellow "#d7af5f")) - (should (string= blue "#67809c")))) - -(ert-deftest dupre-with-colors-binds-semantic () - "dupre-with-colors should bind semantic colors resolved to values." - (dupre-with-colors - (should (string= accent "#d7af5f")) - (should (string= err "#ff2a00")) - (should (string= success "#a4ac64")))) - -;;; Theme loading tests - -(ert-deftest dupre-theme-loads () - "Theme should load without errors." - (load-theme 'dupre t) - (should (memq 'dupre custom-enabled-themes))) - -(ert-deftest dupre-theme-default-face () - "dupre-theme should set the default face correctly." - (load-theme 'dupre t) - (let ((bg (face-attribute 'default :background)) - (fg (face-attribute 'default :foreground))) - (should (string= bg "#151311")) - (should (string= fg "#f0fef0")))) - -(ert-deftest dupre-theme-comment-face-italic () - "Comments should be rendered in italic slant." - (load-theme 'dupre t) - (should (eq (face-attribute 'font-lock-comment-face :slant) 'italic))) - -(ert-deftest dupre-theme-keyword-face () - "Keywords should use blue color." - (load-theme 'dupre t) - (should (string= (face-attribute 'font-lock-keyword-face :foreground) "#67809c"))) - -(ert-deftest dupre-theme-string-face () - "Strings should use green color." - (load-theme 'dupre t) - (should (string= (face-attribute 'font-lock-string-face :foreground) "#a4ac64"))) - -(ert-deftest dupre-theme-function-face () - "Functions should use terracotta color." - (load-theme 'dupre t) - (should (string= (face-attribute 'font-lock-function-name-face :foreground) "#a7502d"))) - -;;; Org-mode face tests (require org to be loaded) -;; Note: org-level-N faces use :inherit dupre-heading-N -;; We verify inheritance is set up correctly by checking the inherit attribute - -(ert-deftest dupre-theme-org-level-1 () - "Org level 1 should inherit from dupre-heading-1." - (require 'org) - (load-theme 'dupre t) - ;; Verify the inheritance relationship is set - (should (eq (face-attribute 'org-level-1 :inherit) 'dupre-heading-1))) - -(ert-deftest dupre-theme-org-level-2 () - "Org level 2 should inherit from dupre-heading-2." - (require 'org) - (load-theme 'dupre t) - ;; Verify the inheritance relationship is set - (should (eq (face-attribute 'org-level-2 :inherit) 'dupre-heading-2))) - -(ert-deftest dupre-theme-org-todo () - "Org TODO should use intense-red." - (require 'org) - (load-theme 'dupre t) - (should (string= (face-attribute 'org-todo :foreground) "#ff2a00"))) - -(ert-deftest dupre-theme-org-done () - "Org DONE should use green." - (require 'org) - (load-theme 'dupre t) - (should (string= (face-attribute 'org-done :foreground) "#a4ac64"))) - -;;; Diff face tests (require diff-mode to be loaded) - -(ert-deftest dupre-theme-diff-added () - "Diff added should use green foreground." - (require 'diff-mode) - (load-theme 'dupre t) - (should (string= (face-attribute 'diff-added :foreground) "#a4ac64"))) - -(ert-deftest dupre-theme-diff-removed () - "Diff removed should use red foreground." - (require 'diff-mode) - (load-theme 'dupre t) - (should (string= (face-attribute 'diff-removed :foreground) "#d47c59"))) - -;;; UI face tests - -(ert-deftest dupre-theme-mode-line () - "Mode line should have correct background." - (load-theme 'dupre t) - (should (string= (face-attribute 'mode-line :background) "#474544"))) - -(ert-deftest dupre-theme-region () - "Region should use bg+2 as background." - (load-theme 'dupre t) - (should (string= (face-attribute 'region :background) "#474544"))) - -;;; Vertico face tests (skip if vertico not available) - -(ert-deftest dupre-theme-vertico-current () - "Vertico current should use bg+2 background." - (skip-unless (require 'vertico nil t)) - (load-theme 'dupre t) - (should (string= (face-attribute 'vertico-current :background) "#474544"))) - -;;; Rainbow-delimiters tests (skip if package not available) - -(ert-deftest dupre-theme-rainbow-depth-1 () - "Rainbow depth 1 should use blue." - (skip-unless (require 'rainbow-delimiters nil t)) - (load-theme 'dupre t) - (should (string= (face-attribute 'rainbow-delimiters-depth-1-face :foreground) "#67809c"))) - -(ert-deftest dupre-theme-rainbow-depth-2 () - "Rainbow depth 2 should use gray+2." - (skip-unless (require 'rainbow-delimiters nil t)) - (load-theme 'dupre t) - (should (string= (face-attribute 'rainbow-delimiters-depth-2-face :foreground) "#d0cbc0"))) - -;;; Error/warning face tests - -(ert-deftest dupre-theme-error-face () - "Error face should use intense-red." - (load-theme 'dupre t) - (should (string= (face-attribute 'error :foreground) "#ff2a00"))) - -(ert-deftest dupre-theme-warning-face () - "Warning face should use yellow+1." - (load-theme 'dupre t) - (should (string= (face-attribute 'warning :foreground) "#ffd75f"))) - -(ert-deftest dupre-theme-success-face () - "Success face should use green." - (load-theme 'dupre t) - (should (string= (face-attribute 'success :foreground) "#a4ac64"))) - -;;; Face registration - -(ert-deftest dupre-semantic-faces-are-registered () - "Dupre's own faces must be real faces, not just theme specs. -An unregistered face renders only through `:inherit'; applied directly as -a text property (e.g. via `org-todo-keyword-faces') it silently fails. -The defface registration in dupre-faces.el is what makes direct use work." - (load-theme 'dupre t) - (dolist (face '(dupre-accent dupre-heading-1 - dupre-org-todo dupre-org-todo-dim - dupre-org-failed dupre-org-priority-a - dupre-org-priority-a-dim)) - (should (facep face))) - ;; and the theme colours them from the palette - (should (string= (face-attribute 'dupre-org-todo :foreground nil 'default) - "#a4ac64")) - (should (string= (face-attribute 'dupre-org-todo-dim :foreground nil 'default) - "#869038"))) - -;;; Diff face legibility (WCAG contrast) - -(defun dupre-test--channel-luminance (c) - "Linearize an 8-bit channel value C (0-255) per the WCAG formula." - (let ((x (/ c 255.0))) - (if (<= x 0.03928) (/ x 12.92) (expt (/ (+ x 0.055) 1.055) 2.4)))) - -(defun dupre-test--relative-luminance (hex) - "WCAG relative luminance of HEX color \"#rrggbb\"." - (+ (* 0.2126 (dupre-test--channel-luminance (string-to-number (substring hex 1 3) 16))) - (* 0.7152 (dupre-test--channel-luminance (string-to-number (substring hex 3 5) 16))) - (* 0.0722 (dupre-test--channel-luminance (string-to-number (substring hex 5 7) 16))))) - -(defun dupre-test--contrast (fg bg) - "WCAG contrast ratio between hex colors FG and BG." - (let ((l1 (dupre-test--relative-luminance fg)) - (l2 (dupre-test--relative-luminance bg))) - (/ (+ (max l1 l2) 0.05) (+ (min l1 l2) 0.05)))) - -(ert-deftest dupre-diff-changed-faces-meet-wcag-aa () - "Error/Regression: diff-changed and diff-refine-changed must stay legible as -standalone backgrounds (WCAG AA, >= 4.5:1 for normal text). Guards the bug -where diff-refine-changed rendered the default fg (#f0fef0) on the bright-gold -yellow-1 (#ffd700) at 1.35:1 -- unreadable wherever the face is used as a plain -background, not just inside diff-mode's own foreground overlay." - (require 'diff-mode) - (load-theme 'dupre t) - (dolist (face '(diff-changed diff-refine-changed)) - (let ((fg (face-attribute face :foreground nil t)) - (bg (face-attribute face :background nil t))) - (should (string-match-p "^#[0-9a-fA-F]\\{6\\}$" fg)) - (should (string-match-p "^#[0-9a-fA-F]\\{6\\}$" bg)) - (should (>= (dupre-test--contrast fg bg) 4.5))))) - -(provide 'test-dupre-theme) -;;; test-dupre-theme.el ends here diff --git a/tests/test-ui-theme-commands.el b/tests/test-ui-theme-commands.el index 55facc17e..4e3ce7f28 100644 --- a/tests/test-ui-theme-commands.el +++ b/tests/test-ui-theme-commands.el @@ -36,13 +36,11 @@ ;;; fallback-theme-name default -(ert-deftest test-ui-theme-default-fallback-is-bundled-dupre () - "Normal: the default fallback theme is dupre, the config's bundled theme. -modus-vivendi ships with Emacs but has no chosen dimming colors; dupre is -bundled in themes/, so it is available on every machine that loads this -config and is the right default fallback. Its loadability is covered by -test-dupre-theme.el." - (should (equal "dupre" (default-value 'fallback-theme-name)))) +(ert-deftest test-ui-theme-default-fallback-is-builtin-modus () + "Normal: the default fallback theme is modus-vivendi. +The fallback has no further fallback, so it must be present everywhere this +config loads. modus-vivendi ships with Emacs, so it always resolves." + (should (equal "modus-vivendi" (default-value 'fallback-theme-name)))) ;;; cj/save-theme-to-file diff --git a/tests/test-ui-theme-persistence.el b/tests/test-ui-theme-persistence.el index 31e0e6cc8..02bb105a6 100644 --- a/tests/test-ui-theme-persistence.el +++ b/tests/test-ui-theme-persistence.el @@ -46,12 +46,12 @@ (lambda (&rest _args) (setq write-file-called t) (error "write-file should not be used")))) - (should (cj/theme-write-file-contents "dupre" file))) + (should (cj/theme-write-file-contents "modus-vivendi" file))) (delete-file file)) (should (equal (list (car write-region-args) (cadr write-region-args) (nth 2 write-region-args)) - (list "dupre" nil file))) + (list "modus-vivendi" nil file))) (should-not write-file-called))) (ert-deftest test-ui-theme-load-valid-persisted-theme () |
