Skip to content

Use spy-on for the clearest cl-letf stubs (selective)#2086

Merged
bbatsov merged 1 commit into
masterfrom
test/cl-letf-to-spy-on-selective
Jul 8, 2026
Merged

Use spy-on for the clearest cl-letf stubs (selective)#2086
bbatsov merged 1 commit into
masterfrom
test/cl-letf-to-spy-on-selective

Conversation

@bbatsov

@bbatsov bbatsov commented Jul 8, 2026

Copy link
Copy Markdown
Owner

A deliberately small, safe pass converting only the crystal-clear cl-letf ((symbol-function ...)) stubs to spy-on:

  • the buffer-file-name stubs in the projectile-toggle-related-file specs (one ordinary function, constant or simple value)
  • the completing-read stubs in the projectile-read-variable specs

spy-on reads better and buttercup restores it automatically per spec.

Left the messier cl-letf uses alone on purpose - they're not safe/clean spy-on candidates:

  • the relation specs stub primitives (file-exists-p, file-relative-name), several at once
  • 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 on a spied command
  • a few set a function to nil (unbinding), which spy-on can't express

889 specs green, clean --warnings-as-errors, relint clean.

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.
@bbatsov bbatsov merged commit 792cc06 into master Jul 8, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant