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

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

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

Powered by Google App Engine
This is Rietveld 408576698