diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2cd4ad32b..a69562ed3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -33,6 +33,7 @@ jobs: - "1.21" - "1.22" - "1.23" + - "1.25" steps: - uses: actions/checkout@v5 - name: Setup Go diff --git a/suite/synctest.go b/suite/synctest.go new file mode 100644 index 000000000..24c8f9082 --- /dev/null +++ b/suite/synctest.go @@ -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() + }) +} diff --git a/suite/synctest_test.go b/suite/synctest_test.go new file mode 100644 index 000000000..e8c98ddbc --- /dev/null +++ b/suite/synctest_test.go @@ -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` + Run(t, new(SyncTestSuite)) +} + +func (s *SyncTestSuite) TestSyncTest() { + s.SyncTest(func() { + synctest.Wait() + }) + s.Run("subtest", func() { + s.SyncTest(func() { + synctest.Wait() + }) + }) +}