Skip to content

Commit 8084467

Browse files
xcapaldildez
andauthored
paralleltest: expose checkcleanup option (#6477)
Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
1 parent b3ac139 commit 8084467

4 files changed

Lines changed: 14 additions & 2 deletions

File tree

.golangci.next.reference.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2312,10 +2312,15 @@ linters:
23122312
# Ignore missing calls to `t.Parallel()` and only report incorrect uses of it.
23132313
# Default: false
23142314
ignore-missing: true
2315-
# Ignore missing calls to `t.Parallel()` in subtests. Top-level tests are
2316-
# still required to have `t.Parallel`, but subtests are allowed to skip it.
2315+
# Ignore missing calls to `t.Parallel()` in subtests.
2316+
# Top-level tests are still required to have `t.Parallel`,
2317+
# but subtests are allowed to skip it.
23172318
# Default: false
23182319
ignore-missing-subtests: true
2320+
# Check that `defer` is not used with `t.Parallel`.
2321+
# (use `t.Cleanup` instead to ensure cleanup runs after parallel subtests complete).
2322+
# Default: false
2323+
check-cleanup: true
23192324

23202325
perfsprint:
23212326
# Enable/disable optimization of integer formatting.

jsonschema/golangci.next.jsonschema.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3048,6 +3048,11 @@
30483048
"description": "Ignore missing calls to `t.Parallel()` in subtests. Top-level tests are still required to have `t.Parallel`, but subtests are allowed to skip it.",
30493049
"type": "boolean",
30503050
"default": false
3051+
},
3052+
"check-cleanup": {
3053+
"description": "Check that defer is not used with t.Parallel (use t.Cleanup instead).",
3054+
"type": "boolean",
3055+
"default": false
30513056
}
30523057
}
30533058
},

pkg/config/linters_settings.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -820,6 +820,7 @@ type ParallelTestSettings struct {
820820
Go string `mapstructure:"-"`
821821
IgnoreMissing bool `mapstructure:"ignore-missing"`
822822
IgnoreMissingSubtests bool `mapstructure:"ignore-missing-subtests"`
823+
CheckCleanup bool `mapstructure:"check-cleanup"`
823824
}
824825

825826
type PerfSprintSettings struct {

pkg/golinters/paralleltest/paralleltest.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ func New(settings *config.ParallelTestSettings) *goanalysis.Linter {
1414
cfg = map[string]any{
1515
"i": settings.IgnoreMissing,
1616
"ignoremissingsubtests": settings.IgnoreMissingSubtests,
17+
"checkcleanup": settings.CheckCleanup,
1718
}
1819

1920
if config.IsGoGreaterThanOrEqual(settings.Go, "1.22") {

0 commit comments

Comments
 (0)