-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Closed
Labels
Milestone
Description
I spent some time on GopherCon trying to figure how to make the qml package work
smoothly on Mac OS. Apparently it was working fine out of luck, because the OS requires
some calls to be made from the initial thread. Now something unrelated was touched, and
the graphic goroutine is landing on a different thread and generating errors.
The solution is simple: an init function that locks the main thread, and a qml.Run
function that runs the main loop. Problem solved.
Except, that doesn't work with the testing package anymore, because the test logic
itself is run at the end of main, and tests are moved on their own goroutine.
This problem might be easily solved by changing the test template from:
testing.Main(matchString, tests, benchmarks, examples)
to something like:
go func() {
testing.Main(matchString, tests, benchmarks, examples)
close(done)
}()
if testing.RunFromMain != nil {
testing.RunFromMain(done)
}
<-done
Then, for the qml package, I'd implement RunFromMain along the lines of:
testing.RunFromMain = func(done chan struct{}) {
stopWhenClosed(done)
qml.Run(nil)
}
Can we add such a testing.RunFromMain hook?
Another alternative, suggested by Dmitry Vyukov, is to run tests on the initial thread
instead of spawning them in goroutines. That would solve the problem too.Reactions are currently unavailable