Skip to content

--scope-output does not work #530

Closed
dart-archive/coverage
#498
@gogolon

Description

@gogolon

Sometimes coverage is gathered from external packages even when --scope-output flag is used and set to the name of the app's package.

Reproduction

  1. Create a new dart project with dart create minimal-sample
  2. Add equatable package: dart pub add equatable
  3. Replace the code inside lib/minimal_sample.dart with the code below:
import 'package:equatable/equatable.dart';

class SomeClass with EquatableMixin {
  @override
  List<Object?> get props => [];
}

int calculate() {
  return 6 * 7;
}
  1. run
dart run --pause-isolates-on-exit --disable-service-auth-codes --enable-vm-service=8181 test &
dart pub global run coverage:collect_coverage --wait-paused --uri=http://127.0.0.1:8181/ -o coverage/coverage.json --resume-isolates --scope-output=minimal_sample

After performing the steps above, the generated coverage/coverage.json looks like this:

{
  "type": "CodeCoverage",
  "coverage": [
    {
      "source": "package:minimal_sample/minimal_sample.dart",
      "script": {
        "type": "@Script",
        "fixedId": true,
        "id": "libraries/1/scripts/package%3Aminimal_sample%2Fminimal_sample.dart",
        "uri": "package:minimal_sample/minimal_sample.dart",
        "_kind": "library"
      },
      "hits": [
        4,
        0,
        5,
        0,
        8,
        1,
        9,
        1
      ]
    },
    {
      "source": "package:equatable/src/equatable_mixin.dart",
      "script": {
        "type": "@Script",
        "fixedId": true,
        "id": "libraries/1/scripts/package%3Aequatable%2Fsrc%2Fequatable_mixin.dart",
        "uri": "package:equatable/src/equatable_mixin.dart",
        "_kind": "library"
      },
      "hits": [
        16,
        0,
        18,
        0,
        21,
        0,
        22,
        0,
        23,
        0,
        26,
        0,
        27,
        0,
        29,
        0,
        31,
        0,
        32,
        0,
        33,
        0,
        34,
        0,
        35,
        0,
        37,
        0,
        38,
        0,
        39,
        0
      ]
    }
  ]
}

I use Dart SDK 3.3.3.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions