Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log all output of ios-deploy #127222

Merged
merged 5 commits into from
May 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 7 additions & 11 deletions packages/flutter_tools/lib/src/ios/ios_deploy.dart
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,12 @@ class IOSDeployDebugger {
.transform<String>(utf8.decoder)
.transform<String>(const LineSplitter())
.listen((String line) {

// TODO(vashworth): Revert after https://github.com/flutter/flutter/issues/121231 is resolved.
if (line.isNotEmpty) {
_logger.printTrace(line);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a test for this in test/general.shard/ios/ios_deploy_test.dart? Looks like we have prior art.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad, I thought just logs didn't need a test. Also, not sure what you mean by "prior art", but I added a test.

}

_monitorIOSDeployFailure(line, _logger);

// (lldb) platform select remote-'ios' --sysroot
Expand All @@ -365,7 +371,6 @@ class IOSDeployDebugger {
}
final String prompt = line.substring(0, promptEndIndex);
lldbRun = RegExp(RegExp.escape(prompt) + r'\s*run');
_logger.printTrace(line);
return;
}

Expand All @@ -384,7 +389,6 @@ class IOSDeployDebugger {
// success
// 2020-09-15 13:42:25.185474-0700 Runner[477:181141] flutter: The Dart VM service is listening on http://127.0.0.1:57782/
if (lldbRun.hasMatch(line)) {
_logger.printTrace(line);
_debuggerState = _IOSDeployDebuggerState.launching;
// TODO(vashworth): Remove all debugger state comments when https://github.com/flutter/flutter/issues/126412 is resolved.
_logger.printTrace('Debugger state set to launching.');
Expand All @@ -393,7 +397,6 @@ class IOSDeployDebugger {
// Next line after "run" must be "success", or the attach failed.
// Example: "error: process launch failed"
if (_debuggerState == _IOSDeployDebuggerState.launching) {
_logger.printTrace(line);
final bool attachSuccess = line == 'success';
_debuggerState = attachSuccess ? _IOSDeployDebuggerState.attached : _IOSDeployDebuggerState.detached;
_logger.printTrace('Debugger state set to ${attachSuccess ? 'attached' : 'detached'}.');
Expand All @@ -408,7 +411,6 @@ class IOSDeployDebugger {
// process signal SIGSTOP
if (line.contains(_signalStop)) {
// The app is about to be stopped. Only show in verbose mode.
_logger.printTrace(line);
return;
}

Expand All @@ -421,7 +423,6 @@ class IOSDeployDebugger {

if (line == _backTraceAll) {
// The app is stopped and the backtrace for all threads will be printed.
_logger.printTrace(line);
// Even though we're not "detached", just stopped, mark as detached so the backtrace
// is only show in verbose.
_debuggerState = _IOSDeployDebuggerState.detached;
Expand All @@ -438,7 +439,6 @@ class IOSDeployDebugger {

if (line.contains('PROCESS_STOPPED') || _lldbProcessStopped.hasMatch(line)) {
// The app has been stopped. Dump the backtrace, and detach.
_logger.printTrace(line);
_iosDeployProcess?.stdin.writeln(_backTraceAll);
if (_processResumeCompleter == null) {
detach();
Expand All @@ -449,28 +449,24 @@ class IOSDeployDebugger {
if (line.contains('PROCESS_EXITED') || _lldbProcessExit.hasMatch(line)) {
// The app exited or crashed, so exit. Continue passing debugging
// messages to the log reader until it exits to capture crash dumps.
_logger.printTrace(line);
exit();
return;
}
if (_lldbProcessDetached.hasMatch(line)) {
// The debugger has detached from the app, and there will be no more debugging messages.
// Kill the ios-deploy process.
_logger.printTrace(line);
exit();
return;
}

if (_lldbProcessResuming.hasMatch(line)) {
_logger.printTrace(line);
// we marked this detached when we received [_backTraceAll]
_debuggerState = _IOSDeployDebuggerState.attached;
_logger.printTrace('Debugger state set to attached.');
return;
}

if (_debuggerState != _IOSDeployDebuggerState.attached) {
_logger.printTrace(line);
return;
}
if (lastLineFromDebugger != null && lastLineFromDebugger!.isNotEmpty && line.isEmpty) {
Expand All @@ -488,7 +484,7 @@ class IOSDeployDebugger {
.transform<String>(const LineSplitter())
.listen((String line) {
_monitorIOSDeployFailure(line, _logger);
_logger.printTrace(line);
_logger.printTrace('error: $line');
});
unawaited(_iosDeployProcess!.exitCode.then((int status) async {
_logger.printTrace('ios-deploy exited with code $exitCode');
Expand Down
20 changes: 20 additions & 0 deletions packages/flutter_tools/test/general.shard/ios/ios_deploy_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,26 @@ void main () {
logger = BufferLogger.test();
});

testWithoutContext('print all lines', () async {
final StreamController<List<int>> stdin = StreamController<List<int>>();
final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
FakeCommand(
command: const <String>['ios-deploy'],
stdout: "(mylldb) platform select remote-'ios' --sysroot\r\n(mylldb) run\r\nsuccess\r\nrandom string\r\n",
stdin: IOSink(stdin.sink),
),
]);
final IOSDeployDebugger iosDeployDebugger = IOSDeployDebugger.test(
processManager: processManager,
logger: logger,
);
expect(await iosDeployDebugger.launchAndAttach(), isTrue);
expect(logger.traceText, contains("(mylldb) platform select remote-'ios' --sysroot"));
expect(logger.traceText, contains('(mylldb) run'));
expect(logger.traceText, contains('success'));
expect(logger.traceText, contains('random string'));
});

testWithoutContext('custom lldb prompt', () async {
final StreamController<List<int>> stdin = StreamController<List<int>>();
final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
Expand Down