-
Notifications
You must be signed in to change notification settings - Fork 220
Open
Labels
Description
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
.
test/pkgs/test_core/lib/src/runner/runner_test.dart
Lines 73 to 79 in b9c59ea
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.
test/pkgs/test_api/lib/src/scaffolding/spawn_hybrid.dart
Lines 155 to 170 in b9c59ea
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.