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

Unified Diff: runtime/observatory/test/coverage_test.dart

Issue 1071363002: Relocate service library tests and hookup a working status file (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 8 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
« no previous file with comments | « runtime/observatory/test/contexts_test.dart ('k') | runtime/observatory/test/debugging_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/observatory/test/coverage_test.dart
diff --git a/runtime/observatory/test/coverage_test.dart b/runtime/observatory/test/coverage_test.dart
deleted file mode 100644
index db9db76b5d1a7d19dededab90ef6a3730557603a..0000000000000000000000000000000000000000
--- a/runtime/observatory/test/coverage_test.dart
+++ /dev/null
@@ -1,155 +0,0 @@
-// Copyright (c) 2015, 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=--compile-all --error_on_bad_type --error_on_bad_override --checked
-
-import 'package:observatory/service_io.dart';
-import 'package:unittest/unittest.dart';
-import 'test_helper.dart';
-import 'dart:async';
-
-int globalVar = 100;
-
-class MyClass {
- static void myFunction(int value) {
- print(value); // line 14
- if (value < 0) {
- print("negative");
- } else {
- print("positive");
- }
- }
-
- static void otherFunction(int value) {
- if (value < 0) {
- print("otherFunction <");
- } else {
- print("otherFunction >=");
- }
- }
-}
-
-void testFunction() {
- MyClass.otherFunction(-100);
- int i = 0;
- while (true) {
- if (++i % 100000000 == 0) {
- MyClass.myFunction(10000);
- }
- }
-}
-
-List normalize(List coverage) {
- // The exact coverage numbers may vary based on how many times
- // things run. Normalize the data to 0 or 1.
- List normalized = [];
- for (int i = 0; i < coverage.length; i += 2) {
- normalized.add(coverage[i]);
- normalized.add(coverage[i+1] == 0 ? 0 : 1);
- }
- return normalized;
-}
-
-var tests = [
-
-// Go to breakpoint at line 14.
-(Isolate isolate) {
- return isolate.rootLib.load().then((_) {
- // Set up a listener to wait for breakpoint events.
- Completer completer = new Completer();
- isolate.vm.events.stream.listen((ServiceEvent event) {
- if (event.eventType == ServiceEvent.kPauseBreakpoint) {
- print('Breakpoint reached');
- completer.complete();
- }
- });
-
- // Create a timer to set a breakpoint with a short delay.
- new Timer(new Duration(milliseconds: 2000), () {
- // Add the breakpoint.
- print('Setting breakpoint.');
- var script = isolate.rootLib.scripts[0];
- var line = 14;
- isolate.addBreakpoint(script, line);
- });
-
- return completer.future;
- });
-},
-
-// Get coverage for function, class, library, script, and isolate.
-(Isolate isolate) {
- return isolate.getStack().then((ServiceMap stack) {
- // Make sure we are in the right place.
- expect(stack.type, equals('Stack'));
- expect(stack['frames'].length, greaterThanOrEqualTo(2));
- expect(stack['frames'][0]['function'].name, equals('myFunction'));
- expect(stack['frames'][0]['function'].dartOwner.name, equals('MyClass'));
-
- var lib = isolate.rootLib;
- var func = stack['frames'][0]['function'];
- expect(func.name, equals('myFunction'));
- var cls = stack['frames'][0]['function'].dartOwner;
- expect(cls.name, equals('MyClass'));
-
- List tests = [];
- // Function
- tests.add(isolate.invokeRpcNoUpgrade('getCoverage',
- { 'targetId': func.id })
- .then((Map coverage) {
- expect(coverage['type'], equals('CodeCoverage'));
- expect(coverage['coverage'].length, equals(1));
- expect(normalize(coverage['coverage'][0]['hits']),
- equals([15, 1, 16, 1, 17, 0, 19, 1]));
- }));
- // Class
- tests.add(isolate.invokeRpcNoUpgrade('getCoverage',
- { 'targetId': cls.id })
- .then((Map coverage) {
- expect(coverage['type'], equals('CodeCoverage'));
- expect(coverage['coverage'].length, equals(1));
- expect(normalize(coverage['coverage'][0]['hits']),
- equals([15, 1, 16, 1, 17, 0, 19, 1,
- 24, 1, 25, 1, 27, 0]));
- }));
- // Library
- tests.add(isolate.invokeRpcNoUpgrade('getCoverage',
- { 'targetId': lib.id })
- .then((Map coverage) {
- expect(coverage['type'], equals('CodeCoverage'));
- expect(coverage['coverage'].length, equals(3));
- expect(normalize(coverage['coverage'][0]['hits']),
- equals([15, 1, 16, 1, 17, 0, 19, 1,
- 24, 1, 25, 1, 27, 0]));
- expect(normalize(coverage['coverage'][1]['hits']).take(12),
- equals([33, 1, 36, 1, 37, 0, 32, 1, 45, 0, 46, 0]));
- }));
- // Script
- tests.add(cls.load().then((_) {
- return isolate.invokeRpcNoUpgrade('getCoverage',
- { 'targetId': cls.script.id })
- .then((Map coverage) {
- expect(coverage['type'], equals('CodeCoverage'));
- expect(coverage['coverage'].length, equals(3));
- expect(normalize(coverage['coverage'][0]['hits']),
- equals([15, 1, 16, 1, 17, 0, 19, 1,
- 24, 1, 25, 1, 27, 0]));
- expect(normalize(coverage['coverage'][1]['hits']).take(12),
- equals([33, 1, 36, 1, 37, 0, 32, 1, 45, 0, 46, 0]));
- });
- }));
- // Isolate
- tests.add(cls.load().then((_) {
- return isolate.invokeRpcNoUpgrade('getCoverage', {})
- .then((Map coverage) {
- expect(coverage['type'], equals('CodeCoverage'));
- expect(coverage['coverage'].length, greaterThan(100));
- });
- }));
- return Future.wait(tests);
- });
-},
-
-];
-
-main(args) => runIsolateTests(args, tests, testeeConcurrent: testFunction);
« no previous file with comments | « runtime/observatory/test/contexts_test.dart ('k') | runtime/observatory/test/debugging_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698