Add debugging for iOS startup test flakes (#130099)

Adding debugging for https://github.com/flutter/flutter/issues/129836.

Takes a screenshot when startup test takes too long (10 minutes).

Also, removes some old debugging and add new debugging message.
This commit is contained in:
Victoria Ashworth
2023-07-07 11:49:00 -05:00
committed by GitHub
parent d55a7d89e0
commit 6683468f0b
3 changed files with 71 additions and 20 deletions

View File

@@ -338,6 +338,8 @@ class IOSDeployDebugger {
RegExp lldbRun = RegExp(r'\(lldb\)\s*run');
final Completer<bool> debuggerCompleter = Completer<bool>();
bool receivedLogs = false;
try {
_iosDeployProcess = await _processUtils.start(
_launchCommand,
@@ -386,8 +388,6 @@ class IOSDeployDebugger {
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.');
return;
}
// Next line after "run" must be "success", or the attach failed.
@@ -396,7 +396,6 @@ class IOSDeployDebugger {
_logger.printTrace(line);
final bool attachSuccess = line == 'success';
_debuggerState = attachSuccess ? _IOSDeployDebuggerState.attached : _IOSDeployDebuggerState.detached;
_logger.printTrace('Debugger state set to ${attachSuccess ? 'attached' : 'detached'}.');
if (!debuggerCompleter.isCompleted) {
debuggerCompleter.complete(attachSuccess);
}
@@ -425,7 +424,6 @@ class IOSDeployDebugger {
// Even though we're not "detached", just stopped, mark as detached so the backtrace
// is only show in verbose.
_debuggerState = _IOSDeployDebuggerState.detached;
_logger.printTrace('Debugger state set to detached.');
// If we paused the app and are waiting to resume it, complete the completer
final Completer<void>? processResumeCompleter = _processResumeCompleter;
@@ -465,7 +463,6 @@ class IOSDeployDebugger {
_logger.printTrace(line);
// we marked this detached when we received [_backTraceAll]
_debuggerState = _IOSDeployDebuggerState.attached;
_logger.printTrace('Debugger state set to attached.');
return;
}
@@ -480,6 +477,16 @@ class IOSDeployDebugger {
// This will still cause "legit" logged newlines to be doubled...
} else if (!_debuggerOutput.isClosed) {
_debuggerOutput.add(line);
// Sometimes the `ios-deploy` process does not return logs from the
// application after attaching, such as the Dart VM url. In CI,
// `idevicesyslog` is used as a fallback to get logs. Print a
// message to indicate whether logs were received from `ios-deploy`
// to help with debugging.
if (!receivedLogs) {
_logger.printTrace('Received logs from ios-deploy.');
receivedLogs = true;
}
}
lastLineFromDebugger = line;
});

View File

@@ -341,6 +341,33 @@ void main () {
await iosDeployDebugger.launchAndAttach();
expect(logger.errorText, contains('Try launching from within Xcode'));
});
testWithoutContext('debugger attached and received logs', () async {
final StreamController<List<int>> stdin = StreamController<List<int>>();
final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
FakeCommand(
command: const <String>['ios-deploy'],
stdout: '(lldb) run\r\nsuccess\r\nLog on attach1\r\n\r\nLog on attach2\r\n',
stdin: IOSink(stdin.sink),
),
]);
final IOSDeployDebugger iosDeployDebugger = IOSDeployDebugger.test(
processManager: processManager,
logger: logger,
);
final List<String> receivedLogLines = <String>[];
final Stream<String> logLines = iosDeployDebugger.logLines
..listen(receivedLogLines.add);
expect(iosDeployDebugger.logLines, emitsInOrder(<String>[
'Log on attach1',
'Log on attach2',
]));
expect(await iosDeployDebugger.launchAndAttach(), isTrue);
await logLines.drain();
expect(LineSplitter.split(logger.traceText), containsOnce('Received logs from ios-deploy.'));
});
});
testWithoutContext('detach', () async {