[flutter_tools] don't trim log messages from the web (#53379)

This commit is contained in:
Jonah Williams 2020-03-26 18:08:05 -07:00 committed by GitHub
parent 2717eb6413
commit be3a4b37b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 1 deletions

View File

@ -672,7 +672,7 @@ class _ResidentWebRunner extends ResidentWebRunner {
// thrown if we're not already subscribed.
}
_stdOutSub = _vmService.onStdoutEvent.listen((vmservice.Event log) {
final String message = utf8.decode(base64.decode(log.bytes)).trim();
final String message = utf8.decode(base64.decode(log.bytes));
globals.printStatus(message);
});
unawaited(_vmService.registerService('reloadSources', 'FlutterTools'));

View File

@ -480,6 +480,30 @@ void main() {
Usage: () => MockFlutterUsage(),
}));
test('Faithfully displays stdout messages with leading/trailing spaces', () => testbed.run(() async {
_setupMocks();
final StreamController<Event> stdoutController = StreamController<Event>();
when(mockVmService.onStdoutEvent).thenAnswer((Invocation invocation) {
return stdoutController.stream;
});
final Completer<DebugConnectionInfo> connectionInfoCompleter = Completer<DebugConnectionInfo>();
unawaited(residentWebRunner.run(
connectionInfoCompleter: connectionInfoCompleter,
));
await connectionInfoCompleter.future;
stdoutController.add(Event(
timestamp: 0,
kind: 'Stdout',
bytes: base64.encode(utf8.encode(' This is a message with 4 leading and trailing spaces '))),
);
// Wait one event loop for the stream listener to fire.
await null;
expect(testLogger.statusText,
contains(' This is a message with 4 leading and trailing spaces '));
}));
test('Fails on compilation errors in hot restart', () => testbed.run(() async {
_setupMocks();
final Completer<DebugConnectionInfo> connectionInfoCompleter = Completer<DebugConnectionInfo>();