More test leaning: a temp-file macro and a match matcher#2085
Merged
Conversation
- projectile-test-with-temp-files: bind vars to fresh temp files (or directories) and clean them up on exit, replacing the manual make-temp-file + unwind-protect + delete-file dance. Applied where it's a clean win (the file-only session specs); most temp-file specs also manage buffers and keep their own unwind-protect. - :to-be-a-match-with: a custom matcher that checks a projectile-replace--match's fields against a plist in one expect (naming every field that didn't match), plus projectile-test-find-match. Collapses the multi-expect match-assertion blocks in the search specs.
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.
Continues the test-readability pass (items #1 and #2 from the audit).
projectile-test-with-temp-files- binds vars to fresh temp files or:dirtemp directories and removes them on exit (normally or via error), replacing themake-temp-file+unwind-protect+delete-filedance. Applied where it's a clean win (file-only session specs). Most temp-file specs also open buffers and keep their ownunwind-protect, so the macro only marginally helps there - I left those rather than risk their cleanup semantics.:to-be-a-match-with- a custom matcher checking aprojectile-replace--match's fields against a plist in a singleexpect, naming every field that didn't match; plusprojectile-test-find-match. Collapses the multi-expectmatch-assertion blocks, e.g.889 specs green, clean
--warnings-as-errors, relint clean.On the other two audit items: #4 (
:to-be-truthysweep) turns out not to be a safe blanket change - many:to-be tassertions are genuine exact-tchecks (e.g. a file-kind marker that is the symbolt), and swapping them to:to-be-truthywould weaken them; I'd only do it case by case. #3 (cl-letf->spy-on) is a large, delicate churn (relation-test alone has 45) for a readability-only gain, and somecl-letfoverrides can't be expressed as spies; I'd do it selectively as its own PR rather than a blanket rewrite. Happy to proceed on either if you'd like.