internalBootstrapNativeTest function

void internalBootstrapNativeTest(
  1. Function getMain(),
  2. List<String> args
)

Bootstraps a native executable test to communicate with the test runner over a socket.

Implementation

void internalBootstrapNativeTest(
    Function Function() getMain, List<String> args) async {
  if (args.length != 2) {
    throw StateError(
        'Expected exactly two args, a host and a port, but got $args');
  }
  var socket = await Socket.connect(args[0], int.parse(args[1]));
  var platformChannel = MultiChannel<Object?>(jsonSocketStreamChannel(socket));
  var testControlChannel = platformChannel.virtualChannel()
    ..pipe(serializeSuite(getMain));
  platformChannel.sink.add(testControlChannel.id);

  unawaited(platformChannel.stream.forEach((message) {
    assert(message == 'debug');
    debugger(message: 'Paused by test runner');
    platformChannel.sink.add('done');
  }));
}