Dart Event Queue: how to debug an event queue?

I am writing some integration tests that use HttpServer

heap Directory().watch()

'and possibly some other future / thread listening code.

I am 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 is that after running (and passing) the tests, the Dart VM fails. Presumably because I still have something pending in the event queue.

How do I debug an event queue? I would like to see what is stopping the Dart VM from exiting the test at the end of the test run.

In the custom TestConfiguration you can see that I am overloading onDone (), this triggers a call and I stop () my server ( .close(force: true)

on HttpServer and digitize all mine Directory().watch()

and change subscriptions). But something is still hanging around ...

+3


source to share


1 answer


The observatory now (Dart VM version: 1.11.0-edge.131775) allows you to examine the message queue in the debugger view.



+1


source







All Articles