compareFixtureResolution function

List<ResolutionMismatch> compareFixtureResolution({
  1. required String hostProjectPath,
  2. required String fixtureProjectPath,
})

Packages fixtureProjectPath resolves differently from hostProjectPath, in lock order.

Only the host's RUNTIME dependencies are compared — the ones whose API its lib/ is compiled against, which the lock labels direct main or transitive. A direct dev package cannot produce this failure, and comparing everything reports benign differences instead: measured across the three d4rt packages with examples, every such difference was lints.

Returns empty when either side has no lock file: a project that has never resolved is a different problem, with its own check.

Implementation

List<ResolutionMismatch> compareFixtureResolution({
  required String hostProjectPath,
  required String fixtureProjectPath,
}) {
  final host = _hostedVersions(hostProjectPath, runtimeOnly: true);
  if (host.isEmpty) return const [];
  final fixture = _hostedVersions(fixtureProjectPath, runtimeOnly: false);
  if (fixture.isEmpty) return const [];

  final mismatches = <ResolutionMismatch>[];
  for (final entry in host.entries) {
    final fixtureVersion = fixture[entry.key];
    // A fixture need not use everything the host does.
    if (fixtureVersion == null || fixtureVersion == entry.value) continue;
    mismatches.add(ResolutionMismatch(
      fixturePath: fixtureProjectPath,
      package: entry.key,
      hostVersion: entry.value,
      fixtureVersion: fixtureVersion,
    ));
  }
  return mismatches;
}