Unverified Commit 0f8a6ab4 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[flutter_tools] make failures to unforward android port non-fatal (#82477)

parent 8334fb0a
......@@ -1313,13 +1313,10 @@ class AndroidDevicePortForwarder extends DevicePortForwarder {
],
throwOnError: false,
);
// The port may have already been unforwarded, for example if there
// are multiple attach process already connected.
if (runResult.exitCode == 0 || runResult
.stderr.contains("listener '$tcpLine' not found")) {
if (runResult.exitCode == 0) {
return;
}
runResult.throwException('Process exited abnormally:\n$runResult');
_logger.printError('Failed to unforward port: $runResult');
}
@override
......
......@@ -143,7 +143,7 @@ void main() {
await forwarder.unforward(ForwardedPort(456, 23));
});
testWithoutContext('failures to unforward port throw exception if stderr is not recognized', () async {
testWithoutContext('failures to unforward port print error but are non-fatral', () async {
final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
const FakeCommand(
command: <String>['adb', '-s', '1', 'forward', '--remove', 'tcp:456'],
......@@ -151,13 +151,16 @@ void main() {
exitCode: 1,
)
]);
final BufferLogger logger = BufferLogger.test();
final AndroidDevicePortForwarder forwarder = AndroidDevicePortForwarder(
adbPath: 'adb',
deviceId: '1',
processManager: processManager,
logger: BufferLogger.test(),
logger: logger,
);
expect(() => forwarder.unforward(ForwardedPort(456, 23)), throwsProcessException());
await forwarder.unforward(ForwardedPort(456, 23));
expect(logger.errorText, contains('Failed to unforward port: error: everything is broken!'));
});
}
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