diff --git a/tests/isolate/spawn_uri_missing_from_isolate_test.dart b/tests/isolate/spawn_uri_missing_from_isolate_test.dart index daefc46e381..c7551d2b08f 100644 --- a/tests/isolate/spawn_uri_missing_from_isolate_test.dart +++ b/tests/isolate/spawn_uri_missing_from_isolate_test.dart @@ -30,13 +30,12 @@ main() { ReceivePort port = new ReceivePort(); Isolate.spawn(isolate, port.sendPort); Completer completer = new Completer(); - port.listen((message) { + port.first.then((message) { if (message == SUCCESS) { completer.complete(null); } else { completer.completeError(message); } - port.close(); }); asyncTest(() => completer.future); diff --git a/tests/isolate/spawn_uri_missing_test.dart b/tests/isolate/spawn_uri_missing_test.dart index c3dd4d32f4a..f342fe216bd 100644 --- a/tests/isolate/spawn_uri_missing_test.dart +++ b/tests/isolate/spawn_uri_missing_test.dart @@ -12,11 +12,14 @@ import 'dart:async'; import 'package:async_helper/async_helper.dart'; +const UNEXPECTED_MESSAGE = 'Created isolate from missing file.'; + Future doTest() { return Isolate.spawnUri(Uri.base.resolve('no_such_file'), [], null) .then((Isolate isolate) { - throw 'Created isolate from missing file'; + throw UNEXPECTED_MESSAGE; }).catchError((error) { + if (error == UNEXPECTED_MESSAGE) throw error; print('An error was thrown as expected'); return null; });