test: enforce t.Parallel via paralleltest linter (closes #38)#53
Merged
Conversation
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.
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
Closes #38. The issue reported table-driven subtests missing
t.Parallel(). An AST sweep of the module shows that's already fixed — all 18t.Runsubtests callt.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
paralleltestlinter (the repo already runs golangci-lint with only thestandardset).How
.golangci.yml: addparalleltesttolinters.enable.Annotate the 6 legitimately-serial top-level tests with
//nolint:paralleltest+ reason:on/on_test.go×3 —testing.AllocsPerRunmeasurements must run serially (parallelism perturbs alloc counts).vt/vt_isolation_test.go×3 — they swap the process-globalhttp.DefaultTransport, so they cannot be parallel.Both reasons were already documented in nearby comments; the
//nolintmakes the serial choice explicit to the linter too.Verification
golangci-lint run ./...→ 0 issues withparalleltestenabled.t.Runwithoutt.Parallel()makes the linter fail with "Range statement … missing the call to method parallel in test Run" — exactly Several subtests omitt.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
-racesuite are the verification.