mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
close sinks cleanup (#5838)
part of https://github.com/flutter/flutter/issues/5789
This commit is contained in:
parent
3e2a52bc21
commit
672d04e0d0
@ -636,7 +636,11 @@ class AnalysisServer {
|
|||||||
_errorsController.add(new FileAnalysisErrors(file, errors));
|
_errorsController.add(new FileAnalysisErrors(file, errors));
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> dispose() async => _process?.kill();
|
Future<bool> dispose() async {
|
||||||
|
await _analyzingController.close();
|
||||||
|
await _errorsController.close();
|
||||||
|
return _process?.kill();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class FileAnalysisErrors {
|
class FileAnalysisErrors {
|
||||||
|
@ -100,7 +100,10 @@ class Daemon {
|
|||||||
// Start listening.
|
// Start listening.
|
||||||
commandStream.listen(
|
commandStream.listen(
|
||||||
(Map<String, dynamic> request) => _handleRequest(request),
|
(Map<String, dynamic> request) => _handleRequest(request),
|
||||||
onDone: () => _onExitCompleter.complete(0)
|
onDone: () {
|
||||||
|
if (!_onExitCompleter.isCompleted)
|
||||||
|
_onExitCompleter.complete(0);
|
||||||
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -579,6 +582,10 @@ class NotifyingLogger extends Logger {
|
|||||||
printStatus(message);
|
printStatus(message);
|
||||||
return new Status();
|
return new Status();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void dispose() {
|
||||||
|
_messageController.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A running application, started by this daemon.
|
/// A running application, started by this daemon.
|
||||||
|
@ -42,6 +42,7 @@ void main() {
|
|||||||
tearDown(() {
|
tearDown(() {
|
||||||
if (daemon != null)
|
if (daemon != null)
|
||||||
return daemon.shutdown();
|
return daemon.shutdown();
|
||||||
|
notifyingLogger.dispose();
|
||||||
});
|
});
|
||||||
|
|
||||||
_testUsingContext('daemon.version', () async {
|
_testUsingContext('daemon.version', () async {
|
||||||
@ -57,6 +58,8 @@ void main() {
|
|||||||
expect(response['id'], 0);
|
expect(response['id'], 0);
|
||||||
expect(response['result'], isNotEmpty);
|
expect(response['result'], isNotEmpty);
|
||||||
expect(response['result'] is String, true);
|
expect(response['result'] is String, true);
|
||||||
|
responses.close();
|
||||||
|
commands.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
_testUsingContext('daemon.logMessage', () {
|
_testUsingContext('daemon.logMessage', () {
|
||||||
@ -77,6 +80,8 @@ void main() {
|
|||||||
Map<String, String> logMessage = response['params'];
|
Map<String, String> logMessage = response['params'];
|
||||||
expect(logMessage['level'], 'error');
|
expect(logMessage['level'], 'error');
|
||||||
expect(logMessage['message'], 'daemon.logMessage test');
|
expect(logMessage['message'], 'daemon.logMessage test');
|
||||||
|
responses.close();
|
||||||
|
commands.close();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -90,6 +95,8 @@ void main() {
|
|||||||
);
|
);
|
||||||
commands.add(<String, dynamic>{'id': 0, 'method': 'daemon.shutdown'});
|
commands.add(<String, dynamic>{'id': 0, 'method': 'daemon.shutdown'});
|
||||||
return daemon.onExit.then((int code) {
|
return daemon.onExit.then((int code) {
|
||||||
|
responses.close();
|
||||||
|
commands.close();
|
||||||
expect(code, 0);
|
expect(code, 0);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -111,6 +118,8 @@ void main() {
|
|||||||
Map<String, dynamic> response = await responses.stream.where(_notEvent).first;
|
Map<String, dynamic> response = await responses.stream.where(_notEvent).first;
|
||||||
expect(response['id'], 0);
|
expect(response['id'], 0);
|
||||||
expect(response['error'], contains('deviceId is required'));
|
expect(response['error'], contains('deviceId is required'));
|
||||||
|
responses.close();
|
||||||
|
commands.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
_testUsingContext('daemon.restart', () async {
|
_testUsingContext('daemon.restart', () async {
|
||||||
@ -130,6 +139,8 @@ void main() {
|
|||||||
Map<String, dynamic> response = await responses.stream.where(_notEvent).first;
|
Map<String, dynamic> response = await responses.stream.where(_notEvent).first;
|
||||||
expect(response['id'], 0);
|
expect(response['id'], 0);
|
||||||
expect(response['error'], contains('appId is required'));
|
expect(response['error'], contains('appId is required'));
|
||||||
|
responses.close();
|
||||||
|
commands.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
_testUsingContext('daemon.stop', () async {
|
_testUsingContext('daemon.stop', () async {
|
||||||
@ -149,6 +160,8 @@ void main() {
|
|||||||
Map<String, dynamic> response = await responses.stream.where(_notEvent).first;
|
Map<String, dynamic> response = await responses.stream.where(_notEvent).first;
|
||||||
expect(response['id'], 0);
|
expect(response['id'], 0);
|
||||||
expect(response['error'], contains('appId is required'));
|
expect(response['error'], contains('appId is required'));
|
||||||
|
responses.close();
|
||||||
|
commands.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
_testUsingContext('device.getDevices', () async {
|
_testUsingContext('device.getDevices', () async {
|
||||||
@ -163,6 +176,8 @@ void main() {
|
|||||||
Map<String, dynamic> response = await responses.stream.where(_notEvent).first;
|
Map<String, dynamic> response = await responses.stream.where(_notEvent).first;
|
||||||
expect(response['id'], 0);
|
expect(response['id'], 0);
|
||||||
expect(response['result'], isList);
|
expect(response['result'], isList);
|
||||||
|
responses.close();
|
||||||
|
commands.close();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,7 @@ void main() {
|
|||||||
expect(await nextPort, 52584);
|
expect(await nextPort, 52584);
|
||||||
|
|
||||||
discoverer.cancel();
|
discoverer.cancel();
|
||||||
|
logReader.dispose();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -62,6 +62,10 @@ class MockDeviceLogReader extends DeviceLogReader {
|
|||||||
Stream<String> get logLines => _linesController.stream;
|
Stream<String> get logLines => _linesController.stream;
|
||||||
|
|
||||||
void addLine(String line) => _linesController.add(line);
|
void addLine(String line) => _linesController.add(line);
|
||||||
|
|
||||||
|
void dispose() {
|
||||||
|
_linesController.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void applyMocksToCommand(FlutterCommand command) {
|
void applyMocksToCommand(FlutterCommand command) {
|
||||||
|
Loading…
Reference in New Issue
Block a user