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

Side by Side Diff: tests/standalone/full_coverage_test.dart

Issue 1688933002: Add debugging output to full_coverage_test to help diagnose timeouts. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 4
5 // These tests fork a second VM process that runs the script 5 // These tests fork a second VM process that runs the script
6 // ``tools/full-coverage.dart'' and verifies that the tool 6 // ``tools/full-coverage.dart'' and verifies that the tool
7 // produces the expeced output. 7 // produces the expeced output.
8 8
9 import 'dart:async'; 9 import 'dart:async';
10 import 'dart:convert'; 10 import 'dart:convert';
11 import 'dart:io'; 11 import 'dart:io';
12 12
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 final String coverageScript = 16 final String coverageScript =
17 Platform.script.resolve('../../tools/full-coverage.dart').toFilePath(); 17 Platform.script.resolve('../../tools/full-coverage.dart').toFilePath();
18 final String packageRoot = Platform.packageRoot; 18 final String packageRoot = Platform.packageRoot;
19 final List dartBaseArgs = ['--package-root=${packageRoot}', '--checked',]; 19 final List dartBaseArgs = ['--package-root=${packageRoot}', '--checked',];
20 final Stopwatch sw = new Stopwatch();
21
22 int elapsed() => sw.elapsedMilliseconds;
20 23
21 // With line numbers starting at 0, the list of hits can be understood as 24 // With line numbers starting at 0, the list of hits can be understood as
22 // follows: 25 // follows:
23 // * -1: No coverage data on this line. 26 // * -1: No coverage data on this line.
24 // * 0: No hits on this line. 27 // * 0: No hits on this line.
25 // * 1: ``Some'' hits on this line. 28 // * 1: ``Some'' hits on this line.
26 final coverageTests = [ 29 final coverageTests = [
27 { 30 {
28 'name': 'faculty', 31 'name': 'faculty',
29 'program': ''' 32 'program': '''
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 } 84 }
82 return testDir.path; 85 return testDir.path;
83 } 86 }
84 87
85 88
86 destroyEnv(base) => new Directory(base).deleteSync(recursive: true); 89 destroyEnv(base) => new Directory(base).deleteSync(recursive: true);
87 90
88 91
89 generateCoverage(String workingDirectory) { 92 generateCoverage(String workingDirectory) {
90 for (var coverageProg in coverageTests) { 93 for (var coverageProg in coverageTests) {
94 print('[+${elapsed()}ms] Generating data for ${coverageProg["name"]}');
91 var progPath = path.join(workingDirectory, coverageProg['name']); 95 var progPath = path.join(workingDirectory, coverageProg['name']);
92 var script = path.join(progPath, "${coverageProg['name']}.dart"); 96 var script = path.join(progPath, "${coverageProg['name']}.dart");
93 var dartArgs = new List.from(dartBaseArgs) 97 var dartArgs = new List.from(dartBaseArgs)
94 ..addAll(['--coverage-dir=${progPath}', '${script}']); 98 ..addAll(['--coverage-dir=${progPath}', '${script}']);
95 var result = Process.runSync(Platform.executable, dartArgs); 99 var result = Process.runSync(Platform.executable, dartArgs);
96 if (result.exitCode != 0) { 100 if (result.exitCode != 0) {
97 print("Coverage generator returned exitCode: ${result.exitCode}."); 101 print("[+${elapsed()}ms] Got exitCode: ${result.exitCode}.");
98 print("stderr:\n${result.stderr}\n"); 102 print("stderr:\n${result.stderr}\n");
99 expect(result.exitCode, 0); 103 expect(result.exitCode, 0);
100 } 104 }
101 } 105 }
102 } 106 }
103 107
104 108
105 Future<Process> convertCoverage(String programDir, String format) { 109 Future<Process> convertCoverage(String programDir, String format) {
106 var dartArgs = new List.from(dartBaseArgs) 110 var dartArgs = new List.from(dartBaseArgs)
107 ..addAll([ 111 ..addAll([
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 // Make sure that there are only lines left that do not contain coverage 209 // Make sure that there are only lines left that do not contain coverage
206 // data. 210 // data.
207 expectedHitMap.forEach((e) => expect(e, -1)); 211 expectedHitMap.forEach((e) => expect(e, -1));
208 }), completes); 212 }), completes);
209 }), completes); 213 }), completes);
210 } 214 }
211 215
212 216
213 main() { 217 main() {
214 String testingDirectory; 218 String testingDirectory;
219 sw.start();
215 220
216 setUp(() { 221 setUp(() {
217 testingDirectory = prepareEnv(); 222 testingDirectory = prepareEnv();
218 }); 223 });
219 224
220 tearDown(() => destroyEnv(testingDirectory)); 225 tearDown(() => destroyEnv(testingDirectory));
221 226
222 test('CoverageTests', () { 227 test('CoverageTests', () {
223 print('Generating coverage data...'); 228 print('[+${elapsed()}ms] Generating coverage data...');
224 generateCoverage(testingDirectory); 229 generateCoverage(testingDirectory);
225 print('Done Generating coverage data.'); 230 print('[+${elapsed()}ms] Done Generating coverage data.');
226 231
227 print('Running tests...'); 232 print('[+${elapsed()}ms] Running tests...');
228 coverageTests.forEach((cTest) { 233 coverageTests.forEach((cTest) {
229 String programDir = path.join(testingDirectory, cTest['name']); 234 String programDir = path.join(testingDirectory, cTest['name']);
230 String programPath = path.join(programDir, "${cTest['name']}.dart"); 235 String programPath = path.join(programDir, "${cTest['name']}.dart");
236 print('[+${elapsed()}ms] Testing lcov for ${cTest["name"]}');
231 testCoverage(programDir, programPath, 237 testCoverage(programDir, programPath,
232 new LcovDescriptor(programPath), 238 new LcovDescriptor(programPath),
233 new List.from(cTest['expectedHits'])); 239 new List.from(cTest['expectedHits']));
240 print('[+${elapsed()}ms] Testing pretty print for ${cTest["name"]}');
234 testCoverage(programDir, programPath, 241 testCoverage(programDir, programPath,
235 new PrettyPrintDescriptor(programPath), 242 new PrettyPrintDescriptor(programPath),
236 new List.from(cTest['expectedHits'])); 243 new List.from(cTest['expectedHits']));
237 }); 244 });
245 print('[+${elapsed()}ms] Done.');
238 }); 246 });
239 } 247 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698