Files
sdk/pkg/analyzer_experimental/bin/coverage.dart
T
scheglov@google.com 0bd1a231e5 Fixes for forgotten review comments.
Sorry, I forgot to fix the most important review comments from previous CL = https://codereview.chromium.org/16964008/

R=rnystrom@google.com
BUG=

Review URL: https://codereview.chromium.org//16885003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@24157 260f80e4-7a28-3924-810f-c04153c831b5
2013-06-18 18:37:55 +00:00

90 lines
2.2 KiB
Dart

// Copyright (c) 2013, 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.
library runtime.coverage;
import 'dart:io';
import 'package:args/args.dart';
import 'package:analyzer_experimental/src/services/runtime/log.dart' as log;
import 'package:analyzer_experimental/src/services/runtime/coverage/coverage_impl.dart';
main() {
ArgResults options;
try {
options = _argParser.parse(new Options().arguments);
} on FormatException catch (e) {
print(e.message);
print('Run "coverage --help" to see available options.');
exit(ERROR);
}
if (options['help']) {
printUsage();
return;
}
// No script to run.
if (options.rest.isEmpty) {
printUsage('<No script to run specified>');
exit(ERROR);
}
// More than one script specified.
if (options.rest.length != 1) {
print('<Only one script should be specified>');
exit(ERROR);
}
var scriptPath = options.rest[0];
// Validate that script file exists.
if (!new File(scriptPath).existsSync()) {
print('<File "$scriptPath" does not exist>');
exit(ERROR);
}
// Prepare output file path.
var outPath = options['out'];
if (outPath == null) {
printUsage('No --out specified.');
exit(ERROR);
}
// Configure logigng.
log.everything();
log.toConsole();
// Run script.
runServerApplication(scriptPath, outPath);
}
final ArgParser _argParser = new ArgParser()
..addFlag('help', negatable: false, help: 'Print this usage information.')
..addOption(
'level',
help: 'The level of the coverage.',
allowed: ['method', 'block', 'statement'],
defaultsTo: 'statement')
..addOption('out', help: 'The output file with statistics.')
..addOption(
'port',
help: 'The port to run server on, if 0 select any.',
defaultsTo: '0');
printUsage([var description = 'Code coverage tool for Dart.']) {
var usage = _argParser.getUsage();
print('$description\n');
print('Usage: coverage [options] <script>\n');
print('$usage\n');
}
/// General error code.
const ERROR = 1;