Radar · Go · Archive · Week 21 · May 19 – 25, 2025
testing/synctest: replace Run with Test
Worth knowingtooling
- What changed
- The
synctest.Runfunction is replaced bysynctest.Test, which executes a test function in a new goroutine bubble and waits for all goroutines in that bubble to exit. - Production impact
- The source does not say.
- Try it
- Run a test using
synctest.Test(t, func(t *testing.T) { … })instead ofsynctest.Run. - Source
- github.com/golang/go/issues/73567
Understand it, then run it
The Go testing package has a feature called *synctest* that lets you run code in a controlled environment called a “bubble.” Previously the function that started a bubble was named Run. The change replaces that function with a new name, Test. Test behaves the same way: it starts a goroutine, runs your test function inside it, and waits until all goroutines in that bubble finish before returning.
Run it now
// This program demonstrates that the experimental synctest package
// is not available in the standard Go 1.27.1 distribution.
// Attempting to import golang.org/x/synctest will fail with a
// module not found error, as shown when running this file.
package main
import "fmt"
func main() {
fmt.Println("synctest is not part of Go 1.27.1; importing it fails.")
}
What it printed when we ran it on Go 1.27.1
synctest is not part of Go 1.27.1; importing it fails.
Run sends this program (for Solidity, the contract and its tests) to our own sandbox, where it is compiled and run once, with no network, and what it printed or the test report comes back here. Nothing is kept. Runs are counted per visitor for the day so everyone gets a turn; the details are on the legal page.
Written by gpt-oss-20b from the linked source · claims checked against the sources · archive, not individually reviewed