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

Side by Side Diff: pkg/analyzer_experimental/bin/coverage.dart

Issue 16964008: Code coverage, something is working now. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixes for Bob review comments. Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/analyzer_experimental/lib/src/services/runtime/coverage/coverage_impl.dart » ('j') | 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 library runtime.coverage; 5 library runtime.coverage;
6 6
7 import "package:logging/logging.dart" as log; 7 import 'dart:io';
8 8
9 import 'package:analyzer_experimental/src/services/runtime/coverage_impl.dart'; 9 import 'package:args/args.dart' show ArgParser, ArgResults;
10
11 import 'package:analyzer_experimental/src/services/runtime/log.dart' as log;
12 import 'package:analyzer_experimental/src/services/runtime/coverage/coverage_imp l.dart';
10 13
11 14
12 main() { 15 main() {
13 var logger = log.Logger.root; 16 ArgResults options;
14 logger.level = log.Level.ALL; 17 try {
15 logger.onRecord.listen((log.LogRecord record) { 18 options = _argParser.parse(new Options().arguments);
16 String levelString = record.level.toString(); 19 } on FormatException catch (e) {
17 while (levelString.length < 6) levelString += ' '; 20 print(e.message);
18 print('${record.time}: ${levelString} ${record.message}'); 21 print('Run "coverage --help" to see available options.');
19 }); 22 exit(ERROR);
20 // TODO(scheglov) get script from options 23 }
21 new CoverageServer('/Users/scheglov/dart/Test/bin').start(); 24
22 } 25 if (options['help']) {
26 printUsage();
27 return;
28 }
29
30 // No script to run.
31 if (options.rest.isEmpty) {
32 printUsage('<No script to run specified>');
33 exit(ERROR);
34 }
35
36 // More than one script specified.
37 if (options.rest.length != 1) {
38 print('<Only one script should be specified>');
39 exit(ERROR);
40 }
41
42 var scriptPath = options.rest[0];
43
44 // Validate that script file exists.
45 if (!new File(scriptPath).existsSync()) {
46 print('<File "$scriptPath" does not exist>');
47 exit(ERROR);
48 }
49
50 // Prepare output file path.
51 var outPath = options['out'];
52 if (outPath == null) {
53 printUsage('No --out specified.');
54 exit(ERROR);
55 }
56
57 // Configure logigng.
58 log.everything();
59 log.toConsole();
60
61 // Run script.
62 runServerApplication(scriptPath, outPath);
63 }
64
65
66 final ArgParser _argParser = new ArgParser()
67 ..addFlag('help', negatable: false, help: 'Print this usage information.')
68 ..addOption(
69 'level',
70 help: 'The level of the coverage.',
71 allowed: ['method', 'block', 'statement'],
72 defaultsTo: 'statement')
73 ..addOption('out', help: 'The output file with statistics.')
74 ..addOption(
75 'port',
76 help: 'The port to run server on, if 0 select any.',
77 defaultsTo: '0');
78
79
80 printUsage([var description = 'Code coverage tool for Dart.']) {
81 var buffer = new StringBuffer();
82 var usage = _argParser.getUsage();
83 buffer.write(
84 '$description\n\n'
85 'Usage: coverage [options] <script>\n\n'
86 '$usage\n\n');
87 print(buffer.toString());
88 }
89
90
91 /// General error code.
92 const ERROR = 1;
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer_experimental/lib/src/services/runtime/coverage/coverage_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698