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

Copy collect_coverage's --scope-output flag to test_with_coverage. #488

Merged
merged 2 commits into from
May 6, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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