简体   繁体   English

Dart事件队列:如何调试事件队列?

[英]Dart Event Queue: How to debug event queue?

I'm writing some integration tests which utilize an HttpServer , a bunch of Directory().watch() 'ers and possibly some other future/stream listening code. 我正在编写一些集成测试,它们使用HttpServer ,一堆Directory().watch() ',以及可能的其他未来/流监听代码。

I'm using the following test configuration: 我正在使用以下测试配置:

class LaserServerTestConfiguration extends SimpleConfiguration {
  LaserServer _server;
  LaserServerTestConfiguration(this._server);
  void onDone(bool success) {
    super.onDone(success);
    _server.stop();
  }
}

And my tests look like this: 我的测试看起来像这样:

main() {
  var conf = new LaserConfiguration.fromPath('test/test_config.yaml');
  var server = new LaserServer(conf);
  unittestConfiguration = new LaserServerTestConfiguration(server);

  server.start().then((_) {

    test('test file changed event', () {
      var response = new Completer<Map>();
      response.future.then(expectAsync((e) =>
        expect(e, containsValue('test/sample/sample_test.html'))
      ));
      WebSocket.connect("ws://localhost:2014").then((ws) {
        ws.listen((msg) {
          response.complete(JSON.decode(msg));
          ws.close();
        });
        new File('test/sample/sample.dart').writeAsString("");
      });
    });

  });
}

The problem I have is that after the tests run (and pass) the Dart VM does not exit. 我遇到的问题是,在测试运行(并通过)后,Dart VM不会退出。 Presumably because I still have something pending in the event queue. 大概是因为我在事件队列中仍有待处理的事情。

How do I debug the event queue? 如何调试事件队列? I would like to see what is preventing the Dart VM from exiting at the end of the test run. 我想看看是什么阻止了Dart VM在测试运行结束时退出。

You can see in the custom TestConfiguration that I overload onDone(), this gets called and I stop() my server ( .close(force: true) on HttpServer and loop all of my Directory().watch() 'ers and cancel the subscriptions). 您可以在自定义TestConfiguration中看到我重载onDone(),这被调用,我在HttpServer上停止()我的服务器( .close(force: true)并循环我的所有Directory().watch() 'ers并取消订阅)。 But something is still hanging around... 但仍有一些问题仍然存在......

现在的天文台(Dart VM版本:1.11.0-edge.131775)允许在调试器视图中调查消息队列。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM