diff options
| author | Craig Jennings <c@cjennings.net> | 2026-04-26 17:59:59 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-04-26 17:59:59 -0500 |
| commit | 8f3c770e062a9aefec17f6b5f4f0a5ed927ac603 (patch) | |
| tree | bebb641f2046133eb43cc9c167bd5aeb8307ff31 | |
| parent | 9958ec4c4396ae8435f7e1818ff383c05df47a14 (diff) | |
| download | emacs-wttrin-8f3c770e062a9aefec17f6b5f4f0a5ed927ac603.tar.gz emacs-wttrin-8f3c770e062a9aefec17f6b5f4f0a5ed927ac603.zip | |
test: regression lock for nil :foreground in --make-emoji-icon
When wttrin-mode-line-emoji-font is set and the cache is fresh, --make-emoji-icon was emitting a face plist of the form (:family ... :height 1.0 :foreground nil). Emacs validates faces on every redisplay, so a single fresh-cache state produced hundreds of "Invalid face attribute :foreground nil" warnings in *Messages*.
The new boundary test asserts the face plist omits :foreground entirely when the caller passes nil. The assertion uses plist-member, not plist-get. plist-get returns nil for both a missing key and a present key bound to nil. That's the exact distinction Emacs's redisplay validator cares about.
| -rw-r--r-- | tests/test-wttrin--mode-line-helpers.el | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/test-wttrin--mode-line-helpers.el b/tests/test-wttrin--mode-line-helpers.el index d6811ba..34523a8 100644 --- a/tests/test-wttrin--mode-line-helpers.el +++ b/tests/test-wttrin--mode-line-helpers.el @@ -70,6 +70,17 @@ ;; Without font or foreground, should be plain string (should (equal result "☀"))))) +(ert-deftest test-wttrin--make-emoji-icon-boundary-nil-foreground-with-font () + "With font set and nil foreground, the face plist must omit :foreground entirely. +A literal `:foreground nil' entry triggers \"Invalid face attribute\" warnings on +every redisplay. `plist-member' (not `plist-get') is required: `plist-get' can't +distinguish a missing key from a present key bound to nil." + (let ((wttrin-mode-line-emoji-font "Noto Color Emoji")) + (let* ((result (wttrin--make-emoji-icon "☀" nil)) + (face (get-text-property 0 'face result))) + (should (equal (plist-get face :family) "Noto Color Emoji")) + (should-not (plist-member face :foreground))))) + ;;; -------------------------------------------------------------------------- ;;; wttrin--set-mode-line-string ;;; -------------------------------------------------------------------------- |
