From 10b7bac6ded10706d182b8daa75055f932add9bc Mon Sep 17 00:00:00 2001 From: Liam Appelbe Date: Mon, 6 May 2024 13:18:17 -0700 Subject: [PATCH] Copy collect_coverage's `--scope-output` flag to test_with_coverage. (dart-lang/coverage#488) --- pkgs/coverage/CHANGELOG.md | 4 ++++ pkgs/coverage/bin/test_with_coverage.dart | 13 +++++++++++-- pkgs/coverage/pubspec.yaml | 2 +- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/pkgs/coverage/CHANGELOG.md b/pkgs/coverage/CHANGELOG.md index ae6cda227..4a2a711ec 100644 --- a/pkgs/coverage/CHANGELOG.md +++ b/pkgs/coverage/CHANGELOG.md @@ -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'. diff --git a/pkgs/coverage/bin/test_with_coverage.dart b/pkgs/coverage/bin/test_with_coverage.dart index d234527f4..010e6089a 100644 --- a/pkgs/coverage/bin/test_with_coverage.dart +++ b/pkgs/coverage/bin/test_with_coverage.dart @@ -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 { @@ -90,7 +94,8 @@ class Flags { this.port, this.testScript, this.functionCoverage, - this.branchCoverage, { + this.branchCoverage, + this.scopeOutput, { required this.rest, }); @@ -101,6 +106,7 @@ class Flags { final String testScript; final bool functionCoverage; final bool branchCoverage; + final List scopeOutput; final List rest; } @@ -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, rest: args.rest, ); } @@ -195,11 +202,13 @@ Future main(List 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', diff --git a/pkgs/coverage/pubspec.yaml b/pkgs/coverage/pubspec.yaml index 2a0553b46..6a443ac0b 100644 --- a/pkgs/coverage/pubspec.yaml +++ b/pkgs/coverage/pubspec.yaml @@ -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