Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(331)

Side by Side Diff: runtime/observatory/tests/service/complex_reload_test.dart

Issue 2518643002: Add a complex reload test that rebases the root script path three times. (Closed)
Patch Set: turnidge review Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/observatory/tests/service/complex_reload/v3/main.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4 // VMOptions=--error_on_bad_type --error_on_bad_override
5
6 import 'test_helper.dart';
7 import 'dart:async';
8 import 'dart:developer';
9 import 'dart:isolate' as I;
10 import 'dart:io';
11 import 'service_test_common.dart';
12 import 'package:observatory/service.dart';
13 import 'package:unittest/unittest.dart';
14
15 testMain() async {
16 debugger(); // Stop here.
17 // Spawn the child isolate.
18 I.Isolate isolate =
19 await I.Isolate.spawnUri(Uri.parse('complex_reload/v1/main.dart'),
20 [],
21 null);
22 print(isolate);
23 debugger();
24 }
25
26 // Directory that we are running in.
27 String directory = Platform.pathSeparator +
28 Platform.script.pathSegments.sublist(
29 0,
30 Platform.script.pathSegments.length - 1).join(Platform.pathSeparator);
31
32 Future<String> invokeTest(Isolate isolate) async {
33 await isolate.reload();
34 Library lib = isolate.rootLibrary;
35 await lib.load();
36 Instance result = await lib.evaluate('test()');
37 expect(result.isString, isTrue);
38 return result.valueAsString;
39 }
40
41 var tests = [
42 // Stopped at 'debugger' statement.
43 hasStoppedAtBreakpoint,
44 // Resume the isolate into the while loop.
45 resumeIsolate,
46 // Stop at 'debugger' statement.
47 hasStoppedAtBreakpoint,
48 (Isolate mainIsolate) async {
49 // Grab the VM.
50 VM vm = mainIsolate.vm;
51 await vm.reloadIsolates();
52 expect(vm.isolates.length, 2);
53
54 // Find the slave isolate.
55 Isolate slaveIsolate =
56 vm.isolates.firstWhere((Isolate i) => i != mainIsolate);
57 expect(slaveIsolate, isNotNull);
58
59 // Invoke test in v1.
60 String v1 = await invokeTest(slaveIsolate);
61 expect(v1, 'apple');
62
63 // Reload to v2.
64 var response = await slaveIsolate.reloadSources(
65 rootLibUri: '$directory/complex_reload/v2/main.dart',
66 );
67 expect(response['success'], isTrue);
68
69 // Invoke test in v2.
70 String v2 = await invokeTest(slaveIsolate);
71 expect(v2, 'banana');
72
73 // Reload to v3.
74 response = await slaveIsolate.reloadSources(
75 rootLibUri: '$directory/complex_reload/v3/main.dart',
76 );
77 expect(response['success'], isTrue);
78
79 // Invoke test in v3.
80 String v3 = await invokeTest(slaveIsolate);
81 expect(v3, 'cabbage');
82 }
83 ];
84
85 main(args) => runIsolateTests(args, tests, testeeConcurrent: testMain);
OLDNEW
« no previous file with comments | « runtime/observatory/tests/service/complex_reload/v3/main.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698