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

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

Issue 2759973004: Fix observatory tests broken by running dartfmt. Temporarily reverted formatting for evaluate_activ… (Closed)
Patch Set: Created 3 years, 9 months 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
OLDNEW
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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 = 17 String baseDirectory = path.dirname(Platform.script.path) + '/';
18 path.dirname(Platform.script.path) + '/';
19 18
20 Uri baseUri = Platform.script.replace(path: baseDirectory); 19 Uri baseUri = Platform.script.replace(path: baseDirectory);
21 Uri spawnUri = baseUri.resolveUri(Uri.parse('bad_reload/v1/main.dart')); 20 Uri spawnUri = baseUri.resolveUri(Uri.parse('bad_reload/v1/main.dart'));
22 Uri v2Uri = baseUri.resolveUri(Uri.parse('bad_reload/v2/main.dart')); 21 Uri v2Uri = baseUri.resolveUri(Uri.parse('bad_reload/v2/main.dart'));
23 22
24 testMain() async { 23 testMain() async {
25 print(baseUri); 24 print(baseUri);
26 debugger(); // Stop here. 25 debugger(); // Stop here.
27 // Spawn the child isolate. 26 // Spawn the child isolate.
28 I.Isolate isolate = 27 I.Isolate isolate = await I.Isolate.spawnUri(spawnUri, [], null);
29 await I.Isolate.spawnUri(spawnUri,
30 [],
31 null);
32 print(isolate); 28 print(isolate);
33 debugger(); 29 debugger();
34 } 30 }
35 31
36 Future<String> invokeTest(Isolate isolate) async { 32 Future<String> invokeTest(Isolate isolate) async {
37 await isolate.reload(); 33 await isolate.reload();
38 Library lib = isolate.rootLibrary; 34 Library lib = isolate.rootLibrary;
39 await lib.load(); 35 await lib.load();
40 Instance result = await lib.evaluate('test()'); 36 Instance result = await lib.evaluate('test()');
41 expect(result.isString, isTrue); 37 expect(result.isString, isTrue);
(...skipping 17 matching lines...) Expand all
59 Isolate slaveIsolate = 55 Isolate slaveIsolate =
60 vm.isolates.firstWhere((Isolate i) => i != mainIsolate); 56 vm.isolates.firstWhere((Isolate i) => i != mainIsolate);
61 expect(slaveIsolate, isNotNull); 57 expect(slaveIsolate, isNotNull);
62 58
63 // Invoke test in v1. 59 // Invoke test in v1.
64 String v1 = await invokeTest(slaveIsolate); 60 String v1 = await invokeTest(slaveIsolate);
65 expect(v1, 'apple'); 61 expect(v1, 'apple');
66 62
67 // Reload to v2. 63 // Reload to v2.
68 var response = await slaveIsolate.reloadSources( 64 var response = await slaveIsolate.reloadSources(
69 rootLibUri: v2Uri.toString(), 65 rootLibUri: v2Uri.toString(),
70 ); 66 );
71 // Observe that it failed. 67 // Observe that it failed.
72 expect(response['success'], isFalse); 68 expect(response['success'], isFalse);
73 List<Map<String, dynamic>> notices = response['details']['notices']; 69 List<Map<String, dynamic>> notices = response['details']['notices'];
74 expect(notices.length, equals(1)); 70 expect(notices.length, equals(1));
75 Map<String, dynamic> reasonForCancelling = notices[0]; 71 Map<String, dynamic> reasonForCancelling = notices[0];
76 expect(reasonForCancelling['type'], equals('ReasonForCancelling')); 72 expect(reasonForCancelling['type'], equals('ReasonForCancelling'));
77 expect(reasonForCancelling['message'], contains('library_isnt_here_man')); 73 expect(reasonForCancelling['message'], contains('library_isnt_here_man'));
78 74
79 // Invoke test in v2. 75 // Invoke test in v2.
80 String v2 = await invokeTest(slaveIsolate); 76 String v2 = await invokeTest(slaveIsolate);
81 expect(v2, 'apple'); 77 expect(v2, 'apple');
82 } 78 }
83 ]; 79 ];
84 80
85 main(args) => runIsolateTests(args, tests, testeeConcurrent: testMain); 81 main(args) => runIsolateTests(args, tests, testeeConcurrent: testMain);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698