| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 // VMOptions=--error_on_bad_type --error_on_bad_override | 4 // VMOptions=--error_on_bad_type --error_on_bad_override |
| 5 | 5 |
| 6 import 'test_helper.dart'; | 6 import 'test_helper.dart'; |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:developer'; | 8 import 'dart:developer'; |
| 9 import 'dart:isolate' as I; | 9 import 'dart:isolate' as I; |
| 10 import 'dart:io'; | 10 import 'dart:io'; |
| 11 import 'service_test_common.dart'; | 11 import 'service_test_common.dart'; |
| 12 import 'package:observatory/service.dart'; | 12 import 'package:observatory/service.dart'; |
| 13 import 'package:path/path.dart' as path; | 13 import 'package:path/path.dart' as path; |
| 14 import 'package:unittest/unittest.dart'; | 14 import 'package:unittest/unittest.dart'; |
| 15 | 15 |
| 16 // Chop off the file name. | 16 // Chop off the file name. |
| 17 String baseDirectory = path.dirname(Platform.script.path) + '/'; | 17 String baseDirectory = path.dirname(Platform.script.path) + '/'; |
| 18 | 18 |
| 19 Uri baseUri = Platform.script.replace(path: baseDirectory); | 19 Uri baseUri = Platform.script.replace(path: baseDirectory); |
| 20 Uri spawnUri = baseUri.resolveUri(Uri.parse('complex_reload/v1/main.dart')); | 20 Uri spawnUri = baseUri.resolveUri(Uri.parse('complex_reload/v1/main.dart')); |
| 21 Uri v2Uri = baseUri.resolveUri(Uri.parse('complex_reload/v2/main.dart')); | 21 Uri v2Uri = baseUri.resolveUri(Uri.parse('complex_reload/v2/main.dart')); |
| 22 Uri v3Uri = baseUri.resolveUri(Uri.parse('complex_reload/v3/main.dart')); | 22 Uri v3Uri = baseUri.resolveUri(Uri.parse('complex_reload/v3/main.dart')); |
| 23 Uri v2PackagesUri = baseUri.resolveUri(Uri.parse('complex_reload/v2/packages')); | |
| 24 | 23 |
| 25 testMain() async { | 24 testMain() async { |
| 26 print(baseUri); | 25 print(baseUri); |
| 27 debugger(); // Stop here. | 26 debugger(); // Stop here. |
| 28 // Spawn the child isolate. | 27 // Spawn the child isolate. |
| 29 I.Isolate isolate = await I.Isolate.spawnUri(spawnUri, [], null); | 28 I.Isolate isolate = await I.Isolate.spawnUri(spawnUri, [], null); |
| 30 print(isolate); | 29 print(isolate); |
| 31 debugger(); | 30 debugger(); |
| 32 } | 31 } |
| 33 | 32 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 58 vm.isolates.firstWhere((Isolate i) => i != mainIsolate); | 57 vm.isolates.firstWhere((Isolate i) => i != mainIsolate); |
| 59 expect(slaveIsolate, isNotNull); | 58 expect(slaveIsolate, isNotNull); |
| 60 | 59 |
| 61 // Invoke test in v1. | 60 // Invoke test in v1. |
| 62 String v1 = await invokeTest(slaveIsolate); | 61 String v1 = await invokeTest(slaveIsolate); |
| 63 expect(v1, 'apple'); | 62 expect(v1, 'apple'); |
| 64 | 63 |
| 65 // Reload to v2. | 64 // Reload to v2. |
| 66 var response = await slaveIsolate.reloadSources( | 65 var response = await slaveIsolate.reloadSources( |
| 67 rootLibUri: v2Uri.toString(), | 66 rootLibUri: v2Uri.toString(), |
| 68 packagesUri: v2PackagesUri.toString(), | |
| 69 ); | 67 ); |
| 70 print(response); | 68 print(response); |
| 71 expect(response['success'], isTrue); | 69 expect(response['success'], isTrue); |
| 72 | 70 |
| 73 // Invoke test in v2. | 71 // Invoke test in v2. |
| 74 String v2 = await invokeTest(slaveIsolate); | 72 String v2 = await invokeTest(slaveIsolate); |
| 75 expect(v2, 'fooLib'); | 73 expect(v2, 'banana'); |
| 76 | 74 |
| 77 // Reload to v3. | 75 // Reload to v3. |
| 78 response = await slaveIsolate.reloadSources( | 76 response = await slaveIsolate.reloadSources( |
| 79 rootLibUri: v3Uri.toString(), | 77 rootLibUri: v3Uri.toString(), |
| 80 ); | 78 ); |
| 81 expect(response['success'], isTrue); | 79 expect(response['success'], isTrue); |
| 82 | 80 |
| 83 // Invoke test in v3. | 81 // Invoke test in v3. |
| 84 String v3 = await invokeTest(slaveIsolate); | 82 String v3 = await invokeTest(slaveIsolate); |
| 85 expect(v3, 'cabbage'); | 83 expect(v3, 'cabbage'); |
| 86 } | 84 } |
| 87 ]; | 85 ]; |
| 88 | 86 |
| 89 main(args) => runIsolateTests(args, tests, testeeConcurrent: testMain); | 87 main(args) => runIsolateTests(args, tests, testeeConcurrent: testMain); |
| OLD | NEW |