Skip to content

Lean up tests: a custom matcher and shared helpers#2084

Merged
bbatsov merged 1 commit into
masterfrom
test/buttercup-matchers-and-helpers
Jul 8, 2026
Merged

Lean up tests: a custom matcher and shared helpers#2084
bbatsov merged 1 commit into
masterfrom
test/buttercup-matchers-and-helpers

Conversation

@bbatsov

@bbatsov bbatsov commented Jul 8, 2026

Copy link
Copy Markdown
Owner

First slice of a test-readability pass. Buttercup 1.38 gives us custom matchers and helper hooks we weren't using at all (zero custom matchers in the suite); this introduces the highest-leverage ones and removes some duplication.

  • :to-have-same-items-as - an order-independent list-equality matcher whose failure message reports the missing/extra items. Replaces the (sort X #'string<) :to-equal (sort ...) boilerplate in the watch, indexing, async, consult and file-kinds specs, e.g.

    ;; before
    (expect (sort native #'string<) :to-equal (sort hybrid #'string<))
    ;; after
    (expect native :to-have-same-items-as hybrid)
  • projectile-test-match-sig - one shared match-signature helper, replacing the two near-identical --sig copies in the scan-async and search-review specs.

  • The search-review --wait now delegates to the existing shared projectile-test-wait-for pump instead of re-rolling the accept-process-output loop.

No behavior change; 889 specs green, clean --warnings-as-errors, relint clean.

More opportunities to follow if you want them (see the PR discussion): a with-temp-file helper macro for the ~35 make-temp-file+unwind-protect dances (mostly in the session/known-projects specs), an optional match-field matcher, and a :to-be-truthy sweep.

- Add a :to-have-same-items-as custom matcher (order-independent list
  equality with a missing/extra failure message) and use it in place of
  the (sort X #'string<) :to-equal (sort ...) dance across the watch,
  indexing, async, consult and file-kinds specs.
- Add a shared projectile-test-match-sig helper and drop the two nearly
  identical per-file --sig copies (scan-async, search-review).
- Make the search-review --wait delegate to the shared
  projectile-test-wait-for pump instead of re-rolling the event loop.

No behavior change; 889 specs green.
@bbatsov bbatsov merged commit d38233d 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