Skip to content

Commit 2fedd5e

Browse files
committed
Run tests in parallel
Issue: #36
1 parent b6f167d commit 2fedd5e

13 files changed

+72
-0
lines changed

.golangci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ linters:
2020
- misspell
2121
- nilnesserr
2222
- nolintlint
23+
- paralleltest
2324
- predeclared
2425
- recvcheck
2526
- revive

graph/endpoint_pair_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,17 @@ import (
77
)
88

99
func TestEndpointPair(t *testing.T) {
10+
t.Parallel()
11+
1012
t.Run("EndpointPair.Source() returns the first node", func(t *testing.T) {
13+
t.Parallel()
1114
if got, want := endpointPair().Source(), "link"; got != want {
1215
t.Errorf("EndpointPair.Source: got %q, want %q", got, want)
1316
}
1417
})
1518

1619
t.Run("EndpointPair.Target() returns the second node", func(t *testing.T) {
20+
t.Parallel()
1721
if got, want := endpointPair().Target(), "zelda"; got != want {
1822
t.Errorf("EndpointPair.Source: got %q, want %q", got, want)
1923
}
@@ -22,6 +26,7 @@ func TestEndpointPair(t *testing.T) {
2226
t.Run(
2327
"EndpointPair.AdjacentNode(EndpointPair.Source()) returns the target",
2428
func(t *testing.T) {
29+
t.Parallel()
2530
got := endpointPair().AdjacentNode(endpointPair().Source())
2631
want := endpointPair().Target()
2732
if got != want {
@@ -38,6 +43,7 @@ func TestEndpointPair(t *testing.T) {
3843
t.Run(
3944
"EndpointPair.AdjacentNode(EndpointPair.Target()) returns the source",
4045
func(t *testing.T) {
46+
t.Parallel()
4147
got := endpointPair().AdjacentNode(endpointPair().Target())
4248
want := endpointPair().Source()
4349
if got != want {
@@ -54,6 +60,7 @@ func TestEndpointPair(t *testing.T) {
5460
t.Run(
5561
"EndpointPair.AdjacentNode(nonAdjacentNode) panics",
5662
func(t *testing.T) {
63+
t.Parallel()
5764
defer func() { _ = recover() }()
5865
endpointPair().AdjacentNode("ganondorf")
5966
t.Errorf(`EndpointPair.AdjacentNode("ganondorf"): should have panicked`)
@@ -63,6 +70,7 @@ func TestEndpointPair(t *testing.T) {
6370
t.Run(
6471
"EndpointPair.String() returns a string representation",
6572
func(t *testing.T) {
73+
t.Parallel()
6674
if got, want := endpointPair().String(), "<link -> zelda>"; got != want {
6775
t.Errorf("EndpointPair.String: got %s, want %s", got, want)
6876
}

graph/equal_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ import (
88
)
99

1010
func TestEqual(t *testing.T) {
11+
t.Parallel()
12+
1113
t.Run("graph a: [link]; graph b: [link]; equal", func(t *testing.T) {
14+
t.Parallel()
1215
a := undirectedGraphOf("link")
1316

1417
if got := graph.Equal(a, a); !got {
@@ -17,12 +20,14 @@ func TestEqual(t *testing.T) {
1720
})
1821

1922
t.Run("graph a: nil; graph b: nil; equal", func(t *testing.T) {
23+
t.Parallel()
2024
if got := graph.Equal[string](nil, nil); !got {
2125
t.Errorf("graph.Equal: got false, want true")
2226
}
2327
})
2428

2529
t.Run("graph a: [link]; graph b: nil; not equal", func(t *testing.T) {
30+
t.Parallel()
2631
a := undirectedGraphOf("link")
2732
if got := graph.Equal(a, nil); got {
2833
t.Errorf("graph.Equal: got true, want false")
@@ -32,6 +37,7 @@ func TestEqual(t *testing.T) {
3237
t.Run(
3338
"graph a: undirected; graph b: directed; not equal",
3439
func(t *testing.T) {
40+
t.Parallel()
3541
a := undirectedGraphOf("link")
3642
b := directedGraphOf("link")
3743

@@ -44,6 +50,7 @@ func TestEqual(t *testing.T) {
4450
t.Run(
4551
"graph a: allows self-loops; graph b: disallows self-loops; not equal",
4652
func(t *testing.T) {
53+
t.Parallel()
4754
a := graph.Undirected[string]().AllowsSelfLoops(true).Build()
4855
b := graph.Undirected[string]().Build()
4956

@@ -54,6 +61,7 @@ func TestEqual(t *testing.T) {
5461
)
5562

5663
t.Run("graph a: [link]; graph b: [zelda]; not equal", func(t *testing.T) {
64+
t.Parallel()
5765
a := undirectedGraphOf("link")
5866
b := undirectedGraphOf("zelda")
5967

@@ -65,6 +73,7 @@ func TestEqual(t *testing.T) {
6573
t.Run(
6674
"graph a: [<link -> zelda>]; graph b: [link, zelda]; not equal",
6775
func(t *testing.T) {
76+
t.Parallel()
6877
a := undirectedGraphOf(edge("link", "zelda"))
6978
b := undirectedGraphOf("link", "zelda")
7079

graph/graph_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ func putEdgeOnMutableGraph(
2222
}
2323

2424
func TestUndirectedGraph(t *testing.T) {
25+
t.Parallel()
26+
2527
graphtest.Graph(
2628
t,
2729
func() graph.Graph[int] {
@@ -36,6 +38,8 @@ func TestUndirectedGraph(t *testing.T) {
3638
}
3739

3840
func TestUndirectedAllowsSelfLoopsGraph(t *testing.T) {
41+
t.Parallel()
42+
3943
graphtest.Graph(
4044
t,
4145
func() graph.Graph[int] {
@@ -50,6 +54,8 @@ func TestUndirectedAllowsSelfLoopsGraph(t *testing.T) {
5054
}
5155

5256
func TestDirectedGraph(t *testing.T) {
57+
t.Parallel()
58+
5359
graphtest.Graph(
5460
t,
5561
func() graph.Graph[int] {
@@ -64,6 +70,8 @@ func TestDirectedGraph(t *testing.T) {
6470
}
6571

6672
func TestDirectedAllowsSelfLoopsGraph(t *testing.T) {
73+
t.Parallel()
74+
6775
graphtest.Graph(
6876
t,
6977
func() graph.Graph[int] {

internal/orderagnostic/diff_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import (
77
)
88

99
func TestDiff(t *testing.T) {
10+
t.Parallel()
11+
1012
type args struct {
1113
got []int
1214
want []int
@@ -57,6 +59,8 @@ func TestDiff(t *testing.T) {
5759
}
5860
for _, tt := range tests {
5961
t.Run(tt.name, func(t *testing.T) {
62+
t.Parallel()
63+
6064
if got := orderagnostic.Diff(
6165
tt.args.got,
6266
tt.args.want,

internal/orderagnostic/equal_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import (
77
)
88

99
func TestSlicesEqual(t *testing.T) {
10+
t.Parallel()
11+
1012
type args struct {
1113
a []int
1214
b []int
@@ -57,6 +59,8 @@ func TestSlicesEqual(t *testing.T) {
5759
}
5860
for _, tt := range tests {
5961
t.Run(tt.name, func(t *testing.T) {
62+
t.Parallel()
63+
6064
if got := orderagnostic.SlicesEqual(
6165
tt.args.a,
6266
tt.args.b,

internal/slicesx/allof_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import (
88
)
99

1010
func TestAllOf(t *testing.T) {
11+
t.Parallel()
12+
1113
type args struct {
1214
first int
1315
rest []int
@@ -44,6 +46,8 @@ func TestAllOf(t *testing.T) {
4446
}
4547
for _, tt := range tests {
4648
t.Run(tt.name, func(t *testing.T) {
49+
t.Parallel()
50+
4751
if got := slicesx.AllOf(tt.args.first, tt.args.rest); !slices.Equal(got, tt.want) {
4852
t.Errorf("AllOf() = %v, want %v", got, tt.want)
4953
}

internal/stringsx/split_by_comma_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import (
88
)
99

1010
func TestSplitByComma(t *testing.T) {
11+
t.Parallel()
12+
1113
type args struct {
1214
s string
1315
}
@@ -40,6 +42,8 @@ func TestSplitByComma(t *testing.T) {
4042
}
4143
for _, tt := range tests {
4244
t.Run(tt.name, func(t *testing.T) {
45+
t.Parallel()
46+
4347
if got := stringsx.SplitByComma(tt.args.s); !reflect.DeepEqual(got, tt.want) {
4448
t.Errorf("SplitByComma(): got %v, want %v", got, tt.want)
4549
}

set/equal_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,27 @@ import (
77
)
88

99
func TestEqual(t *testing.T) {
10+
t.Parallel()
11+
1012
t.Run("set a: nil; set b: nil; equal", func(t *testing.T) {
13+
t.Parallel()
14+
1115
if got := set.Equal[string](nil, nil); !got {
1216
t.Errorf("set.Equal: got false, want true")
1317
}
1418
})
1519

1620
t.Run("set a: [link]; set b: nil; not equal", func(t *testing.T) {
21+
t.Parallel()
22+
1723
if got := set.Equal[string](set.Of("link"), nil); got {
1824
t.Errorf("set.Equal: got true, want false")
1925
}
2026
})
2127

2228
t.Run("set a: [link]; set b: [zelda]; not equal", func(t *testing.T) {
29+
t.Parallel()
30+
2331
if got := set.Equal[string](set.Of("link"), set.Of("zelda")); got {
2432
t.Errorf("set.Equal: got true, want false")
2533
}
@@ -28,6 +36,8 @@ func TestEqual(t *testing.T) {
2836
t.Run(
2937
"set a: [link]; set b: [link, zelda]; not equal",
3038
func(t *testing.T) {
39+
t.Parallel()
40+
3141
got := set.Equal[string](set.Of("link"), set.Of("link", "zelda"))
3242
if got {
3343
t.Errorf("set.Equal: got true, want false")

set/set_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,16 @@ import (
88
)
99

1010
func TestSetOf(t *testing.T) {
11+
t.Parallel()
12+
1113
settest.Set(t, func(elems []string) set.Set[string] {
1214
return set.Of(elems...)
1315
})
1416
}
1517

1618
func TestSetInitializedWithAdd(t *testing.T) {
19+
t.Parallel()
20+
1721
settest.Set(t, func(elems []string) set.Set[string] {
1822
s := set.Of[string]()
1923
for _, elem := range elems {

set/string_impl_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import (
1010
)
1111

1212
func TestStringImpl(t *testing.T) {
13+
t.Parallel()
14+
1315
type testCase struct {
1416
name string
1517
arg set.Set[string]
@@ -34,6 +36,8 @@ func TestStringImpl(t *testing.T) {
3436
}
3537
for _, tt := range tests {
3638
t.Run(tt.name, func(t *testing.T) {
39+
t.Parallel()
40+
3741
if got := set.StringImpl(tt.arg); !slices.Contains(tt.wantAny, got) {
3842
t.Errorf("StringImpl() = %v, want any of %v", got, tt.wantAny)
3943
}

set/union_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import (
99
)
1010

1111
func TestUnion(t *testing.T) {
12+
t.Parallel()
13+
1214
settest.Set(t, func(elems []string) set.Set[string] {
1315
a := set.Of[string]()
1416
b := set.Of[string]()
@@ -25,12 +27,16 @@ func TestUnion(t *testing.T) {
2527
})
2628

2729
t.Run("union is unmodifiable", func(t *testing.T) {
30+
t.Parallel()
31+
2832
union := set.Union[int](set.Of[int](), set.Of[int]())
2933

3034
internalsettest.IsMutable(t, "set.Union", union)
3135
})
3236

3337
t.Run("union is view", func(t *testing.T) {
38+
t.Parallel()
39+
3440
a := set.Of[int]()
3541
b := set.Of[int]()
3642
union := set.Union[int](a, b)

set/unmodifiable_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import (
99
)
1010

1111
func TestSetUnmodifiable(t *testing.T) {
12+
t.Parallel()
13+
1214
settest.Set(t, func(elements []string) set.Set[string] {
1315
s := set.Of[string]()
1416
for _, element := range elements {
@@ -20,6 +22,8 @@ func TestSetUnmodifiable(t *testing.T) {
2022
t.Run(
2123
"empty unmodifiable set: add to underlying set",
2224
func(t *testing.T) {
25+
t.Parallel()
26+
2327
s := set.Of[string]()
2428
unmodSet := set.Unmodifiable[string](s)
2529

@@ -51,6 +55,8 @@ func TestSetUnmodifiable(t *testing.T) {
5155
"add x2 to underlying set: "+
5256
"has two-element string representation",
5357
func(t *testing.T) {
58+
t.Parallel()
59+
5460
s := set.Of[string]()
5561
unmodSet := set.Unmodifiable[string](s)
5662

0 commit comments

Comments
 (0)