From c82fc132a8f811a9222479b46e00d36b90243315 Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Tue, 30 Apr 2019 19:18:15 -0700 Subject: [PATCH] add stderr to log processor for desktop (#31874) --- packages/flutter_tools/lib/src/desktop.dart | 14 +++++++++----- .../test/macos/macos_device_test.dart | 16 +++++++++------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/packages/flutter_tools/lib/src/desktop.dart b/packages/flutter_tools/lib/src/desktop.dart index 0929ea9f2a..287f33aaf0 100644 --- a/packages/flutter_tools/lib/src/desktop.dart +++ b/packages/flutter_tools/lib/src/desktop.dart @@ -53,17 +53,21 @@ Future killProcess(String executable) async { } class DesktopLogReader extends DeviceLogReader { - final StreamController _inputController = StreamController.broadcast(); + final StreamController> _inputController = StreamController>.broadcast(); void initializeProcess(Process process) { - _inputController.addStream(process.stdout - .transform(utf8.decoder) - .transform(const LineSplitter())); + process.stdout.listen(_inputController.add); + process.stderr.listen(_inputController.add); + process.exitCode.then((int result) { + _inputController.close(); + }); } @override Stream get logLines { - return _inputController.stream; + return _inputController.stream + .transform(utf8.decoder) + .transform(const LineSplitter()); } @override diff --git a/packages/flutter_tools/test/macos/macos_device_test.dart b/packages/flutter_tools/test/macos/macos_device_test.dart index 7ea82591f5..4dd84e309d 100644 --- a/packages/flutter_tools/test/macos/macos_device_test.dart +++ b/packages/flutter_tools/test/macos/macos_device_test.dart @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import 'dart:async'; import 'dart:convert'; import 'package:file/memory.dart'; @@ -20,6 +21,7 @@ import 'package:flutter_tools/src/macos/macos_device.dart'; import '../src/common.dart'; import '../src/context.dart'; +import '../src/mocks.dart'; void main() { group(MacOSDevice, () { @@ -69,21 +71,21 @@ tester 17193 0.0 0.2 4791128 37820 ?? S 2:27PM 0:00.09 /Applica final MockFileSystem mockFileSystem = MockFileSystem(); final MockProcessManager mockProcessManager = MockProcessManager(); final MockFile mockFile = MockFile(); - final MockProcess mockProcess = MockProcess(); when(macOSApp.executable(any)).thenReturn('test'); when(mockFileSystem.file('test')).thenReturn(mockFile); when(mockFile.existsSync()).thenReturn(true); when(mockProcessManager.start(['test'])).thenAnswer((Invocation invocation) async { - return mockProcess; + return FakeProcess( + exitCode: Completer().future, + stdout: Stream>.fromIterable(>[ + utf8.encode('Observatory listening on http://127.0.0.1/0\n'), + ]), + stderr: const Stream>.empty(), + ); }); when(mockProcessManager.run(any)).thenAnswer((Invocation invocation) async { return ProcessResult(0, 1, '', ''); }); - when(mockProcess.stdout).thenAnswer((Invocation invocation) { - return Stream>.fromIterable(>[ - utf8.encode('Observatory listening on http://127.0.0.1/0'), - ]); - }); testUsingContext('Can run from prebuilt application', () async { final LaunchResult result = await device.startApp(macOSApp, prebuiltApplication: true);