Skip to content

test: enforce t.Parallel via paralleltest linter (closes #38)#53

Merged
joaomdsg merged 1 commit into
mainfrom
test/enforce-paralleltest-38
May 29, 2026
Merged

test: enforce t.Parallel via paralleltest linter (closes #38)#53
joaomdsg merged 1 commit into
mainfrom
test/enforce-paralleltest-38

Conversation

@joaomdsg

Copy link
Copy Markdown
Member

What

Closes #38. The issue reported table-driven subtests missing t.Parallel(). An AST sweep of the module shows that's already fixed — all 18 t.Run subtests call t.Parallel() as their first statement (the omissions were cleaned up during the #30 typed-API rewrite, after #38 was filed).

So rather than fix live offenders (there are none), this locks the convention in so it can't regress: enable the paralleltest linter (the repo already runs golangci-lint with only the standard set).

How

  • .golangci.yml: add paralleltest to linters.enable.

  • Annotate the 6 legitimately-serial top-level tests with //nolint:paralleltest + reason:

    • on/on_test.go ×3 — testing.AllocsPerRun measurements must run serially (parallelism perturbs alloc counts).
    • vt/vt_isolation_test.go ×3 — they swap the process-global http.DefaultTransport, so they cannot be parallel.

    Both reasons were already documented in nearby comments; the //nolint makes the serial choice explicit to the linter too.

Verification

  • golangci-lint run ./...0 issues with paralleltest enabled.
  • Guard proven: injecting a table-driven t.Run without t.Parallel() makes the linter fail with "Range statement … missing the call to method parallel in test Run" — exactly Several subtests omit t.Parallel() #38's pattern — then reverts to 0 issues.
  • gofmt -l . clean; go test -race ./... green across all packages.

Note on scope

No runtime/behavior change — this is test-suite + lint config only, so there's nothing browser-observable to verify; the linter run + full -race suite are the verification.

Every subtest already calls t.Parallel (the omissions #38 reported were
cleaned up in the typed-API rewrite), so this locks the convention in
rather than fixing live offenders: enable the paralleltest linter so a
future table-driven t.Run that forgets t.Parallel fails CI instead of
silently losing race coverage.

Six top-level tests are legitimately serial — three AllocsPerRun checks
in on/ and three vt/ tests that swap the process-global
http.DefaultTransport — so each carries a //nolint:paralleltest with the
reason, making the serial choice explicit rather than accidental.
@joaomdsg
joaomdsg merged commit 1434f7e into main May 29, 2026
4 checks passed
@joaomdsg
joaomdsg deleted the test/enforce-paralleltest-38 branch May 29, 2026 07:13
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.

Several subtests omit t.Parallel()

1 participant