Skip to content
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ pubspec.lock

# generated assets in test fixtures
/test/fixtures/coverage/browser/coverage/
/test/fixtures/coverage/non_test_file/coverage/
/test/fixtures/coverage/vm/coverage/
/test/fixtures/docs/docs/doc/api/
3 changes: 2 additions & 1 deletion lib/src/tasks/coverage/api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import 'package:dart_dev/src/tasks/coverage/config.dart';
import 'package:dart_dev/src/tasks/coverage/exceptions.dart';
import 'package:dart_dev/src/tasks/task.dart';

const String _dartFilePattern = '.dart';
const String _testFilePattern = '_test.dart';

class CoverageResult extends TaskResult {
Expand Down Expand Up @@ -140,7 +141,7 @@ class CoverageTask extends Task {
_reportOn = reportOn {
// Build the list of test files.
tests.forEach((path) {
if (path.endsWith(_testFilePattern) &&
if (path.endsWith(_dartFilePattern) &&
FileSystemEntity.isFileSync(path)) {
_files.add(new File(path));
} else if (FileSystemEntity.isDirectorySync(path)) {
Expand Down
9 changes: 9 additions & 0 deletions test/fixtures/coverage/non_test_file/lib/non_test_file.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
library non_test_file;

import 'dart:io';

void notCovered() {
print('nope');
}

bool works() => stdout is IOSink;
7 changes: 7 additions & 0 deletions test/fixtures/coverage/non_test_file/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: non_test_file
version: 0.0.0
dev_dependencies:
coverage: "^0.7.2"
dart_dev:
path: ../../../..
test: "^0.12.0"
11 changes: 11 additions & 0 deletions test/fixtures/coverage/non_test_file/test/file.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@TestOn('vm')
library coverage.non_test_file.test.file;

import 'package:non_test_file/non_test_file.dart' as lib;
import 'package:test/test.dart';

main() {
test('non_test_file', () {
expect(lib.works(), isTrue);
});
}
9 changes: 9 additions & 0 deletions test/fixtures/coverage/non_test_file/tool/dev.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
library tool.dev;

import 'package:dart_dev/dart_dev.dart' show dev, config;

main(List<String> args) async {
config.test.unitTests = ['test/file.dart'];

await dev(args);
}
7 changes: 7 additions & 0 deletions test/integration/coverage_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import 'dart:io';
import 'package:dart_dev/util.dart' show TaskProcess;
import 'package:test/test.dart';

const String projectWithDartFile = 'test/fixtures/coverage/non_test_file';
const String projectWithVmTests = 'test/fixtures/coverage/browser';
const String projectWithBrowserTests = 'test/fixtures/coverage/vm';
const String projectWithoutCoveragePackage =
Expand Down Expand Up @@ -60,6 +61,12 @@ void main() {
expect(await runCoverage(projectWithoutCoveragePackage), isFalse);
});

test('should create coverage with non_test file specified', () async {
expect(await runCoverage(projectWithDartFile), isTrue);
File lcov = new File('$projectWithDartFile/coverage/coverage.lcov');
expect(lcov.existsSync(), isTrue);
}, timeout: new Timeout(new Duration(seconds: 60)));

// TODO: Will need to mock out the `genhtml` command as well.
// test('should not fail if "lcov" is installed and --html is set', () async {
// MockPlatformUtil.install();
Expand Down