Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CP-839 New Task: Code Coverage #25

Merged
merged 1 commit into from
Aug 18, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.pub
packages
pubspec.lock
pubspec.lock

coverage/
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
All Dart (https://dartlang.org) projects eventually share a common set of development requirements:

- Tests (unit, integration, and functional)
- Code coverage
- Consistent code formatting
- Static analysis to detect issues
- Examples for manual testing/exploration
Expand Down Expand Up @@ -57,6 +58,7 @@ static analysis - you just need to know how to use the `dart_dev` tool.
## Supported Tasks

- **Tests:** runs test suites (unit, integration, and functional) via the [`test` package test runner](https://github.com/dart-lang/test).
- **Coverage:** collects coverage over test suites (unit, integration, and functional) and generates a report. Uses the [`coverage` package](https://github.com/dart-lang/coverage).
- **Code Formatting:** runs the [`dartfmt` tool from the `dart_style` package](https://github.com/dart-lang/dart_style) over source code.
- **Static Analysis:** runs the [`dartanalyzer`](https://www.dartlang.org/tools/analyzer/) over source code.
- **Serving Examples:** uses [`pub serve`](https://www.dartlang.org/tools/pub/cmd/pub-serve.html) to serve the project examples.
Expand Down Expand Up @@ -91,6 +93,9 @@ main(args) async {

// Define the directories where the LICENSE should be applied.
config.copyLicense.directories = ['example/', 'lib/'];

// Configure whether or not the HTML coverage report should be generated.
config.coverage.html = false;

// Configure the port on which examples should be served.
config.examples.port = 9000;
Expand Down Expand Up @@ -120,13 +125,15 @@ see the help usage. Try it out by running any of the following tasks:
# with the alias
ddev analyze
ddev copy-license
ddev coverage
ddev examples
ddev format
ddev test

# without the alias
pub run dart_dev analyze
pub run dart_dev copy-license
pub run dart_dev coverage
pub run dart_dev examples
pub run dart_dev format
pub run dart_dev test
Expand All @@ -146,6 +153,7 @@ main(args) async {
// Available config objects:
// config.analyze
// config.copyLicense
// config.coverage
// config.examples
// config.format
// config.init
Expand All @@ -172,6 +180,15 @@ Name | Type | Default | Description
`directories` | `List<String>` | `['lib/']` | All source files in these directories will have the LICENSE header applied.
`licensePath` | `String` | `LICENSE` | Path to the source LICENSE file that will be copied to all source files.

### `coverage` config
All configuration options for the `coverage` task are found on the `config.coverage` object.
However, the `coverage` task also uses the test suite configuration from the `config.test` object.

Name | Type | Default | Description
---------- | -------------- | ----------- | -----------
`html` | `bool` | `true` | Whether or not to generate the HTML report.
`output` | `String` | `coverage/` | Output directory for coverage artifacts.
`reportOn` | `List<String>` | `['lib/']` | List of paths to include in the generated coverage report (LCOV and HTML).

### `examples` Config
All configuration options for the `examples` task are found on the `config.examples` object.
Expand Down Expand Up @@ -220,6 +237,7 @@ Supported tasks:

analyze
copy-license
coverage
examples
format
init
Expand All @@ -228,6 +246,7 @@ Supported tasks:

- Static analysis: `ddev analyze`
- Applying license to source files: `ddev copy-license`
- Code coverage: `ddev coverage`
- Serving examples: `ddev examples`
- Dart formatter: `ddev format`
- Initialization: `ddev init`
Expand Down
2 changes: 2 additions & 0 deletions lib/src/dart_dev_cli.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import 'package:dart_dev/src/tasks/config.dart';

import 'package:dart_dev/src/tasks/analyze/cli.dart';
import 'package:dart_dev/src/tasks/copy_license/cli.dart';
import 'package:dart_dev/src/tasks/coverage/cli.dart';
import 'package:dart_dev/src/tasks/examples/cli.dart';
import 'package:dart_dev/src/tasks/format/cli.dart';
import 'package:dart_dev/src/tasks/init/cli.dart';
Expand All @@ -54,6 +55,7 @@ String _topLevelUsage = _parser.usage;
dev(List<String> args) async {
registerTask(new AnalyzeCli(), config.analyze);
registerTask(new CopyLicenseCli(), config.copyLicense);
registerTask(new CoverageCli(), config.coverage);
registerTask(new ExamplesCli(), config.examples);
registerTask(new FormatCli(), config.format);
registerTask(new InitCli(), config.init);
Expand Down
2 changes: 2 additions & 0 deletions lib/src/tasks/config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ library dart_dev.src.tasks.config;

import 'package:dart_dev/src/tasks/analyze/config.dart';
import 'package:dart_dev/src/tasks/copy_license/config.dart';
import 'package:dart_dev/src/tasks/coverage/config.dart';
import 'package:dart_dev/src/tasks/examples/config.dart';
import 'package:dart_dev/src/tasks/format/config.dart';
import 'package:dart_dev/src/tasks/init/config.dart';
Expand All @@ -26,6 +27,7 @@ Config config = new Config();
class Config {
AnalyzeConfig analyze = new AnalyzeConfig();
CopyLicenseConfig copyLicense = new CopyLicenseConfig();
CoverageConfig coverage = new CoverageConfig();
ExamplesConfig examples = new ExamplesConfig();
FormatConfig format = new FormatConfig();
InitConfig init = new InitConfig();
Expand Down
Loading