Skip to content

Commit a6012a9

Browse files
committed
t.Parallel for all that's possible
1 parent 035a755 commit a6012a9

File tree

5 files changed

+28
-10
lines changed

5 files changed

+28
-10
lines changed

assert/goid_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
)
66

77
func TestGoid(t *testing.T) {
8+
t.Parallel()
89
stackBytes := []byte(`goroutine 518 [running]:
910
`)
1011

internal/debug/debug_test.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ func TestFullName(t *testing.T) {
3737
}
3838

3939
func TestIsAnchor(t *testing.T) {
40+
t.Parallel()
4041
type args struct {
4142
input string
4243
StackInfo
@@ -78,8 +79,10 @@ func TestIsAnchor(t *testing.T) {
7879
"github.com/lainio/err2/try.To1[...](...)",
7980
StackInfo{"lainio/err2", "", 0, nil, nil}}, true},
8081
}
81-
for _, tt := range tests {
82+
for _, ttv := range tests {
83+
tt := ttv
8284
t.Run(tt.name, func(t *testing.T) {
85+
t.Parallel()
8386
test.Require(t, tt.retval == tt.isAnchor(tt.input), "equal")
8487
})
8588
}
@@ -132,6 +135,7 @@ func TestIsFuncAnchor(t *testing.T) {
132135
}
133136

134137
func TestFnLNro(t *testing.T) {
138+
t.Parallel()
135139
tests := []struct {
136140
name string
137141
input string
@@ -141,8 +145,10 @@ func TestFnLNro(t *testing.T) {
141145
" /Users/harrilainio/go/pkg/mod/github.com/lainio/[email protected]/internal/handler/handler.go:69 +0xbc",
142146
69},
143147
}
144-
for _, tt := range tests {
148+
for _, ttv := range tests {
149+
tt := ttv
145150
t.Run(tt.name, func(t *testing.T) {
151+
t.Parallel()
146152
output := fnLNro(tt.input)
147153
test.Require(t, output == tt.output, output)
148154
})
@@ -210,6 +216,7 @@ func TestStackPrint_noLimits(t *testing.T) {
210216
}
211217

212218
func TestStackPrintForTest(t *testing.T) {
219+
t.Parallel()
213220
tests := []struct {
214221
name string
215222
input string
@@ -220,8 +227,10 @@ func TestStackPrintForTest(t *testing.T) {
220227
{"short", input, outputForTestLvl2, 2},
221228
//{"real test trace", inputFromTest, outputFromTest, 4},
222229
}
223-
for _, tt := range tests {
230+
for _, ttv := range tests {
231+
tt := ttv
224232
t.Run(tt.name, func(t *testing.T) {
233+
t.Parallel()
225234
r := strings.NewReader(tt.input)
226235
w := new(bytes.Buffer)
227236
printStackForTest(r, w, tt.lvl)

internal/handler/handler_test.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
)
1313

1414
func TestProcess(t *testing.T) {
15+
t.Parallel()
1516
type args struct {
1617
handler.Info
1718
}
@@ -113,8 +114,10 @@ func TestProcess(t *testing.T) {
113114
errStr: "error",
114115
}},
115116
}
116-
for _, tt := range tests {
117+
for _, ttv := range tests {
118+
tt := ttv
117119
t.Run(tt.name, func(t *testing.T) {
120+
t.Parallel()
118121
if handler.WorkToDo(tt.args.Any, tt.args.Err) {
119122
handler.Process(&tt.args.Info)
120123

@@ -142,6 +145,7 @@ func Handle() {
142145
}
143146

144147
func TestPreProcess_debug(t *testing.T) {
148+
t.Parallel()
145149
// in real case PreProcess is called from Handle function. So, we make our
146150
// own Handle here. Now our test function name will be the Handle caller
147151
// and that's what error stack tracing is all about
@@ -159,6 +163,7 @@ func TestPreProcess_debug(t *testing.T) {
159163
}
160164

161165
func TestPreProcess(t *testing.T) {
166+
t.Parallel()
162167
type args struct {
163168
handler.Info
164169
a []any
@@ -225,8 +230,10 @@ func TestPreProcess(t *testing.T) {
225230
errStr: "",
226231
}},
227232
}
228-
for _, tt := range tests {
233+
for _, ttv := range tests {
234+
tt := ttv
229235
t.Run(tt.name, func(t *testing.T) {
236+
t.Parallel()
230237
if handler.WorkToDo(tt.args.Any, tt.args.Err) &&
231238
len(tt.args.a) > 0 {
232239

internal/str/str_test.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,12 @@ func TestDecamel(t *testing.T) {
4646
{"unnatural method and anonym", args{"(**DIDAgent)...AssertWallet...Func1"}, "didagent assert wallet: func1"},
4747
{"from spf13 cobra", args{"bot.glob..func5"}, "bot: glob: func5"},
4848
}
49-
for _, tt := range tests {
50-
s := tt.args.s
51-
want := tt.want
49+
for _, ttv := range tests {
50+
tt := ttv
5251
t.Run(tt.name, func(t *testing.T) {
5352
t.Parallel()
54-
got := str.Decamel(s)
55-
test.RequireEqual(t, got, want)
53+
got := str.Decamel(tt.args.s)
54+
test.RequireEqual(t, got, tt.want)
5655
})
5756
}
5857
}

try/out_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ func ExampleResult1_Logf() {
9090
}
9191

9292
func TestResult2_Logf(t *testing.T) {
93+
t.Parallel()
9394
// Set log tracing to stdout that we can see it in Example output. In
9495
// normal cases that would be a Logging stream or stderr.
9596
err2.SetLogTracer(os.Stdout)
@@ -110,6 +111,7 @@ func TestResult2_Logf(t *testing.T) {
110111
}
111112

112113
func TestResult_Handle(t *testing.T) {
114+
t.Parallel()
113115
// try out f() |err| handle to show how to stop propagate error
114116
callFn := func(mode int) (err error) {
115117
defer err2.Handle(&err)

0 commit comments

Comments
 (0)