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

Unified Diff: runtime/observatory/tests/service/bad_reload_test.dart

Issue 2748353004: Only propagate reload errors when there are Dart frames on the stack. (Closed)
Patch Set: rmacnak review 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 side-by-side diff with in-line comments
Download patch
Index: runtime/observatory/tests/service/bad_reload_test.dart
diff --git a/runtime/observatory/tests/service/bad_reload_test.dart b/runtime/observatory/tests/service/bad_reload_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..a11a3d8326cf43fd349bd4a8f8fc284cca8247d4
--- /dev/null
+++ b/runtime/observatory/tests/service/bad_reload_test.dart
@@ -0,0 +1,85 @@
+// Copyright (c) 2017, 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:path/path.dart' as path;
+import 'package:unittest/unittest.dart';
+
+// Chop off the file name.
+String baseDirectory =
+ path.dirname(Platform.script.path) + '/';
+
+Uri baseUri = Platform.script.replace(path: baseDirectory);
+Uri spawnUri = baseUri.resolveUri(Uri.parse('bad_reload/v1/main.dart'));
+Uri v2Uri = baseUri.resolveUri(Uri.parse('bad_reload/v2/main.dart'));
+
+testMain() async {
+ print(baseUri);
+ debugger(); // Stop here.
+ // Spawn the child isolate.
+ I.Isolate isolate =
+ await I.Isolate.spawnUri(spawnUri,
+ [],
+ null);
+ print(isolate);
+ debugger();
+}
+
+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: v2Uri.toString(),
+ );
+ // Observe that it failed.
+ expect(response['success'], isFalse);
+ List<Map<String, dynamic>> notices = response['details']['notices'];
+ expect(notices.length, equals(1));
+ Map<String, dynamic> reasonForCancelling = notices[0];
+ expect(reasonForCancelling['type'], equals('ReasonForCancelling'));
+ expect(reasonForCancelling['message'], contains('library_isnt_here_man'));
+
+ // Invoke test in v2.
+ String v2 = await invokeTest(slaveIsolate);
+ expect(v2, 'apple');
+ }
+];
+
+main(args) => runIsolateTests(args, tests, testeeConcurrent: testMain);

Powered by Google App Engine
This is Rietveld 408576698