Chromium Code Reviews| Index: runtime/vm/isolate_test.cc |
| diff --git a/runtime/vm/isolate_test.cc b/runtime/vm/isolate_test.cc |
| index 2af007ea2285a4036d98158a5e9a793b6e970199..b600c33c16d4ec42485fcf2b7aa21ecf9b418caa 100644 |
| --- a/runtime/vm/isolate_test.cc |
| +++ b/runtime/vm/isolate_test.cc |
| @@ -25,15 +25,48 @@ TEST_CASE(IsolateSpawn) { |
| "import 'dart:isolate';\n" |
| "void entry(message) {}\n" |
| "int testMain() {\n" |
| - " try {\n" |
| - " Isolate.spawn(entry, null);\n" |
| - " } catch (e) {\n" |
| - " rethrow;\n" |
| - " }\n" |
| - " return 0;\n" |
| + " Isolate.spawn(entry, null);\n" |
| + // TODO(floitsch): the following code is only to bump the event loop |
| + // so it executes asynchronous microtasks. |
| + " var rp = new RawReceivePort();\n" |
| + " rp.sendPort.send(null);\n" |
| + " rp.handler = (_) { rp.close(); };\n" |
| "}\n"; |
| + |
| + // Setup the internal library's 'internalPrint' function. |
| + // Necessary because asynchronous errors use "print" to print their |
| + // stack trace. |
| + Dart_Handle url = NewString("dart:_collection-dev"); |
| + DART_CHECK_VALID(url); |
| + Dart_Handle internal_lib = Dart_LookupLibrary(url); |
| + DART_CHECK_VALID(internal_lib); |
| + Dart_Handle print = Dart_GetField(internal_lib, |
| + NewString("_nullPrintClosure")); |
|
Ivan Posva
2013/12/12 12:11:49
I think it would be better to not pollute the inte
floitsch
2013/12/12 21:08:37
Done.
|
| + Dart_Handle result = Dart_SetField(internal_lib, |
| + NewString("_printClosure"), |
| + print); |
| + |
| + DART_CHECK_VALID(result); |
| + |
| + // Setup the 'scheduleImmediate' closure. |
| + url = NewString("dart:isolate"); |
| + DART_CHECK_VALID(url); |
| + Dart_Handle isolate_lib = Dart_LookupLibrary(url); |
| + DART_CHECK_VALID(isolate_lib); |
| + Dart_Handle schedule_immediate_closure = |
| + Dart_Invoke(isolate_lib, NewString("_getIsolateScheduleImmediateClosure"), |
| + 0, NULL); |
| + Dart_Handle args[1]; |
| + args[0] = schedule_immediate_closure; |
| + DART_CHECK_VALID(Dart_Invoke( |
| + internal_lib, NewString("setScheduleImmediateClosure"), 1, args)); |
| + |
| + |
| Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); |
| - Dart_Handle result = Dart_Invoke(lib, NewString("testMain"), 0, NULL); |
| + result = Dart_Invoke(lib, NewString("testMain"), 0, NULL); |
| + EXPECT(!Dart_IsError(result)); |
| + // Run until all ports to isolate are closed. |
| + result = Dart_RunLoop(); |
| EXPECT_ERROR(result, "Null callback specified for isolate creation"); |
| EXPECT(Dart_ErrorHasException(result)); |
| Dart_Handle exception_result = Dart_ErrorGetException(result); |