Use spy-on for the clearest cl-letf stubs (selective)#2086
Merged
Conversation
Convert the crystal-clear cases where a spec stubbed one ordinary function with a constant/simple lambda: the buffer-file-name stubs in the toggle-related-file specs and the completing-read stubs in the projectile-read-variable specs. spy-on reads better and buttercup restores it automatically. Left the messier cl-letf uses alone on purpose: the relation specs stub primitives (file-exists-p, file-relative-name) several at a time, the test-at-point specs fake tree-sitter primitives, the replace-review helpers scope pop-to-buffer narrowly to dodge buttercup's interactive-form check, and a few rely on cl-letf setting a function to nil (unbinding), which spy-on can't express.
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.
A deliberately small, safe pass converting only the crystal-clear
cl-letf ((symbol-function ...))stubs tospy-on:buffer-file-namestubs in theprojectile-toggle-related-filespecs (one ordinary function, constant or simple value)completing-readstubs in theprojectile-read-variablespecsspy-onreads better and buttercup restores it automatically per spec.Left the messier
cl-letfuses alone on purpose - they're not safe/clean spy-on candidates:file-exists-p,file-relative-name), several at oncepop-to-buffernarrowly to dodge buttercup's interactive-form check on a spied commandnil(unbinding), whichspy-oncan't express889 specs green, clean
--warnings-as-errors, relint clean.