Fix "Run current test" matching tests with similar names#3140
Merged
PEZ merged 2 commits intoBetterThanTomorrow:devfrom Mar 21, 2026
Merged
Fix "Run current test" matching tests with similar names#3140PEZ merged 2 commits intoBetterThanTomorrow:devfrom
PEZ merged 2 commits intoBetterThanTomorrow:devfrom
Conversation
❌ Deploy Preview for calva-docs failed.
|
The search regex used word boundaries (\b) which don't work correctly with hyphenated Clojure test names — "a-test" would also match "b-a-test" and "a-test-b" because hyphens are word boundaries. Replace with a pattern that anchors on the namespace separator (/) and end-of-string ($), so only the exact test name matches against the namespace-qualified var name returned by orchard. Extract the pattern into a testable testNameSearchPattern() function and add unit tests. Fixes BetterThanTomorrow#2168
d72caed to
70dd320
Compare
Collaborator
|
Thanks again! ❤️ |
jramosg
pushed a commit
to jramosg/calva
that referenced
this pull request
Mar 28, 2026
…xact-match Fix "Run current test" matching tests with similar names * Fixes BetterThanTomorrow#2168
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.
What has changed?
"Run current test" was running all tests whose names contained the target name as a substring. For example, running
a-testwould also runb-a-testanda-test-b.The search regex used
\b(word boundaries) to match test names, but hyphens are word boundary characters in regex. So\ba-test\bmatchesa-testinsideb-a-testbecause-is a boundary.Replaced
\b...\bwith/...$— anchoring on the namespace separator (/) and end-of-string ($). This works because cider-nrepl's orchard usesre-findagainst namespace-qualified var names likemy.ns/a-test. The namespace is already filtered byns-query, so we only need to match the name portion exactly.Previous attempts to use
^...$failed becauseescapeStringRegexpescapes^and$. The fix puts the anchors outside the escape call.Extracted the pattern into a testable
testNameSearchPattern()function with 5 unit tests.Fixes #2168
My Calva PR Checklist
I have:
devbranch. (Or have specific reasons to target some other branch.)published. (Sorry for the nagging.)[Unreleased]entry inCHANGELOG.md, linking the issue(s) that the PR is addressing.[ ] Added to or updated docs in this branch, if appropriate(no docs changes needed)npm run prettier-format)npm run eslintbefore creating your PR, or runnpm run eslint-watchto eslint as you go).