74
//
75
//nolint:revive // ctx is last so callers can pass nil to mean "no override"; SA1012 forbids passing nil as the first ctx arg.
76
>
func (s *Suite[T]) copySuite(t *testing.T, parallel bool, assertT require.TestingT, ctx context.Context) testingSuite {
suite.go
77
>
cp := reflect.New(reflect.TypeFor[T]().Elem()).Interface().(T)
78
>
cp.initSuite(t, parallel, assertT, ctx)
79
>
return cp
80
>
}
81
82
//nolint:revive // see copySuite above.
83
>
func (s *Suite[T]) initSuite(t *testing.T, parallel bool, assertT require.TestingT, ctx context.Context) {
suite.go
84
>
g := &s.guardT
85
>
g.name = t.Name()
86
>
g.T = t
87
>
g.hasSubtests.Store(false)
88
>
s.runParallel = parallel
89
>
s.ctx = ctx
90
>
s.ctxOnce = sync.Once{}
91
>
if s.runParallel {
92
>
t.Parallel() //nolint:testifylint // parallelsuite intentionally supports parallel tests
93
>
}
94
>
if assertT == nil {
95
>
assertT = g
96
>
}
97
>
s.assertT = assertT
98
>
s.Assertions = require.New(assertT)
99
>
s.ProtoAssertions = protorequire.New(assertT)
100
>
s.HistoryRequire = historyrequire.New(assertT)
101
}
102
103
// T returns the *testing.T, panicking if the guard has been sealed.
105
>
if s.guardT.hasSubtests.Load() {
106
panic("parallelsuite: do not call T() after Run(); use the subtest callback's parameter instead")
107
}
109
}
110