mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
[flutter_tools] expand Regexp log match to include more AndroidRuntime failures (#56943)
This commit is contained in:
parent
7ed0950e05
commit
7f400af35a
@ -986,6 +986,7 @@ class AdbLogReader extends DeviceLogReader {
|
||||
RegExp(r'^[VDIWEF]\/flutter[^:]*:\s+', caseSensitive: false),
|
||||
RegExp(r'^[IE]\/DartVM[^:]*:\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]\/System\.err:\s+'),
|
||||
RegExp(r'^[F]\/[\S^:]+:\s+'),
|
||||
@ -1019,6 +1020,7 @@ class AdbLogReader extends DeviceLogReader {
|
||||
}
|
||||
final Match timeMatch = AndroidDevice._timeRegExp.firstMatch(line);
|
||||
if (timeMatch == null || line.length == timeMatch.end) {
|
||||
_acceptedLastLine = false;
|
||||
return;
|
||||
}
|
||||
// Chop off the time.
|
||||
|
||||
@ -13,6 +13,11 @@ import '../../src/context.dart';
|
||||
const int kLollipopVersionCode = 21;
|
||||
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() {
|
||||
testWithoutContext('AdbLogReader calls adb logcat with expected flags apiVersion 21', () async {
|
||||
final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
|
||||
@ -128,6 +133,40 @@ void main() {
|
||||
logReader.dispose();
|
||||
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) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user