Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ jobs:
- "1.21"
- "1.22"
- "1.23"
- "1.25"
steps:
- uses: actions/checkout@v5
- name: Setup Go
Expand Down
18 changes: 18 additions & 0 deletions suite/synctest.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//go:build go1.25

package suite

import (
"testing"
"testing/synctest"
)

// SyncTest executes f in a new [synctest] bubble.
func (suite *Suite) SyncTest(f func()) {
oldT := suite.T()
synctest.Test(oldT, func(t *testing.T) {
suite.SetT(t)
defer suite.SetT(oldT)
f()
})
}
28 changes: 28 additions & 0 deletions suite/synctest_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//go:build go1.25

package suite

import (
"testing"
"testing/synctest"
)

type SyncTestSuite struct {
Suite
}

func TestSyncTest(t *testing.T) {
t.Setenv("GODEBUG", "asynctimerchan=0") // since our go.mod says `go 1.17`

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, Not sure if it's worth referencing the specific release notes https://go.dev/doc/go1.23#timer-changes

Run(t, new(SyncTestSuite))
}

func (s *SyncTestSuite) TestSyncTest() {
s.SyncTest(func() {
synctest.Wait()
})
s.Run("subtest", func() {
s.SyncTest(func() {
synctest.Wait()
})
})
}