Unverified Commit c82fc132 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

add stderr to log processor for desktop (#31874)

parent b5e206e5
...@@ -53,17 +53,21 @@ Future<bool> killProcess(String executable) async { ...@@ -53,17 +53,21 @@ Future<bool> killProcess(String executable) async {
} }
class DesktopLogReader extends DeviceLogReader { class DesktopLogReader extends DeviceLogReader {
final StreamController<String> _inputController = StreamController<String>.broadcast(); final StreamController<List<int>> _inputController = StreamController<List<int>>.broadcast();
void initializeProcess(Process process) { void initializeProcess(Process process) {
_inputController.addStream(process.stdout process.stdout.listen(_inputController.add);
.transform(utf8.decoder) process.stderr.listen(_inputController.add);
.transform(const LineSplitter())); process.exitCode.then((int result) {
_inputController.close();
});
} }
@override @override
Stream<String> get logLines { Stream<String> get logLines {
return _inputController.stream; return _inputController.stream
.transform(utf8.decoder)
.transform(const LineSplitter());
} }
@override @override
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:async';
import 'dart:convert'; import 'dart:convert';
import 'package:file/memory.dart'; import 'package:file/memory.dart';
...@@ -20,6 +21,7 @@ import 'package:flutter_tools/src/macos/macos_device.dart'; ...@@ -20,6 +21,7 @@ import 'package:flutter_tools/src/macos/macos_device.dart';
import '../src/common.dart'; import '../src/common.dart';
import '../src/context.dart'; import '../src/context.dart';
import '../src/mocks.dart';
void main() { void main() {
group(MacOSDevice, () { group(MacOSDevice, () {
...@@ -69,21 +71,21 @@ tester 17193 0.0 0.2 4791128 37820 ?? S 2:27PM 0:00.09 /Applica ...@@ -69,21 +71,21 @@ tester 17193 0.0 0.2 4791128 37820 ?? S 2:27PM 0:00.09 /Applica
final MockFileSystem mockFileSystem = MockFileSystem(); final MockFileSystem mockFileSystem = MockFileSystem();
final MockProcessManager mockProcessManager = MockProcessManager(); final MockProcessManager mockProcessManager = MockProcessManager();
final MockFile mockFile = MockFile(); final MockFile mockFile = MockFile();
final MockProcess mockProcess = MockProcess();
when(macOSApp.executable(any)).thenReturn('test'); when(macOSApp.executable(any)).thenReturn('test');
when(mockFileSystem.file('test')).thenReturn(mockFile); when(mockFileSystem.file('test')).thenReturn(mockFile);
when(mockFile.existsSync()).thenReturn(true); when(mockFile.existsSync()).thenReturn(true);
when(mockProcessManager.start(<String>['test'])).thenAnswer((Invocation invocation) async { when(mockProcessManager.start(<String>['test'])).thenAnswer((Invocation invocation) async {
return mockProcess; return FakeProcess(
exitCode: Completer<int>().future,
stdout: Stream<List<int>>.fromIterable(<List<int>>[
utf8.encode('Observatory listening on http://127.0.0.1/0\n'),
]),
stderr: const Stream<List<int>>.empty(),
);
}); });
when(mockProcessManager.run(any)).thenAnswer((Invocation invocation) async { when(mockProcessManager.run(any)).thenAnswer((Invocation invocation) async {
return ProcessResult(0, 1, '', ''); return ProcessResult(0, 1, '', '');
}); });
when(mockProcess.stdout).thenAnswer((Invocation invocation) {
return Stream<List<int>>.fromIterable(<List<int>>[
utf8.encode('Observatory listening on http://127.0.0.1/0'),
]);
});
testUsingContext('Can run from prebuilt application', () async { testUsingContext('Can run from prebuilt application', () async {
final LaunchResult result = await device.startApp(macOSApp, prebuiltApplication: true); final LaunchResult result = await device.startApp(macOSApp, prebuiltApplication: true);
......
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