Unverified Commit 7f400af3 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[flutter_tools] expand Regexp log match to include more AndroidRuntime failures (#56943)

parent 7ed0950e
...@@ -986,6 +986,7 @@ class AdbLogReader extends DeviceLogReader { ...@@ -986,6 +986,7 @@ class AdbLogReader extends DeviceLogReader {
RegExp(r'^[VDIWEF]\/flutter[^:]*:\s+', caseSensitive: false), RegExp(r'^[VDIWEF]\/flutter[^:]*:\s+', caseSensitive: false),
RegExp(r'^[IE]\/DartVM[^:]*:\s+'), RegExp(r'^[IE]\/DartVM[^:]*:\s+'),
RegExp(r'^[WEF]\/AndroidRuntime:\s+'), RegExp(r'^[WEF]\/AndroidRuntime:\s+'),
RegExp(r'^[WEF]\/AndroidRuntime\([0-9]+\):\s+'),
RegExp(r'^[WEF]\/ActivityManager:\s+.*(\bflutter\b|\bdomokit\b|\bsky\b)'), RegExp(r'^[WEF]\/ActivityManager:\s+.*(\bflutter\b|\bdomokit\b|\bsky\b)'),
RegExp(r'^[WEF]\/System\.err:\s+'), RegExp(r'^[WEF]\/System\.err:\s+'),
RegExp(r'^[F]\/[\S^:]+:\s+'), RegExp(r'^[F]\/[\S^:]+:\s+'),
...@@ -1019,6 +1020,7 @@ class AdbLogReader extends DeviceLogReader { ...@@ -1019,6 +1020,7 @@ class AdbLogReader extends DeviceLogReader {
} }
final Match timeMatch = AndroidDevice._timeRegExp.firstMatch(line); final Match timeMatch = AndroidDevice._timeRegExp.firstMatch(line);
if (timeMatch == null || line.length == timeMatch.end) { if (timeMatch == null || line.length == timeMatch.end) {
_acceptedLastLine = false;
return; return;
} }
// Chop off the time. // Chop off the time.
......
...@@ -13,6 +13,11 @@ import '../../src/context.dart'; ...@@ -13,6 +13,11 @@ import '../../src/context.dart';
const int kLollipopVersionCode = 21; const int kLollipopVersionCode = 21;
const String kLastLogcatTimestamp = '11-27 15:39:04.506'; const String kLastLogcatTimestamp = '11-27 15:39:04.506';
/// By default the android log reader accepts lines that match no patterns
/// if the previous line was a match. Include an intentionally non-matching
/// line as the first input to disable this behavior.
const String kDummyLine = 'Contents are not important\n';
void main() { void main() {
testWithoutContext('AdbLogReader calls adb logcat with expected flags apiVersion 21', () async { testWithoutContext('AdbLogReader calls adb logcat with expected flags apiVersion 21', () async {
final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[ final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
...@@ -128,6 +133,40 @@ void main() { ...@@ -128,6 +133,40 @@ void main() {
logReader.dispose(); logReader.dispose();
await onDone.future; await onDone.future;
}); });
testWithoutContext('AdbLogReader does not filter output from AndroidRuntime crashes', () async {
final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
FakeCommand(
command: const <String>[
'adb',
'-s',
'1234',
'logcat',
'-v',
'time',
],
completer: Completer<void>.sync(),
// Example stack trace from an incorrectly named application:name in the AndroidManfiest.xml
stdout:
kDummyLine +
'05-11 12:54:46.665 E/AndroidRuntime(11787): FATAL EXCEPTION: main\n'
'05-11 12:54:46.665 E/AndroidRuntime(11787): Process: com.example.foobar, PID: 11787\n'
'05-11 12:54:46.665 java.lang.RuntimeException: Unable to instantiate application '
'io.flutter.app.FlutterApplication2: java.lang.ClassNotFoundException:\n',
)
]);
final AdbLogReader logReader = await AdbLogReader.createLogReader(
createMockDevice(null),
processManager,
);
await expectLater(logReader.logLines, emitsInOrder(<String>[
'E/AndroidRuntime(11787): FATAL EXCEPTION: main',
'E/AndroidRuntime(11787): Process: com.example.foobar, PID: 11787',
'java.lang.RuntimeException: Unable to instantiate application io.flutter.app.FlutterApplication2: java.lang.ClassNotFoundException:',
]));
logReader.dispose();
});
} }
MockAndroidDevice createMockDevice(int sdkLevel) { MockAndroidDevice createMockDevice(int sdkLevel) {
......
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