Skip to content

Add support for platform specific communication channels #2497

Open
@natebosch

Description

@natebosch

Some test platforms want to expose new runtime capabilities that coordinate between the code under test and the test platform. We currently implement a similar capability baked in to the test runner instead of individual platforms - spawnHybridCode and spawnHybridUri.

case 'spawn-hybrid-uri':
// When we kill the isolate that the test lives in, that will close
// this virtual channel and cause the spawned isolate to close as
// well.
spawnHybridUri(msg['url'] as String, msg['message'], suite).pipe(
testChannel.virtualChannel((msg['channel'] as num).toInt()));
break;

We can likely use the existing multichannel mechanism to create additional communication channels.

var channel = Zone.current[#test.runner.test_channel] as MultiChannel?;
if (channel == null) {
throw UnsupportedError("Can't connect to the test runner.\n"
'spawnHybridUri() is currently only supported within "dart test".');
}
ensureJsonEncodable(message);
var virtualChannel = channel.virtualChannel();
StreamChannel isolateChannel = virtualChannel;
channel.sink.add({
'type': 'spawn-hybrid-uri',
'url': uri,
'message': message,
'channel': virtualChannel.id
});

We will need to solve the API on the platform definition side as well.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions