Skip to content

Commit 62a3fae

Browse files
committed
feat: initial commit
0 parents  commit 62a3fae

8 files changed

Lines changed: 686 additions & 0 deletions

File tree

cmd/paralleltestctx/main.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package main
2+
3+
import (
4+
"github.com/coder/paralleltestctx/pkg/paralleltestctx"
5+
"golang.org/x/tools/go/analysis/singlechecker"
6+
)
7+
8+
func main() { singlechecker.Main(paralleltestctx.Analyzer()) }

cmd/plugin/plugin.go

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package plugin
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/coder/paralleltestctx/pkg/paralleltestctx"
7+
"github.com/golangci/plugin-module-register/register"
8+
"golang.org/x/tools/go/analysis"
9+
)
10+
11+
func init() {
12+
register.Plugin("paralleltestctx", New)
13+
}
14+
15+
func New(settings any) (register.LinterPlugin, error) {
16+
s, ok := settings.(map[string]any)
17+
if !ok {
18+
return nil, fmt.Errorf("expect paralleltestctx's configurations to be a map[string]string, got %T", settings)
19+
}
20+
conf := make(map[string]string, len(s))
21+
for k, v := range s {
22+
vStr, ok := v.(string)
23+
if !ok {
24+
return nil, fmt.Errorf("expect paralleltestctx's configuration values for %q to be strings, got %T", k, v)
25+
}
26+
conf[k] = vStr
27+
}
28+
return &parallelTestCtxPlugin{conf: conf}, nil
29+
}
30+
31+
type parallelTestCtxPlugin struct {
32+
conf map[string]string
33+
}
34+
35+
func (p *parallelTestCtxPlugin) BuildAnalyzers() ([]*analysis.Analyzer, error) {
36+
analyzer := paralleltestctx.Analyzer()
37+
for k, v := range p.conf {
38+
if err := analyzer.Flags.Set(k, v); err != nil {
39+
return nil, fmt.Errorf("set config flag %s with %s: %w", k, v, err)
40+
}
41+
}
42+
return []*analysis.Analyzer{analyzer}, nil
43+
}
44+
45+
func (p *parallelTestCtxPlugin) GetLoadMode() string { return register.LoadModeTypesInfo }

go.mod

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module github.com/coder/paralleltestctx
2+
3+
go 1.24.6
4+
5+
require (
6+
github.com/golangci/plugin-module-register v0.1.2
7+
golang.org/x/tools v0.36.0
8+
)
9+
10+
require (
11+
golang.org/x/mod v0.27.0 // indirect
12+
golang.org/x/sync v0.16.0 // indirect
13+
)

go.sum

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
github.com/golangci/plugin-module-register v0.1.2 h1:e5WM6PO6NIAEcij3B053CohVp3HIYbzSuP53UAYgOpg=
2+
github.com/golangci/plugin-module-register v0.1.2/go.mod h1:1+QGTsKBvAIvPvoY/os+G5eoqxWn70HYDm2uvUyGuVw=
3+
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
4+
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
5+
golang.org/x/mod v0.27.0 h1:kb+q2PyFnEADO2IEF935ehFUXlWiNjJWtRNgBLSfbxQ=
6+
golang.org/x/mod v0.27.0/go.mod h1:rWI627Fq0DEoudcK+MBkNkCe0EetEaDSwJJkCcjpazc=
7+
golang.org/x/sync v0.16.0 h1:ycBJEhp9p4vXvUZNszeOq0kGTPghopOL8q0fq3vstxw=
8+
golang.org/x/sync v0.16.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
9+
golang.org/x/tools v0.36.0 h1:kWS0uv/zsvHEle1LbV5LE8QujrxB3wfQyxHfhOk0Qkg=
10+
golang.org/x/tools v0.36.0/go.mod h1:WBDiHKJK8YgLHlcQPYQzNCkUxUypCaa5ZegCVutKm+s=

0 commit comments

Comments
 (0)