-
Notifications
You must be signed in to change notification settings - Fork 17.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
testing: provide access to initial thread from tests #7905
Labels
Milestone
Comments
I also realized that just having tests in main would be sub-optimal for the problem at hand either way. Ideally the event loop can run for the duration of multiple tests, rather than starting and stopping it on every single test. The original solution suggested, with a RunFromMain hook on testing, still sounds like the best approach for the problem, and it's also very simple. |
>Ideally the event loop can run for the duration of multiple tests How critical is it? testing.RunFromMain interface looks quite involved to me. More in the spirit of Go's approach would be: func TestFoo(t *testing.T) { t.OnMainThread() ... } But this will involve subprocesses, and each test do own setup/teardown. |
On a similar note, recently somebody was asking the following feature: func TestDie(t *testing.T) { output, err := t.DeathTest(func() { log.Fatal("Die") } ) if err != nil || !regexp.Match("Die", output) { t.Fatal(...) } } Such "death tests" also must run in a subprocess. So probably we can figure out a single testing package extension that covers both cases. |
Although I did manage to make the main event loop stop in the qml package, the main event loop of many GUI toolkits are designed to run once and for the duration of the application. I'd prefer to not fix the go test problem in a way that makes doing that impossible, as it may uncover bugs that few people care about now or in the future. The RunFromMain interface is both simple to implement, and simple to use. With it, I will offer a function that may be called as: func init() { qml.SetupTesting() } and then tests can just use the qml package as usual, for example. |
I've been holding back the fix for qml a bit too long, so I'm releasing v1 of the API with an in-memory code patching hack for the time being. It's exclusive to testing and fairly isolated, so not too bad: http://blog.labix.org/2014/08/13/announcing-qml-v1-for-go Is there anything I can do to help refining the actual solution? |
Status changed to Duplicate. Merged into issue #8202. |
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The text was updated successfully, but these errors were encountered: