Skip to content

[tool_crash] flutter test --coverage crashes finalizing coverage on 3.41.7 #185654

Description

@gonzalogauto

Steps to Reproduce

A glob entry in the workspace: block of a host app's pubspec.yaml (e.g. - packages/*) is enough — no native-asset / firebase / objective_c / sentry / etc. dependencies needed.

mkdir repro && cd repro
flutter create .
flutter create --template=package packages/some_pkg

Edit repro/pubspec.yaml and add:

workspace:
  - packages/*

Edit repro/packages/some_pkg/pubspec.yaml and add under environment::

resolution: workspace

Then run:

flutter test --coverage

Expected results

flutter test --coverage exits 0 and writes coverage/lcov.info.

Actual results

The test process exits successfully, then flutter crashes with a RangeError and coverage/lcov.info is never written. Exit code is non-zero, so CI fails even though every test passed.

00:00 +1: All tests passed!
Oops; flutter has exited unexpectedly: "RangeError (length): Invalid value: Valid value range is empty: 0".

#0      _Array.[] (dart:core-patch/array.dart)
#1      Resolver.resolve (package:coverage/src/resolver.dart:85:43)
#2      CoverageCollector.finalizeCoverage.<anonymous closure> (package:flutter_tools/src/test/coverage_collector.dart:216:44)
#3      MappedIterator.moveNext (dart:_internal/iterable.dart:420:20)
#4      WhereTypeIterator.moveNext (dart:_internal/iterable.dart:904:20)
#5      new _GrowableList._ofOther (dart:core-patch/growable_array.dart:207:26)
#6      new _GrowableList.of (dart:core-patch/growable_array.dart:156:26)
#7      new List.of (dart:core-patch/array_patch.dart:39:18)
#8      Iterable.toList (dart:core/iterable.dart:517:7)
#9      CoverageCollector.finalizeCoverage (package:flutter_tools/src/test/coverage_collector.dart:218:12)
#10     CoverageCollector.collectCoverageData (package:flutter_tools/src/test/coverage_collector.dart:235:40)
#11     TestCommand.runCommand (package:flutter_tools/src/commands/test.dart:713:53)

Trigger chain

FlutterProject.workspaceProjects doesn't expand glob entries — it produces a synthetic FlutterProject for the literal path packages/*, which doesn't exist as a real directory and therefore has no pubspec.yaml, so manifest.appName returns the empty string.

  1. _getCoveragePackages in packages/flutter_tools/lib/src/commands/test.dart walks flutterProject.workspaceProjects recursively and calls packagesToInclude.add(project.manifest.appName). The empty-name synthetic project contributes "" to the set.
  2. CoverageCollector.finalizeCoverage (packages/flutter_tools/lib/src/test/coverage_collector.dart:216) builds package:$e for each entry. With e = "", that's the bare URI package:.
  3. Resolver.resolve (package:coverage/src/resolver.dart:85) does uri.pathSegments[0] on that URI, where pathSegments is empty → RangeError.

Confirmed by patching the local SDK to log:

!!! addProject name=<host_app>  dir=/.../repro
!!! addProject name=<>          dir=/.../repro/packages/*
!!! libraryNames = <host_app>, <>

The dir=/.../packages/* is the synthetic project — Flutter is treating the glob as a literal directory.

What sidesteps the crash

  • Replacing the glob with an explicit list of workspace members in workspace: (e.g. - packages/some_pkg instead of - packages/*). flutter test --coverage then runs cleanly.
  • Passing --coverage-package=<host_package_name> (limits coverage collection to the host package, so the empty entry never reaches the resolver — but loses workspace-package coverage).

Logs / flutter doctor -v

flutter doctor -v
[✓] Flutter (Channel stable, 3.41.7, on macOS 26.4.1 25E253 darwin-arm64, locale en-AR)
    • Flutter version 3.41.7 on channel stable
    • Framework revision cc0734ac71 (12 days ago), 2026-04-15 21:21:08 -0700
    • Engine revision 59aa584fdf
    • Dart version 3.11.5
    • DevTools version 2.54.2
    • Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop,
      enable-windows-desktop, enable-android, enable-ios, cli-animations,
      enable-native-assets, omit-legacy-version-file, enable-lldb-debugging,
      enable-uiscene-migration

[✓] Xcode - develop for iOS and macOS (Xcode 26.4.1)
[✓] Chrome - develop for the web
[✓] Connected device (3 available)
[✓] Network resources

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: tests"flutter test", flutter_test, or one of our testsc: crashStack traces logged to the consolehas reproducible stepsThe issue has been confirmed reproducible and is ready to work onteam-toolOwned by Flutter Tool teamtoolAffects the "flutter" command-line tool. See also t: labels.triaged-toolTriaged by Flutter Tool teamworkaround availableThere is a workaround available to overcome the issue

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions