Skip to content

[SwiftPM] Re-enable tests for when settings fail to compile #196307

Closed

Description

@loic-sharma

The tree is closed due to test failures: https://ci.chromium.org/ui/p/flutter/builders/prod/Linux%20tool_tests_general/31207/overview

00:30 +3002 ~2 -1: test/general.shard/migrations/swift_package_manager_integration_migration_test.dart: Flutter Package Migration validate project settings throw if settings fail to compile [E]  TimeoutException after 0:00:02.000000: Test timed out after 2 seconds.  dart:isolate  _RawReceivePort._handleMessage
....
00:32 +3123 ~2 -2: test/general.shard/migrations/swift_package_manager_integration_migration_test.dart: Flutter Package Migration validate project settings throw if settings fail to compile due to package dependencies [E]
  TimeoutException after 0:00:02.000000: Test timed out after 2 seconds.
  dart:isolate  _RawReceivePort._handleMessage

The test passes locally on my machine. No recent commits seem relevant to this test failure. I will disable these two tests temporarily to unblock the tree.

Activity

  1. loic-sharma commented on Nov 10, 2026

    @loic-sharma
    MemberAuthor

    @vashworth Antigravity suspects the crash reporter is blocked attempting to do a network request. Here's a vibecoded fix:

    diff --git a/packages/flutter_tools/lib/src/migrations/swift_package_manager_integration_migration.dart b/packages/flutter_tools/lib/src/migrations/swift_package_manager_integration_migration.dart
    index 3ea349e38dd..c92c18ab9f1 100644
    --- a/packages/flutter_tools/lib/src/migrations/swift_package_manager_integration_migration.dart
    +++ b/packages/flutter_tools/lib/src/migrations/swift_package_manager_integration_migration.dart
    @@ -2,6 +2,7 @@
     // Use of this source code is governed by a BSD-style license that can be
     // found in the LICENSE file.
     
    +import 'package:http/http.dart' as http;
     import 'package:meta/meta.dart';
     import 'package:unified_analytics/unified_analytics.dart';
     import 'package:xml/xml.dart';
    @@ -38,11 +39,17 @@ class SwiftPackageManagerIntegrationMigration extends ProjectMigrator {
         required this._reportCrashes,
         required this._toolContext,
         required this._xcodeProjectInterpreter,
    +    this._httpClient,
       }) : _xcodeProject = project,
            _xcodeProjectInfoFile = project.xcodeProjectInfoFile,
            super(_toolContext.logger);
     
       final XcodeBasedProject _xcodeProject;
    +
    +  /// The HTTP client used to send crash reports.
    +  ///
    +  /// If null, a default [http.Client] is used.
    +  final http.Client? _httpClient;
       final FlutterDarwinPlatform _platform;
       final BuildInfo _buildInfo;
       final Analytics _analytics;
    @@ -251,6 +258,7 @@ class SwiftPackageManagerIntegrationMigration extends ProjectMigrator {
               try {
                 await asyncGuard(() async {
                   final crashReportSender = CrashReportSender(
    +                client: _httpClient,
                     platform: hostPlatform,
                     logger: logger,
                     operatingSystemUtils: os,
    diff --git a/packages/flutter_tools/test/general.shard/migrations/swift_package_manager_integration_migration_test.dart b/packages/flutter_tools/test/general.shard/migrations/swift_package_manager_integration_migration_test.dart
    index f56ae8cc450..648f6e2aeec 100644
    --- a/packages/flutter_tools/test/general.shard/migrations/swift_package_manager_integration_migration_test.dart
    +++ b/packages/flutter_tools/test/general.shard/migrations/swift_package_manager_integration_migration_test.dart
    @@ -15,6 +15,8 @@ import 'package:flutter_tools/src/ios/xcodeproj.dart';
     import 'package:flutter_tools/src/migrations/swift_package_manager_integration_migration.dart';
     import 'package:flutter_tools/src/plugins.dart';
     import 'package:flutter_tools/src/project.dart';
    +import 'package:http/http.dart' as http;
    +import 'package:http/testing.dart';
     import 'package:test/fake.dart';
     import 'package:unified_analytics/unified_analytics.dart';
     
    @@ -4639,6 +4641,7 @@ void main() {
           testWithoutContext('throw if settings fail to compile', () async {
             final memoryFileSystem = MemoryFileSystem();
             final testLogger = BufferLogger.test();
    +        final crashReports = <http.BaseRequest>[];
             final FakeAnalytics fakeAnalytics = getInitializedFakeAnalyticsInstance(
               fs: memoryFileSystem,
               fakeFlutterVersion: FakeFlutterVersion(),
    @@ -4675,6 +4678,7 @@ void main() {
                 platform: FakePlatform(),
               ),
               xcodeProjectInterpreter: FakeXcodeProjectInterpreter(throwErrorOnGetInfo: true),
    +          httpClient: _fakeCrashServer(crashReports),
             );
             await expectLater(
               () => projectMigration.migrate(),
    @@ -4691,11 +4695,13 @@ void main() {
               ),
             );
             expect(testLogger.traceText, contains('Sending crash report to Google.'));
    +        expect(crashReports, hasLength(1));
           });
     
           testWithoutContext('throw if settings fail to compile due to package dependencies', () async {
             final memoryFileSystem = MemoryFileSystem();
             final testLogger = BufferLogger.test();
    +        final crashReports = <http.BaseRequest>[];
             final FakeAnalytics fakeAnalytics = getInitializedFakeAnalyticsInstance(
               fs: memoryFileSystem,
               fakeFlutterVersion: FakeFlutterVersion(),
    @@ -4734,6 +4740,7 @@ void main() {
               xcodeProjectInterpreter: FakeXcodeProjectInterpreter(
                 errorMessageOnGetInfo: 'Could not resolve package dependencies: network error',
               ),
    +          httpClient: _fakeCrashServer(crashReports),
             );
             await expectLater(
               () => projectMigration.migrate(),
    @@ -4750,11 +4757,13 @@ void main() {
               ),
             );
             expect(testLogger.traceText, contains('Sending crash report to Google.'));
    +        expect(crashReports, hasLength(1));
           });
     
           testWithoutContext('does not send crash report if reportCrashes is false', () async {
             final memoryFileSystem = MemoryFileSystem();
             final testLogger = BufferLogger.test();
    +        final crashReports = <http.BaseRequest>[];
             final FakeAnalytics fakeAnalytics = getInitializedFakeAnalyticsInstance(
               fs: memoryFileSystem,
               fakeFlutterVersion: FakeFlutterVersion(),
    @@ -4791,6 +4800,7 @@ void main() {
                 platform: FakePlatform(),
               ),
               xcodeProjectInterpreter: FakeXcodeProjectInterpreter(throwErrorOnGetInfo: true),
    +          httpClient: _fakeCrashServer(crashReports),
             );
             await expectLater(
               () => projectMigration.migrate(),
    @@ -4807,6 +4817,7 @@ void main() {
               ),
             );
             expect(testLogger.traceText, isNot(contains('Sending crash report to Google.')));
    +        expect(crashReports, isEmpty);
           });
     
           testWithoutContext('restore project settings from backup on failure', () async {
    @@ -6102,3 +6113,13 @@ class FakeConfig extends Fake implements Config {
       @override
       Object? getValue(String key) => null;
     }
    +
    +/// Creates a fake crash server client that records each request in [requests].
    +///
    +/// This prevents tests from sending real crash reports over the network.
    +http.Client _fakeCrashServer(List<http.BaseRequest> requests) {
    +  return MockClient((http.Request request) async {
    +    requests.add(request);
    +    return http.Response('test-report-id', 200);
    +  });
    +}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

c: disabled testTracks the restoration of a disabled testteam-iosOwned by iOS platform team

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions