From b74779ddd5c66419afd0b4a00108d30c7573390e Mon Sep 17 00:00:00 2001 From: GrĂ©goire DuchĂȘne Date: Sun, 26 Feb 2023 12:56:14 +0000 Subject: Clone testing options before calling subtest --- testing.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'testing.go') diff --git a/testing.go b/testing.go index 2b91a72..4dba90c 100644 --- a/testing.go +++ b/testing.go @@ -15,7 +15,7 @@ import ( // functions, but behaves otherwise like testing.T. type T struct { *testing.T - Options []cmp.Option + Options cmp.Options wg sync.WaitGroup } @@ -135,9 +135,10 @@ func (t *T) Must(b bool) { func (t *T) Run(name string, f func(t *T)) { t.T.Run(name, func(s *testing.T) { - t := &T{T: s, Options: t.Options} - f(t) - t.wg.Wait() + o := &T{T: s, Options: make(cmp.Options, len(t.Options))} + copy(o.Options, t.Options) + f(o) + o.wg.Wait() }) } -- cgit v1.2.3-70-g09d2