Improve font-lock test failure messages with a :to-have-face matcher#704
Merged
Conversation
The face helpers asserted with a bare (expect ACTUAL :to-equal EXPECTED), so a failure read "Expected face-a to equal face-b" with no hint of which token was wrong. Add a :to-have-face matcher that resolves a substring (searched from point), a position, or a (START END) range and reports e.g. "Expected \"def\" to have face font-lock-string-face, but it had font-lock-keyword-face". Route expect-face-at, expect-face-of and clojure-test--check-faces (hence when-fontifying-it) through it, so the whole font-lock suite gains the better messages.
Replace (cl-letf ((symbol-function ...))) with buttercup's spy-on, which auto-restores after each spec. The clojure-project-relative-path check was a bare expect directly under describe (so it never ran as a spec); wrap it in an it, which both fixes that and lets it use spy-on.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The font-lock helpers assert faces with a bare
(expect actual :to-equal expected)insideclojure-test--check-faces/expect-face-of, so a failure just says "Expectedfont-lock-string-faceto equalfont-lock-keyword-face" - with no hint of which token was wrong.This adds a
:to-have-facematcher that takes a substring (searched from point, as the helpers already did), a position, or a(START END)range, and reports things like:expect-face-at,expect-face-ofandclojure-test--check-faces(sowhen-fontifying-it) route through it, so the whole font-lock suite gets the better messages with no call-site changes.Second commit swaps the three
cl-letfproject stubs forspy-on(auto-restores per spec). One of them was a bareexpectdirectly underdescribe, so it never actually ran as a spec - it's now wrapped in anit.Test-only; 433 specs, unchanged behavior.