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 {
}
}
// 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.
abstract class ResidentRunner {
ResidentRunner(
......
......@@ -134,13 +134,6 @@ class ColdRunner extends ResidentRunner {
);
} on Exception catch (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;
}
for (final FlutterDevice device in flutterDevices) {
......
......@@ -233,20 +233,6 @@ class HotRunner extends ResidentRunner {
rethrow;
}
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;
}
......
......@@ -6,9 +6,6 @@ import 'dart:async';
import 'package:flutter_tools/src/base/file_system.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/compile.dart';
import 'package:flutter_tools/src/device.dart';
......@@ -23,75 +20,28 @@ import '../src/context.dart';
import '../src/mocks.dart';
void main() {
group('cold attach', () {
MockResidentCompiler residentCompiler;
BufferLogger mockLogger;
setUp(() {
mockLogger = BufferLogger(
terminal: AnsiTerminal(
stdio: null,
platform: const LocalPlatform(),
),
outputPreferences: OutputPreferences.test(),
);
residentCompiler = MockResidentCompiler();
});
testUsingContext('Prints message when HttpException is thrown - 1', () 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('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,
});
testUsingContext('Exits with code 2 when when HttpException is thrown '
'during VM service connection', () async {
final MockResidentCompiler residentCompiler = MockResidentCompiler();
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('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);
});
group('cleanupAtFinish()', () {
......
......@@ -415,15 +415,15 @@ void main() {
});
group('hot attach', () {
MockResidentCompiler residentCompiler = MockResidentCompiler();
MockLocalEngineArtifacts mockArtifacts;
setUp(() {
residentCompiler = MockResidentCompiler();
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();
when(mockDevice.supportsHotReload).thenReturn(true);
when(mockDevice.supportsHotRestart).thenReturn(false);
......@@ -443,38 +443,6 @@ void main() {
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>{
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>{
Artifacts: () => mockArtifacts,
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