Пример #1
0
func (s *S) TearDownTest(c *C) {
	s.engine.Destroy()

	retries := 30 // Three seconds top.
	for {
		// Do not call qml.Flush here. It creates a nested event loop
		// that attempts to process the deferred object deletes and cannot,
		// because deferred deletes are only processed at the same loop level.
		// So it *reposts* the deferred deletion event, in practice *preventing*
		// these objects from being deleted.
		runtime.GC()
		stats := qml.Stats()
		if stats.EnginesAlive == 0 && stats.ValuesAlive == 0 && stats.ConnectionsAlive == 0 {
			break
		}
		if retries == 0 {
			panic(fmt.Sprintf("there are values alive:\n%#v\n", stats))
		}
		retries--
		time.Sleep(100 * time.Millisecond)
		if retries%10 == 0 {
			c.Logf("There are still objects alive; waiting for them to die: %#v\n", stats)
		}
	}

	qml.SetLogger(nil)
}
Пример #2
0
func (s *S) SetUpTest(c *C) {
	qml.SetLogger(c)
	qml.CollectStats(true)
	qml.ResetStats()

	stats := qml.Stats()
	if stats.EnginesAlive > 0 || stats.ValuesAlive > 0 || stats.ConnectionsAlive > 0 {
		panic(fmt.Sprintf("Test started with values alive: %#v\n", stats))
	}

	s.engine = qml.NewEngine()
	s.context = s.engine.Context()
}