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

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

Issue 1846443002: - Remove --coverage_dir flag and old-style coverage service requests. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Remove obsolete tests. Created 4 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 unified diff | Download patch
« no previous file with comments | « runtime/observatory/tests/service/call_site_data_test.dart ('k') | runtime/vm/coverage.h » ('j') | 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) 2015, 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 'package:observatory/service_io.dart';
7 import 'package:unittest/unittest.dart';
8 import 'test_helper.dart';
9 import 'service_test_common.dart';
10 import 'dart:developer';
11
12 const int LINE_A = 20;
13 const int LINE_B = 38;
14 const int LINE_C = 136;
15
16 int globalVar = 100;
17
18 class MyClass {
19 static void myFunction(int value) {
20 if (value < 0) { // Line A.
21 print("negative");
22 } else {
23 print("positive");
24 }
25 debugger();
26 }
27
28 static void otherFunction(int value) {
29 if (value < 0) {
30 print("otherFunction <");
31 } else {
32 print("otherFunction >=");
33 }
34 }
35 }
36
37 void testFunction() {
38 MyClass.otherFunction(-100); // Line B.
39 MyClass.myFunction(10000);
40 }
41
42 var tests = [
43
44 hasStoppedAtBreakpoint,
45
46 // Get coverage for function, class, library, script, and isolate.
47 (Isolate isolate) async {
48 var stack = await isolate.getStack();
49
50 // Make sure we are in the right place.
51 expect(stack.type, equals('Stack'));
52 expect(stack['frames'].length, greaterThanOrEqualTo(2));
53 expect(stack['frames'][0].function.name, equals('myFunction'));
54 expect(stack['frames'][0].function.dartOwner.name, equals('MyClass'));
55
56 var lib = isolate.rootLibrary;
57 var func = stack['frames'][0].function;
58 expect(func.name, equals('myFunction'));
59 var cls = func.dartOwner;
60 expect(cls.name, equals('MyClass'));
61
62 // Function
63 var coverage = await isolate.invokeRpcNoUpgrade('_getCoverage',
64 { 'targetId': func.id });
65 expect(coverage['type'], equals('CodeCoverage'));
66 expect(coverage['coverage'].length, equals(1));
67 expect(coverage['coverage'][0]['hits'],
68 equals([LINE_A, 1,
69 LINE_A + 1, 0,
70 LINE_A + 3, 1,
71 LINE_A + 5, 1]));
72
73 // Class
74 coverage = await isolate.invokeRpcNoUpgrade('_getCoverage',
75 { 'targetId': cls.id });
76 expect(coverage['type'], equals('CodeCoverage'));
77 expect(coverage['coverage'].length, equals(1));
78 expect(coverage['coverage'][0]['hits'],
79 equals([LINE_A, 1,
80 LINE_A + 1, 0,
81 LINE_A + 3, 1,
82 LINE_A + 5, 1,
83 LINE_A + 9, 1,
84 LINE_A + 10, 1,
85 LINE_A + 12, 0,
86 LINE_A - 2, 0]));
87
88 // Library
89 coverage = await isolate.invokeRpcNoUpgrade('_getCoverage',
90 { 'targetId': lib.id });
91 expect(coverage['type'], equals('CodeCoverage'));
92 expect(coverage['coverage'].length, equals(4));
93 expect(coverage['coverage'][0]['hits'],
94 equals([LINE_A, 1,
95 LINE_A + 1, 0,
96 LINE_A + 3, 1,
97 LINE_A + 5, 1,
98 LINE_A + 9, 1,
99 LINE_A + 10, 1,
100 LINE_A + 12, 0,
101 LINE_A - 2, 0]));
102 expect(coverage['coverage'][1]['hits'],
103 equals([LINE_B, 1,
104 LINE_B + 1, 1,
105 LINE_C, 2]));
106
107 // Script
108 await cls.load();
109 coverage = await isolate.invokeRpcNoUpgrade('_getCoverage',
110 { 'targetId': cls.location.script.id });
111 expect(coverage['type'], equals('CodeCoverage'));
112 expect(coverage['coverage'].length, equals(4));
113 expect(coverage['coverage'][0]['hits'],
114 equals([LINE_A, 1,
115 LINE_A + 1, 0,
116 LINE_A + 3, 1,
117 LINE_A + 5, 1,
118 LINE_A + 9, 1,
119 LINE_A + 10, 1,
120 LINE_A + 12, 0,
121 LINE_A - 2, 0]));
122 expect(coverage['coverage'][1]['hits'],
123 equals([LINE_B, 1,
124 LINE_B + 1, 1,
125 LINE_C, 2]));
126
127 // Isolate
128 coverage = await isolate.invokeRpcNoUpgrade('_getCoverage', {});
129 print('Done processing _getCoverage for full isolate');
130 expect(coverage['type'], equals('CodeCoverage'));
131 expect(coverage['coverage'].length, greaterThan(100));
132 },
133
134 ];
135
136 main(args) => runIsolateTests(args, tests, // Line C.
137 testeeConcurrent: testFunction,
138 trace_service: true);
OLDNEW
« no previous file with comments | « runtime/observatory/tests/service/call_site_data_test.dart ('k') | runtime/vm/coverage.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698