mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 15:17:07 +00:00
Add a complex reload test that rebases the root script path three times.
BUG= R=turnidge@google.com Review URL: https://codereview.chromium.org/2518643002 .
This commit is contained in:
parent
80e227a840
commit
8a7f7715f1
5 changed files with 123 additions and 2 deletions
|
@ -1333,9 +1333,19 @@ class Isolate extends ServiceObjectOwner implements M.Isolate {
|
|||
return invokeRpc('getSourceReport', params);
|
||||
}
|
||||
|
||||
Future<ServiceMap> reloadSources() {
|
||||
return invokeRpc('_reloadSources', {}).then((_) {
|
||||
Future<ServiceMap> reloadSources(
|
||||
{String rootLibUri,
|
||||
bool pause}) {
|
||||
Map<String, dynamic> params = <String, dynamic>{};
|
||||
if (rootLibUri != null) {
|
||||
params['rootLibUri'] = rootLibUri;
|
||||
}
|
||||
if (pause != null) {
|
||||
params['pause'] = pause;
|
||||
}
|
||||
return invokeRpc('reloadSources', params).then((result) {
|
||||
reloading = true;
|
||||
return result;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
// VMOptions=--error_on_bad_type --error_on_bad_override
|
||||
|
||||
import 'dart:isolate';
|
||||
|
||||
test() => 'apple';
|
||||
|
||||
main() {
|
||||
RawReceivePort keepAlive = new RawReceivePort();
|
||||
print('slave isolate running');
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
// VMOptions=--error_on_bad_type --error_on_bad_override
|
||||
|
||||
test() => 'banana';
|
|
@ -0,0 +1,6 @@
|
|||
// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
// VMOptions=--error_on_bad_type --error_on_bad_override
|
||||
|
||||
test() => 'cabbage';
|
85
runtime/observatory/tests/service/complex_reload_test.dart
Normal file
85
runtime/observatory/tests/service/complex_reload_test.dart
Normal file
|
@ -0,0 +1,85 @@
|
|||
// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
// VMOptions=--error_on_bad_type --error_on_bad_override
|
||||
|
||||
import 'test_helper.dart';
|
||||
import 'dart:async';
|
||||
import 'dart:developer';
|
||||
import 'dart:isolate' as I;
|
||||
import 'dart:io';
|
||||
import 'service_test_common.dart';
|
||||
import 'package:observatory/service.dart';
|
||||
import 'package:unittest/unittest.dart';
|
||||
|
||||
testMain() async {
|
||||
debugger(); // Stop here.
|
||||
// Spawn the child isolate.
|
||||
I.Isolate isolate =
|
||||
await I.Isolate.spawnUri(Uri.parse('complex_reload/v1/main.dart'),
|
||||
[],
|
||||
null);
|
||||
print(isolate);
|
||||
debugger();
|
||||
}
|
||||
|
||||
// Directory that we are running in.
|
||||
String directory = Platform.pathSeparator +
|
||||
Platform.script.pathSegments.sublist(
|
||||
0,
|
||||
Platform.script.pathSegments.length - 1).join(Platform.pathSeparator);
|
||||
|
||||
Future<String> invokeTest(Isolate isolate) async {
|
||||
await isolate.reload();
|
||||
Library lib = isolate.rootLibrary;
|
||||
await lib.load();
|
||||
Instance result = await lib.evaluate('test()');
|
||||
expect(result.isString, isTrue);
|
||||
return result.valueAsString;
|
||||
}
|
||||
|
||||
var tests = [
|
||||
// Stopped at 'debugger' statement.
|
||||
hasStoppedAtBreakpoint,
|
||||
// Resume the isolate into the while loop.
|
||||
resumeIsolate,
|
||||
// Stop at 'debugger' statement.
|
||||
hasStoppedAtBreakpoint,
|
||||
(Isolate mainIsolate) async {
|
||||
// Grab the VM.
|
||||
VM vm = mainIsolate.vm;
|
||||
await vm.reloadIsolates();
|
||||
expect(vm.isolates.length, 2);
|
||||
|
||||
// Find the slave isolate.
|
||||
Isolate slaveIsolate =
|
||||
vm.isolates.firstWhere((Isolate i) => i != mainIsolate);
|
||||
expect(slaveIsolate, isNotNull);
|
||||
|
||||
// Invoke test in v1.
|
||||
String v1 = await invokeTest(slaveIsolate);
|
||||
expect(v1, 'apple');
|
||||
|
||||
// Reload to v2.
|
||||
var response = await slaveIsolate.reloadSources(
|
||||
rootLibUri: '$directory/complex_reload/v2/main.dart',
|
||||
);
|
||||
expect(response['success'], isTrue);
|
||||
|
||||
// Invoke test in v2.
|
||||
String v2 = await invokeTest(slaveIsolate);
|
||||
expect(v2, 'banana');
|
||||
|
||||
// Reload to v3.
|
||||
response = await slaveIsolate.reloadSources(
|
||||
rootLibUri: '$directory/complex_reload/v3/main.dart',
|
||||
);
|
||||
expect(response['success'], isTrue);
|
||||
|
||||
// Invoke test in v3.
|
||||
String v3 = await invokeTest(slaveIsolate);
|
||||
expect(v3, 'cabbage');
|
||||
}
|
||||
];
|
||||
|
||||
main(args) => runIsolateTests(args, tests, testeeConcurrent: testMain);
|
Loading…
Reference in a new issue