Unverified Commit 0734db62 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[flutter_tools] remove handling of error that is fixed (#58557)

The linked error has been fixed, removed work around. Updates the test cases to only test for exit instead of error message

#33050
parent 7e942b62
...@@ -648,23 +648,6 @@ class FlutterDevice { ...@@ -648,23 +648,6 @@ class FlutterDevice {
} }
} }
// Issue: https://github.com/flutter/flutter/issues/33050
// Matches the following patterns:
// HttpException: Connection closed before full header was received, uri = *
// HttpException: , uri = *
final RegExp kAndroidQHttpConnectionClosedExp = RegExp(r'^HttpException\:.+\, uri \=.+$');
/// Returns `true` if any of the devices is running Android Q.
Future<bool> hasDeviceRunningAndroidQ(List<FlutterDevice> flutterDevices) async {
for (final FlutterDevice flutterDevice in flutterDevices) {
final String sdkNameAndVersion = await flutterDevice.device.sdkNameAndVersion;
if (sdkNameAndVersion != null && sdkNameAndVersion.startsWith('Android 10')) {
return true;
}
}
return false;
}
// Shared code between different resident application runners. // Shared code between different resident application runners.
abstract class ResidentRunner { abstract class ResidentRunner {
ResidentRunner( ResidentRunner(
......
...@@ -134,13 +134,6 @@ class ColdRunner extends ResidentRunner { ...@@ -134,13 +134,6 @@ class ColdRunner extends ResidentRunner {
); );
} on Exception catch (error) { } on Exception catch (error) {
globals.printError('Error connecting to the service protocol: $error'); globals.printError('Error connecting to the service protocol: $error');
// https://github.com/flutter/flutter/issues/33050
// TODO(blasten): Remove this check once https://issuetracker.google.com/issues/132325318 has been fixed.
if (await hasDeviceRunningAndroidQ(flutterDevices) &&
error.toString().contains(kAndroidQHttpConnectionClosedExp)) {
globals.printStatus('🔨 If you are using an emulator running Android Q Beta, consider using an emulator running API level 29 or lower.');
globals.printStatus('Learn more about the status of this issue on https://issuetracker.google.com/issues/132325318');
}
return 2; return 2;
} }
for (final FlutterDevice device in flutterDevices) { for (final FlutterDevice device in flutterDevices) {
......
...@@ -233,20 +233,6 @@ class HotRunner extends ResidentRunner { ...@@ -233,20 +233,6 @@ class HotRunner extends ResidentRunner {
rethrow; rethrow;
} }
globals.printError('Error connecting to the service protocol: $error'); globals.printError('Error connecting to the service protocol: $error');
// https://github.com/flutter/flutter/issues/33050
// TODO(blasten): Remove this check once
// https://issuetracker.google.com/issues/132325318 has been fixed.
if (await hasDeviceRunningAndroidQ(flutterDevices) &&
error.toString().contains(kAndroidQHttpConnectionClosedExp)) {
globals.printStatus(
'🔨 If you are using an emulator running Android Q Beta, '
'consider using an emulator running API level 29 or lower.',
);
globals.printStatus(
'Learn more about the status of this issue on '
'https://issuetracker.google.com/issues/132325318.',
);
}
return 2; return 2;
} }
......
...@@ -6,9 +6,6 @@ import 'dart:async'; ...@@ -6,9 +6,6 @@ import 'dart:async';
import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/io.dart'; import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/base/terminal.dart';
import 'package:flutter_tools/src/build_info.dart'; import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/compile.dart'; import 'package:flutter_tools/src/compile.dart';
import 'package:flutter_tools/src/device.dart'; import 'package:flutter_tools/src/device.dart';
...@@ -23,75 +20,28 @@ import '../src/context.dart'; ...@@ -23,75 +20,28 @@ import '../src/context.dart';
import '../src/mocks.dart'; import '../src/mocks.dart';
void main() { void main() {
group('cold attach', () { testUsingContext('Exits with code 2 when when HttpException is thrown '
MockResidentCompiler residentCompiler; 'during VM service connection', () async {
BufferLogger mockLogger; final MockResidentCompiler residentCompiler = MockResidentCompiler();
final MockDevice mockDevice = MockDevice();
setUp(() { when(mockDevice.supportsHotReload).thenReturn(true);
mockLogger = BufferLogger( when(mockDevice.supportsHotRestart).thenReturn(false);
terminal: AnsiTerminal( when(mockDevice.targetPlatform).thenAnswer((Invocation _) async => TargetPlatform.tester);
stdio: null, when(mockDevice.sdkNameAndVersion).thenAnswer((Invocation _) async => 'Android 10');
platform: const LocalPlatform(),
), final List<FlutterDevice> devices = <FlutterDevice>[
outputPreferences: OutputPreferences.test(), TestFlutterDevice(
); device: mockDevice,
residentCompiler = MockResidentCompiler(); generator: residentCompiler,
}); exception: const HttpException('Connection closed before full header was received, '
'uri = http://127.0.0.1:63394/5ZmLv8A59xY=/ws'),
testUsingContext('Prints message when HttpException is thrown - 1', () async { ),
final MockDevice mockDevice = MockDevice(); ];
when(mockDevice.supportsHotReload).thenReturn(true);
when(mockDevice.supportsHotRestart).thenReturn(false); final int exitCode = await ColdRunner(devices,
when(mockDevice.targetPlatform).thenAnswer((Invocation _) async => TargetPlatform.tester); debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug),
when(mockDevice.sdkNameAndVersion).thenAnswer((Invocation _) async => 'Android 10'); ).attach();
expect(exitCode, 2);
final List<FlutterDevice> devices = <FlutterDevice>[
TestFlutterDevice(
device: mockDevice,
generator: residentCompiler,
exception: const HttpException('Connection closed before full header was received, '
'uri = http://127.0.0.1:63394/5ZmLv8A59xY=/ws'),
),
];
final int exitCode = await ColdRunner(devices,
debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug),
).attach();
expect(exitCode, 2);
expect(mockLogger.statusText, contains('If you are using an emulator running Android Q Beta, '
'consider using an emulator running API level 29 or lower.'));
expect(mockLogger.statusText, contains('Learn more about the status of this issue on '
'https://issuetracker.google.com/issues/132325318'));
}, overrides: <Type, Generator>{
Logger: () => mockLogger,
});
testUsingContext('Prints message when HttpException is thrown - 2', () async {
final MockDevice mockDevice = MockDevice();
when(mockDevice.supportsHotReload).thenReturn(true);
when(mockDevice.supportsHotRestart).thenReturn(false);
when(mockDevice.targetPlatform).thenAnswer((Invocation _) async => TargetPlatform.tester);
when(mockDevice.sdkNameAndVersion).thenAnswer((Invocation _) async => 'Android 10');
final List<FlutterDevice> devices = <FlutterDevice>[
TestFlutterDevice(
device: mockDevice,
generator: residentCompiler,
exception: const HttpException(', uri = http://127.0.0.1:63394/5ZmLv8A59xY=/ws'),
),
];
final int exitCode = await ColdRunner(devices,
debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug),
).attach();
expect(exitCode, 2);
expect(mockLogger.statusText, contains('If you are using an emulator running Android Q Beta, '
'consider using an emulator running API level 29 or lower.'));
expect(mockLogger.statusText, contains('Learn more about the status of this issue on '
'https://issuetracker.google.com/issues/132325318'));
}, overrides: <Type, Generator>{
Logger: () => mockLogger,
});
}); });
group('cleanupAtFinish()', () { group('cleanupAtFinish()', () {
......
...@@ -415,15 +415,15 @@ void main() { ...@@ -415,15 +415,15 @@ void main() {
}); });
group('hot attach', () { group('hot attach', () {
MockResidentCompiler residentCompiler = MockResidentCompiler();
MockLocalEngineArtifacts mockArtifacts; MockLocalEngineArtifacts mockArtifacts;
setUp(() { setUp(() {
residentCompiler = MockResidentCompiler();
mockArtifacts = MockLocalEngineArtifacts(); mockArtifacts = MockLocalEngineArtifacts();
}); });
testUsingContext('Prints message when HttpException is thrown - 1', () async { testUsingContext('Exits with code 2 when when HttpException is thrown '
'during VM service connection', () async {
final MockResidentCompiler residentCompiler = MockResidentCompiler();
final MockDevice mockDevice = MockDevice(); final MockDevice mockDevice = MockDevice();
when(mockDevice.supportsHotReload).thenReturn(true); when(mockDevice.supportsHotReload).thenReturn(true);
when(mockDevice.supportsHotRestart).thenReturn(false); when(mockDevice.supportsHotRestart).thenReturn(false);
...@@ -443,38 +443,6 @@ void main() { ...@@ -443,38 +443,6 @@ void main() {
debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug), debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug),
).attach(); ).attach();
expect(exitCode, 2); expect(exitCode, 2);
expect(testLogger.statusText, contains('If you are using an emulator running Android Q Beta, '
'consider using an emulator running API level 29 or lower.'));
expect(testLogger.statusText, contains('Learn more about the status of this issue on '
'https://issuetracker.google.com/issues/132325318'));
}, overrides: <Type, Generator>{
Artifacts: () => mockArtifacts,
HotRunnerConfig: () => TestHotRunnerConfig(successfulSetup: true),
});
testUsingContext('Prints message when HttpException is thrown - 2', () async {
final MockDevice mockDevice = MockDevice();
when(mockDevice.supportsHotReload).thenReturn(true);
when(mockDevice.supportsHotRestart).thenReturn(false);
when(mockDevice.targetPlatform).thenAnswer((Invocation _) async => TargetPlatform.tester);
when(mockDevice.sdkNameAndVersion).thenAnswer((Invocation _) async => 'Android 10');
final List<FlutterDevice> devices = <FlutterDevice>[
TestFlutterDevice(
device: mockDevice,
generator: residentCompiler,
exception: const HttpException(', uri = http://127.0.0.1:63394/5ZmLv8A59xY=/ws'),
),
];
final int exitCode = await HotRunner(devices,
debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug),
).attach();
expect(exitCode, 2);
expect(testLogger.statusText, contains('If you are using an emulator running Android Q Beta, '
'consider using an emulator running API level 29 or lower.'));
expect(testLogger.statusText, contains('Learn more about the status of this issue on '
'https://issuetracker.google.com/issues/132325318'));
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
Artifacts: () => mockArtifacts, Artifacts: () => mockArtifacts,
HotRunnerConfig: () => TestHotRunnerConfig(successfulSetup: true), HotRunnerConfig: () => TestHotRunnerConfig(successfulSetup: true),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment