[flutter_tools] refactor the IOSDevicePortForwarder and move tests out of devices_test.dart#52772
Conversation
|
|
||
| @override | ||
| DevicePortForwarder get portForwarder => _portForwarder ??= IOSDevicePortForwarder(this); | ||
| DevicePortForwarder get portForwarder => _portForwarder ??= IOSDevicePortForwarder( |
There was a problem hiding this comment.
This is not referenced in google3
|
|
||
| @override | ||
| List<ForwardedPort> get forwardedPorts => _forwardedPorts; | ||
| List<ForwardedPort> forwardedPorts = <ForwardedPort>[]; |
There was a problem hiding this comment.
This is semantically equivalent, just shorter
There was a problem hiding this comment.
This is a valid override for List<ForwardedPort> get forwardedPorts? TIL.
There was a problem hiding this comment.
Dart doesn't actually have fields, so:
int get a => _a;
set a(int value) => _a = value;
is equivalent to
int a;
And
int get a => _a;
Is equivalent to a final field like above.
There was a problem hiding this comment.
(edited, code typo)
| final List<ForwardedPort> _forwardedPorts; | ||
| final ProcessUtils _processUtils; | ||
| final Logger _logger; | ||
| final MapEntry<String, String> _dyLdLibEntry; |
There was a problem hiding this comment.
non-trivial change: I inject the dyLdLibEntry and iproxy paths.
| }), | ||
| stderr = Stream<List<int>>.value(utf8.encode(_stderr)), | ||
| stdout = Stream<List<int>>.value(utf8.encode(_stdout)); | ||
| stderr = _stderr == null |
There was a problem hiding this comment.
We needed a way to differentiate the stream being empty versus containing an empty string.
There was a problem hiding this comment.
what does utf8.encode('') return?
There was a problem hiding this comment.
EmptyList, but the Stream constructor leads to a non-empty stream with a single empty list emitted on it.
| // By default, the .forward() method will try every port between 1024 | ||
| // and 65535; this test verifies we are killing iproxy processes when | ||
| // we timeout on a port | ||
| testWithoutContext('IOSDevicePortForwarder.forward will kill iproxy processes before invoking a second', () async { |
There was a problem hiding this comment.
We only have a single IOSDevicePortForwarder test :(
|
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of |
Description
(Note: I tried the lib only changes, but those need test changes too .. so it got pretty big. Trying vertical cuts instead of horizontal).
Updates the IOSDevicePortForwarder to no longer depend on context, or on an IOSDevice instance. Instead, it receives all necessary configuration through the constructor.
Moves the IOSDevicePortForwarder to a separate file.