Skip to content

Add ^:synchronized opt-out for parallel namespaces - #52

Merged
camsaul merged 1 commit into
mainfrom
synchronized-test-metadata
Aug 18, 2026
Merged

Add ^:synchronized opt-out for parallel namespaces#52
camsaul merged 1 commit into
mainfrom
synchronized-test-metadata

Conversation

@crisptrutski

@crisptrutski crisptrutski commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Why

Marking a namespace ^:parallel is a convenient way to opt many tests into concurrency at once. Occasionally one test in that namespace mutates global state or uses another shared resource and must run serially.

Hawk already supports that override through ^{:parallel false} on the test, but the map metadata is cumbersome for a common and important escape hatch. ^:synchronized makes the two execution choices concise and symmetric:

Scope Metadata Result
Namespace ^:parallel Tests run in parallel by default
Test ^:synchronized This test opts out and runs serially

What changed

  • Treat ^:synchronized as shorthand for ^{:parallel false} on tests and namespaces.
  • Preserve the existing Hawk precedence rule: test metadata overrides namespace metadata.
  • Document both override directions.
  • Cover synchronized tests in parallel namespaces, synchronized namespaces, and precedence combinations.

This is additive and backward-compatible; existing :parallel metadata keeps the same behavior.

Verification

  • clojure -X:dev:test — 35 tests, 180 assertions, 0 failures/errors
  • clojure -M:kondo --lint src test — 0 errors, 0 warnings

Follow-up consumer: metabase/metabase#80064

@crisptrutski
crisptrutski requested a review from camsaul as a code owner August 18, 2026 08:50
@crisptrutski crisptrutski changed the title Support ^:synchronized test metadata Add ^:synchronized opt-out for parallel namespaces Aug 18, 2026
@crisptrutski
crisptrutski requested a lite review from Copilot August 18, 2026 09:02

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds ^:synchronized metadata as a concise opt-out from parallel execution, complementing existing ^:parallel behavior while preserving the precedence rule that test-level metadata overrides namespace-level metadata.

Changes:

  • Extend mb.hawk.parallel/parallel? to treat ^:synchronized as shorthand for ^{:parallel false} at both var and namespace scope.
  • Add test coverage for :parallel / :synchronized precedence combinations.
  • Document opting out (^:synchronized) and opting in (^:parallel) behavior in the README.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/mb/hawk/parallel.clj Adds :synchronized handling via a helper and updates parallel? docstring.
test/mb/hawk/parallel_test.clj Updates/extends tests to cover synchronized behavior and precedence.
README.md Documents ^:synchronized and clarifies override directions and precedence.
Suppressed comments (1)

README.md:94

  • README grammar: “shouldn't be ran” should be “shouldn't be run”.
Hawk includes `mb.hawk.parallel/assert-test-is-not-parallel`, which you can use to make sure things that shouldn't be ran
in parallel tests are not:

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/mb/hawk/parallel.clj

(defn parallel?
"Whether `test-var` can be ran in parallel with other parallel tests."
"Whether `test-var` can be ran in parallel with other parallel tests.
Comment thread README.md
Comment on lines 80 to +81
Metabase test runner. All tests are ran synchronously unless they are given `^:parallel` metadata (either the test
itself, or the namespace).
itself, or the namespace). A test in a parallel namespace can explicitly opt out with `^:synchronized`:
@crisptrutski

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

Comment thread src/mb/hawk/parallel.clj
(defn- parallel-setting [metadata]
(if-some [parallel (:parallel metadata)]
parallel
(when (:synchronized metadata)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh what if someone puts ^{:synchronized false}? 😆

@camsaul camsaul left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me, 👍

@camsaul
camsaul merged commit 7d8eddb into main Aug 18, 2026
3 checks passed
@camsaul
camsaul deleted the synchronized-test-metadata branch August 18, 2026 16:18
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.

3 participants