Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
Copy collect_coverage's --scope-output flag to test_with_coverage. (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
liamappelbe authored May 6, 2024
1 parent f110e8b commit 88b1da8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.8.0

- Copy collect_coverage's `--scope-output` flag to test_with_coverage.

## 1.7.2

- Update `package:vm_service` constraints to '>=12.0.0 <15.0.0'.
Expand Down
13 changes: 11 additions & 2 deletions bin/test_with_coverage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ ArgParser _createArgParser() => ArgParser()
defaultsTo: false,
help: 'Collect branch coverage info.',
)
..addMultiOption('scope-output',
help: 'restrict coverage results so that only scripts that start with '
'the provided package path are considered. Defaults to the name of '
'the package under test.')
..addFlag('help', abbr: 'h', negatable: false, help: 'Show this help.');

class Flags {
Expand All @@ -90,7 +94,8 @@ class Flags {
this.port,
this.testScript,
this.functionCoverage,
this.branchCoverage, {
this.branchCoverage,
this.scopeOutput, {
required this.rest,
});

Expand All @@ -101,6 +106,7 @@ class Flags {
final String testScript;
final bool functionCoverage;
final bool branchCoverage;
final List<String> scopeOutput;
final List<String> rest;
}

Expand Down Expand Up @@ -154,6 +160,7 @@ ${parser.usage}
args['test'] as String,
args['function-coverage'] as bool,
args['branch-coverage'] as bool,
args['scope-output'] as List<String>,
rest: args.rest,
);
}
Expand Down Expand Up @@ -195,11 +202,13 @@ Future<void> main(List<String> arguments) async {
);
final serviceUri = await serviceUriCompleter.future;

final scopes =
flags.scopeOutput.isEmpty ? [flags.packageName] : flags.scopeOutput;
await collect_coverage.main([
'--wait-paused',
'--resume-isolates',
'--uri=$serviceUri',
'--scope-output=${flags.packageName}',
for (final scope in scopes) '--scope-output=$scope',
if (flags.branchCoverage) '--branch-coverage',
if (flags.functionCoverage) '--function-coverage',
'-o',
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: coverage
version: 1.7.2
version: 1.8.0
description: Coverage data manipulation and formatting
repository: https://github.com/dart-lang/coverage

Expand Down

0 comments on commit 88b1da8

Please sign in to comment.