Fix log filtering and CI tests for iOS 17 physical devices (#132491)

Fixes a couple of issues introduced in new iOS 17 physical device tooling: https://github.com/flutter/flutter/pull/131865.

1) Duplicate messages were being filtered out too aggressively. 

For example, if on the counter app, you printed "Increment!" on button click, it would only print once no matter how many times you clicked.

Sometimes more than one log source is used at a time and the original intention was to filter duplicates between two log sources, so it wouldn't print the same message from both logs. However, it would also filter when the same message was added more than once via the same log.

The new solution distinguishes a "primary" and a "fallback" log source and prefers to use the primary source unless it's not working, in which it'll use the fallback. If the fallback is faster than the primary, the primary will exclude the logs received by the fallback in a 1-to-1 fashion to prevent too-aggressive filtering. Once a flutter-message has been received by the primary source, fallback messages will be ignored.

Note: iOS < 17 did not regress.

2) There was a race condition between the shutdown hooks and exiting XcodeDebug that was causing a crash when deleting a file that doesn't exist. This only affects CI  - for the new integration tests and when testing with iOS 17 physical devices.
This commit is contained in:
Victoria Ashworth
2023-08-14 12:30:55 -05:00
committed by GitHub
parent 8b8f262d4d
commit ec0b7443c4
4 changed files with 746 additions and 237 deletions

View File

@@ -190,7 +190,7 @@ Runner(libsystem_asl.dylib)[297] <Notice>: libMobileGestalt
]));
});
testWithoutContext('IOSDeviceLogReader ignores VM Service logs when attached to debugger', () async {
testWithoutContext('IOSDeviceLogReader ignores VM Service logs when attached to and received flutter logs from debugger', () async {
final Event stdoutEvent = Event(
kind: 'Stdout',
timestamp: 0,
@@ -229,14 +229,14 @@ Runner(libsystem_asl.dylib)[297] <Notice>: libMobileGestalt
iosDeployDebugger.debuggerAttached = true;
final Stream<String> debuggingLogs = Stream<String>.fromIterable(<String>[
'Message from debugger',
'flutter: Message from debugger',
]);
iosDeployDebugger.logLines = debuggingLogs;
logReader.debuggerStream = iosDeployDebugger;
// Wait for stream listeners to fire.
await expectLater(logReader.logLines, emitsInAnyOrder(<Matcher>[
equals('Message from debugger'),
equals('flutter: Message from debugger'),
]));
});
});
@@ -365,7 +365,8 @@ Runner(libsystem_asl.dylib)[297] <Notice>: libMobileGestalt
expect(logReader.useSyslogLogging, isTrue);
expect(logReader.useUnifiedLogging, isTrue);
expect(logReader.useIOSDeployLogging, isFalse);
expect(logReader.usingMultipleLoggingSources, isTrue);
expect(logReader.logSources.primarySource, IOSDeviceLogSource.idevicesyslog);
expect(logReader.logSources.fallbackSource, IOSDeviceLogSource.unifiedLogging);
});
testWithoutContext('for wirelessly attached CoreDevice', () {
@@ -384,7 +385,8 @@ Runner(libsystem_asl.dylib)[297] <Notice>: libMobileGestalt
expect(logReader.useSyslogLogging, isFalse);
expect(logReader.useUnifiedLogging, isTrue);
expect(logReader.useIOSDeployLogging, isFalse);
expect(logReader.usingMultipleLoggingSources, isFalse);
expect(logReader.logSources.primarySource, IOSDeviceLogSource.unifiedLogging);
expect(logReader.logSources.fallbackSource, isNull);
});
testWithoutContext('for iOS 12 or less device', () {
@@ -401,10 +403,11 @@ Runner(libsystem_asl.dylib)[297] <Notice>: libMobileGestalt
expect(logReader.useSyslogLogging, isTrue);
expect(logReader.useUnifiedLogging, isFalse);
expect(logReader.useIOSDeployLogging, isFalse);
expect(logReader.usingMultipleLoggingSources, isFalse);
expect(logReader.logSources.primarySource, IOSDeviceLogSource.idevicesyslog);
expect(logReader.logSources.fallbackSource, isNull);
});
testWithoutContext('for iOS 13 or greater non-CoreDevice', () {
testWithoutContext('for iOS 13 or greater non-CoreDevice and _iosDeployDebugger not attached', () {
final IOSDeviceLogReader logReader = IOSDeviceLogReader.test(
iMobileDevice: IMobileDevice(
artifacts: artifacts,
@@ -418,7 +421,40 @@ Runner(libsystem_asl.dylib)[297] <Notice>: libMobileGestalt
expect(logReader.useSyslogLogging, isFalse);
expect(logReader.useUnifiedLogging, isTrue);
expect(logReader.useIOSDeployLogging, isTrue);
expect(logReader.usingMultipleLoggingSources, isTrue);
expect(logReader.logSources.primarySource, IOSDeviceLogSource.iosDeploy);
expect(logReader.logSources.fallbackSource, IOSDeviceLogSource.unifiedLogging);
});
testWithoutContext('for iOS 13 or greater non-CoreDevice, _iosDeployDebugger not attached, and VM is connected', () {
final IOSDeviceLogReader logReader = IOSDeviceLogReader.test(
iMobileDevice: IMobileDevice(
artifacts: artifacts,
processManager: processManager,
cache: fakeCache,
logger: logger,
),
majorSdkVersion: 13,
);
final FlutterVmService vmService = FakeVmServiceHost(requests: <VmServiceExpectation>[
const FakeVmServiceRequest(method: 'streamListen', args: <String, Object>{
'streamId': 'Debug',
}),
const FakeVmServiceRequest(method: 'streamListen', args: <String, Object>{
'streamId': 'Stdout',
}),
const FakeVmServiceRequest(method: 'streamListen', args: <String, Object>{
'streamId': 'Stderr',
}),
]).vmService;
logReader.connectedVMService = vmService;
expect(logReader.useSyslogLogging, isFalse);
expect(logReader.useUnifiedLogging, isTrue);
expect(logReader.useIOSDeployLogging, isTrue);
expect(logReader.logSources.primarySource, IOSDeviceLogSource.unifiedLogging);
expect(logReader.logSources.fallbackSource, IOSDeviceLogSource.iosDeploy);
});
testWithoutContext('for iOS 13 or greater non-CoreDevice and _iosDeployDebugger is attached', () {
@@ -436,10 +472,25 @@ Runner(libsystem_asl.dylib)[297] <Notice>: libMobileGestalt
iosDeployDebugger.debuggerAttached = true;
logReader.debuggerStream = iosDeployDebugger;
final FlutterVmService vmService = FakeVmServiceHost(requests: <VmServiceExpectation>[
const FakeVmServiceRequest(method: 'streamListen', args: <String, Object>{
'streamId': 'Debug',
}),
const FakeVmServiceRequest(method: 'streamListen', args: <String, Object>{
'streamId': 'Stdout',
}),
const FakeVmServiceRequest(method: 'streamListen', args: <String, Object>{
'streamId': 'Stderr',
}),
]).vmService;
logReader.connectedVMService = vmService;
expect(logReader.useSyslogLogging, isFalse);
expect(logReader.useUnifiedLogging, isFalse);
expect(logReader.useUnifiedLogging, isTrue);
expect(logReader.useIOSDeployLogging, isTrue);
expect(logReader.usingMultipleLoggingSources, isFalse);
expect(logReader.logSources.primarySource, IOSDeviceLogSource.iosDeploy);
expect(logReader.logSources.fallbackSource, IOSDeviceLogSource.unifiedLogging);
});
testWithoutContext('for iOS 16 or greater non-CoreDevice', () {
@@ -453,10 +504,15 @@ Runner(libsystem_asl.dylib)[297] <Notice>: libMobileGestalt
majorSdkVersion: 16,
);
final FakeIOSDeployDebugger iosDeployDebugger = FakeIOSDeployDebugger();
iosDeployDebugger.debuggerAttached = true;
logReader.debuggerStream = iosDeployDebugger;
expect(logReader.useSyslogLogging, isFalse);
expect(logReader.useUnifiedLogging, isTrue);
expect(logReader.useIOSDeployLogging, isTrue);
expect(logReader.usingMultipleLoggingSources, isTrue);
expect(logReader.logSources.primarySource, IOSDeviceLogSource.iosDeploy);
expect(logReader.logSources.fallbackSource, IOSDeviceLogSource.unifiedLogging);
});
testWithoutContext('for iOS 16 or greater non-CoreDevice in CI', () {
@@ -472,126 +528,465 @@ Runner(libsystem_asl.dylib)[297] <Notice>: libMobileGestalt
);
expect(logReader.useSyslogLogging, isTrue);
expect(logReader.useUnifiedLogging, isTrue);
expect(logReader.useIOSDeployLogging, isTrue);
expect(logReader.usingMultipleLoggingSources, isTrue);
});
testWithoutContext('syslog sends flutter messages to stream when useSyslogLogging is true', () async {
processManager.addCommand(
FakeCommand(
command: <String>[
ideviceSyslogPath, '-u', '1234',
],
stdout: '''
Runner(Flutter)[297] <Notice>: A is for ari
Runner(Flutter)[297] <Notice>: I is for ichigo
May 30 13:56:28 Runner(Flutter)[2037] <Notice>: flutter: The Dart VM service is listening on http://127.0.0.1:63098/35ZezGIQLnw=/
May 30 13:56:28 Runner(Flutter)[2037] <Notice>: flutter: This is a test
May 30 13:56:28 Runner(Flutter)[2037] <Notice>: [VERBOSE-2:FlutterDarwinContextMetalImpeller.mm(39)] Using the Impeller rendering backend.
'''
),
);
final IOSDeviceLogReader logReader = IOSDeviceLogReader.test(
iMobileDevice: IMobileDevice(
artifacts: artifacts,
processManager: processManager,
cache: fakeCache,
logger: logger,
),
usingCISystem: true,
majorSdkVersion: 16,
);
final List<String> lines = await logReader.logLines.toList();
expect(logReader.useSyslogLogging, isTrue);
expect(processManager, hasNoRemainingExpectations);
expect(lines, <String>[
'flutter: The Dart VM service is listening on http://127.0.0.1:63098/35ZezGIQLnw=/',
'flutter: This is a test'
]);
});
testWithoutContext('IOSDeviceLogReader only uses ios-deploy debugger when attached and not in CI', () async {
final Stream<String> debuggingLogs = Stream<String>.fromIterable(<String>[
'(lldb) 2023-05-30 13:48:52.461894-0500 Runner[2019:1101495] [VERBOSE-2:FlutterDarwinContextMetalImpeller.mm(39)] Using the Impeller rendering backend.',
'',
]);
final IOSDeviceLogReader logReader = IOSDeviceLogReader.test(
iMobileDevice: IMobileDevice(
artifacts: artifacts,
processManager: processManager,
cache: fakeCache,
logger: logger,
),
majorSdkVersion: 16,
);
final FakeIOSDeployDebugger iosDeployDebugger = FakeIOSDeployDebugger();
iosDeployDebugger.debuggerAttached = true;
iosDeployDebugger.logLines = debuggingLogs;
logReader.debuggerStream = iosDeployDebugger;
final Future<List<String>> logLines = logReader.logLines.toList();
final List<String> lines = await logLines;
expect(logReader.useIOSDeployLogging, isTrue);
expect(logReader.useSyslogLogging, isFalse);
expect(logReader.useUnifiedLogging, isFalse);
expect(logReader.usingMultipleLoggingSources, isFalse);
expect(processManager, hasNoRemainingExpectations);
expect(
lines.contains(
'(lldb) 2023-05-30 13:48:52.461894-0500 Runner[2019:1101495] [VERBOSE-2:FlutterDarwinContextMetalImpeller.mm(39)] Using the Impeller rendering backend.',
),
isTrue,
);
expect(logReader.useIOSDeployLogging, isTrue);
expect(logReader.logSources.primarySource, IOSDeviceLogSource.iosDeploy);
expect(logReader.logSources.fallbackSource, IOSDeviceLogSource.idevicesyslog);
});
testWithoutContext('IOSDeviceLogReader uses both syslog and ios-deploy debugger for CI and filters duplicate messages', () async {
processManager.addCommand(
FakeCommand(
command: <String>[
ideviceSyslogPath, '-u', '1234',
],
stdout: '''
May 30 13:56:28 Runner(Flutter)[2037] <Notice>: flutter: The Dart VM service is listening on http://127.0.0.1:63098/35ZezGIQLnw=/
May 30 13:56:28 Runner(Flutter)[2037] <Notice>: flutter: Check for duplicate
May 30 13:56:28 Runner(Flutter)[2037] <Notice>: [VERBOSE-2:FlutterDarwinContextMetalImpeller.mm(39)] Using the Impeller rendering backend.
'''
),
);
group('when useSyslogLogging', () {
final Stream<String> debuggingLogs = Stream<String>.fromIterable(<String>[
'2023-06-01 12:49:01.445093-0500 Runner[2225:533240] flutter: Check for duplicate',
'(lldb) 2023-05-30 13:48:52.461894-0500 Runner[2019:1101495] [VERBOSE-2:FlutterDarwinContextMetalImpeller.mm(39)] Using the Impeller rendering backend.',
]);
testWithoutContext('is true syslog sends flutter messages to stream', () async {
processManager.addCommand(
FakeCommand(
command: <String>[
ideviceSyslogPath, '-u', '1234',
],
stdout: '''
Runner(Flutter)[297] <Notice>: A is for ari
Runner(Flutter)[297] <Notice>: I is for ichigo
May 30 13:56:28 Runner(Flutter)[2037] <Notice>: flutter: The Dart VM service is listening on http://127.0.0.1:63098/35ZezGIQLnw=/
May 30 13:56:28 Runner(Flutter)[2037] <Notice>: flutter: This is a test
May 30 13:56:28 Runner(Flutter)[2037] <Notice>: [VERBOSE-2:FlutterDarwinContextMetalImpeller.mm(39)] Using the Impeller rendering backend.
'''
),
);
final IOSDeviceLogReader logReader = IOSDeviceLogReader.test(
iMobileDevice: IMobileDevice(
artifacts: artifacts,
processManager: processManager,
cache: fakeCache,
logger: logger,
),
usingCISystem: true,
majorSdkVersion: 16,
);
final List<String> lines = await logReader.logLines.toList();
final IOSDeviceLogReader logReader = IOSDeviceLogReader.test(
iMobileDevice: IMobileDevice(
artifacts: artifacts,
processManager: processManager,
cache: fakeCache,
logger: logger,
),
usingCISystem: true,
majorSdkVersion: 16,
);
final FakeIOSDeployDebugger iosDeployDebugger = FakeIOSDeployDebugger();
iosDeployDebugger.logLines = debuggingLogs;
logReader.debuggerStream = iosDeployDebugger;
final Future<List<String>> logLines = logReader.logLines.toList();
final List<String> lines = await logLines;
expect(logReader.useSyslogLogging, isTrue);
expect(processManager, hasNoRemainingExpectations);
expect(lines, <String>[
'flutter: The Dart VM service is listening on http://127.0.0.1:63098/35ZezGIQLnw=/',
'flutter: This is a test'
]);
});
expect(logReader.useSyslogLogging, isTrue);
expect(logReader.useIOSDeployLogging, isTrue);
expect(logReader.usingMultipleLoggingSources, isTrue);
expect(processManager, hasNoRemainingExpectations);
expect(lines.length, 3);
expect(lines, containsAll(<String>[
'(lldb) 2023-05-30 13:48:52.461894-0500 Runner[2019:1101495] [VERBOSE-2:FlutterDarwinContextMetalImpeller.mm(39)] Using the Impeller rendering backend.',
'flutter: The Dart VM service is listening on http://127.0.0.1:63098/35ZezGIQLnw=/',
'flutter: Check for duplicate',
]));
testWithoutContext('is false syslog does not send flutter messages to stream', () async {
final IOSDeviceLogReader logReader = IOSDeviceLogReader.test(
iMobileDevice: IMobileDevice(
artifacts: artifacts,
processManager: processManager,
cache: fakeCache,
logger: logger,
),
majorSdkVersion: 16,
);
final FakeIOSDeployDebugger iosDeployDebugger = FakeIOSDeployDebugger();
iosDeployDebugger.logLines = Stream<String>.fromIterable(<String>[]);
logReader.debuggerStream = iosDeployDebugger;
final List<String> lines = await logReader.logLines.toList();
expect(logReader.useSyslogLogging, isFalse);
expect(processManager, hasNoRemainingExpectations);
expect(lines, isEmpty);
});
});
group('when useIOSDeployLogging', () {
testWithoutContext('is true ios-deploy sends flutter messages to stream', () async {
final IOSDeviceLogReader logReader = IOSDeviceLogReader.test(
iMobileDevice: IMobileDevice(
artifacts: artifacts,
processManager: processManager,
cache: fakeCache,
logger: logger,
),
majorSdkVersion: 16,
);
final FakeIOSDeployDebugger iosDeployDebugger = FakeIOSDeployDebugger();
final Stream<String> debuggingLogs = Stream<String>.fromIterable(<String>[
'flutter: Message from debugger',
]);
iosDeployDebugger.logLines = debuggingLogs;
logReader.debuggerStream = iosDeployDebugger;
final List<String> lines = await logReader.logLines.toList();
expect(logReader.useIOSDeployLogging, isTrue);
expect(processManager, hasNoRemainingExpectations);
expect(lines, <String>[
'flutter: Message from debugger',
]);
});
testWithoutContext('is false ios-deploy does not send flutter messages to stream', () async {
final IOSDeviceLogReader logReader = IOSDeviceLogReader.test(
iMobileDevice: IMobileDevice(
artifacts: artifacts,
processManager: FakeProcessManager.any(),
cache: fakeCache,
logger: logger,
),
majorSdkVersion: 12,
);
final FakeIOSDeployDebugger iosDeployDebugger = FakeIOSDeployDebugger();
final Stream<String> debuggingLogs = Stream<String>.fromIterable(<String>[
'flutter: Message from debugger',
]);
iosDeployDebugger.logLines = debuggingLogs;
logReader.debuggerStream = iosDeployDebugger;
final List<String> lines = await logReader.logLines.toList();
expect(logReader.useIOSDeployLogging, isFalse);
expect(processManager, hasNoRemainingExpectations);
expect(lines, isEmpty);
});
});
group('when useUnifiedLogging', () {
testWithoutContext('is true Dart VM sends flutter messages to stream', () async {
final Event stdoutEvent = Event(
kind: 'Stdout',
timestamp: 0,
bytes: base64.encode(utf8.encode('flutter: A flutter message')),
);
final Event stderrEvent = Event(
kind: 'Stderr',
timestamp: 0,
bytes: base64.encode(utf8.encode('flutter: A second flutter message')),
);
final FlutterVmService vmService = FakeVmServiceHost(requests: <VmServiceExpectation>[
const FakeVmServiceRequest(method: 'streamListen', args: <String, Object>{
'streamId': 'Debug',
}),
const FakeVmServiceRequest(method: 'streamListen', args: <String, Object>{
'streamId': 'Stdout',
}),
const FakeVmServiceRequest(method: 'streamListen', args: <String, Object>{
'streamId': 'Stderr',
}),
FakeVmServiceStreamResponse(event: stdoutEvent, streamId: 'Stdout'),
FakeVmServiceStreamResponse(event: stderrEvent, streamId: 'Stderr'),
]).vmService;
final IOSDeviceLogReader logReader = IOSDeviceLogReader.test(
useSyslog: false,
iMobileDevice: IMobileDevice(
artifacts: artifacts,
processManager: processManager,
cache: fakeCache,
logger: logger,
),
);
logReader.connectedVMService = vmService;
// Wait for stream listeners to fire.
expect(logReader.useUnifiedLogging, isTrue);
expect(processManager, hasNoRemainingExpectations);
await expectLater(logReader.logLines, emitsInAnyOrder(<Matcher>[
equals('flutter: A flutter message'),
equals('flutter: A second flutter message'),
]));
});
testWithoutContext('is false Dart VM does not send flutter messages to stream', () async {
final Event stdoutEvent = Event(
kind: 'Stdout',
timestamp: 0,
bytes: base64.encode(utf8.encode('flutter: A flutter message')),
);
final Event stderrEvent = Event(
kind: 'Stderr',
timestamp: 0,
bytes: base64.encode(utf8.encode('flutter: A second flutter message')),
);
final FlutterVmService vmService = FakeVmServiceHost(requests: <VmServiceExpectation>[
const FakeVmServiceRequest(method: 'streamListen', args: <String, Object>{
'streamId': 'Debug',
}),
const FakeVmServiceRequest(method: 'streamListen', args: <String, Object>{
'streamId': 'Stdout',
}),
const FakeVmServiceRequest(method: 'streamListen', args: <String, Object>{
'streamId': 'Stderr',
}),
FakeVmServiceStreamResponse(event: stdoutEvent, streamId: 'Stdout'),
FakeVmServiceStreamResponse(event: stderrEvent, streamId: 'Stderr'),
]).vmService;
final IOSDeviceLogReader logReader = IOSDeviceLogReader.test(
iMobileDevice: IMobileDevice(
artifacts: artifacts,
processManager: FakeProcessManager.any(),
cache: fakeCache,
logger: logger,
),
majorSdkVersion: 12,
);
logReader.connectedVMService = vmService;
final List<String> lines = await logReader.logLines.toList();
// Wait for stream listeners to fire.
expect(logReader.useUnifiedLogging, isFalse);
expect(processManager, hasNoRemainingExpectations);
expect(lines, isEmpty);
});
});
group('and when to exclude logs:', () {
testWithoutContext('all primary messages are included except if fallback sent flutter message first', () async {
final IOSDeviceLogReader logReader = IOSDeviceLogReader.test(
iMobileDevice: IMobileDevice(
artifacts: artifacts,
processManager: FakeProcessManager.any(),
cache: fakeCache,
logger: logger,
),
usingCISystem: true,
majorSdkVersion: 16,
);
expect(logReader.useSyslogLogging, isTrue);
expect(logReader.useIOSDeployLogging, isTrue);
expect(logReader.logSources.primarySource, IOSDeviceLogSource.iosDeploy);
expect(logReader.logSources.fallbackSource, IOSDeviceLogSource.idevicesyslog);
final Future<List<String>> logLines = logReader.logLines.toList();
logReader.addToLinesController(
'flutter: The Dart VM service is listening on http://127.0.0.1:63098/35ZezGIQLnw=/',
IOSDeviceLogSource.idevicesyslog,
);
// Will be excluded because was already added by fallback.
logReader.addToLinesController(
'flutter: The Dart VM service is listening on http://127.0.0.1:63098/35ZezGIQLnw=/',
IOSDeviceLogSource.iosDeploy,
);
logReader.addToLinesController(
'A second non-flutter message',
IOSDeviceLogSource.iosDeploy,
);
logReader.addToLinesController(
'flutter: Another flutter message',
IOSDeviceLogSource.iosDeploy,
);
final List<String> lines = await logLines;
expect(lines, containsAllInOrder(<String>[
'flutter: The Dart VM service is listening on http://127.0.0.1:63098/35ZezGIQLnw=/', // from idevicesyslog
'A second non-flutter message', // from iosDeploy
'flutter: Another flutter message', // from iosDeploy
]));
});
testWithoutContext('all primary messages are included when there is no fallback', () async {
final IOSDeviceLogReader logReader = IOSDeviceLogReader.test(
iMobileDevice: IMobileDevice(
artifacts: artifacts,
processManager: FakeProcessManager.any(),
cache: fakeCache,
logger: logger,
),
majorSdkVersion: 12,
);
expect(logReader.useSyslogLogging, isTrue);
expect(logReader.logSources.primarySource, IOSDeviceLogSource.idevicesyslog);
expect(logReader.logSources.fallbackSource, isNull);
final Future<List<String>> logLines = logReader.logLines.toList();
logReader.addToLinesController(
'flutter: The Dart VM service is listening on http://127.0.0.1:63098/35ZezGIQLnw=/',
IOSDeviceLogSource.idevicesyslog,
);
logReader.addToLinesController(
'A non-flutter message',
IOSDeviceLogSource.idevicesyslog,
);
logReader.addToLinesController(
'A non-flutter message',
IOSDeviceLogSource.idevicesyslog,
);
logReader.addToLinesController(
'flutter: A flutter message',
IOSDeviceLogSource.idevicesyslog,
);
logReader.addToLinesController(
'flutter: A flutter message',
IOSDeviceLogSource.idevicesyslog,
);
final List<String> lines = await logLines;
expect(lines, containsAllInOrder(<String>[
'flutter: The Dart VM service is listening on http://127.0.0.1:63098/35ZezGIQLnw=/',
'A non-flutter message',
'A non-flutter message',
'flutter: A flutter message',
'flutter: A flutter message',
]));
});
testWithoutContext('primary messages are not added if fallback already added them, otherwise duplicates are allowed', () async {
final IOSDeviceLogReader logReader = IOSDeviceLogReader.test(
iMobileDevice: IMobileDevice(
artifacts: artifacts,
processManager: FakeProcessManager.any(),
cache: fakeCache,
logger: logger,
),
usingCISystem: true,
majorSdkVersion: 16,
);
expect(logReader.useSyslogLogging, isTrue);
expect(logReader.useIOSDeployLogging, isTrue);
expect(logReader.logSources.primarySource, IOSDeviceLogSource.iosDeploy);
expect(logReader.logSources.fallbackSource, IOSDeviceLogSource.idevicesyslog);
final Future<List<String>> logLines = logReader.logLines.toList();
logReader.addToLinesController(
'flutter: A flutter message',
IOSDeviceLogSource.idevicesyslog,
);
logReader.addToLinesController(
'flutter: A flutter message',
IOSDeviceLogSource.idevicesyslog,
);
logReader.addToLinesController(
'A non-flutter message',
IOSDeviceLogSource.iosDeploy,
);
logReader.addToLinesController(
'A non-flutter message',
IOSDeviceLogSource.iosDeploy,
);
// Will be excluded because was already added by fallback.
logReader.addToLinesController(
'flutter: A flutter message',
IOSDeviceLogSource.iosDeploy,
);
// Will be excluded because was already added by fallback.
logReader.addToLinesController(
'flutter: A flutter message',
IOSDeviceLogSource.iosDeploy,
);
// Will be included because, although the message is the same, the
// fallback only added it twice so this third one is considered new.
logReader.addToLinesController(
'flutter: A flutter message',
IOSDeviceLogSource.iosDeploy,
);
final List<String> lines = await logLines;
expect(lines, containsAllInOrder(<String>[
'flutter: A flutter message', // from idevicesyslog
'flutter: A flutter message', // from idevicesyslog
'A non-flutter message', // from iosDeploy
'A non-flutter message', // from iosDeploy
'flutter: A flutter message', // from iosDeploy
]));
});
testWithoutContext('flutter fallback messages are included until a primary flutter message is received', () async {
final IOSDeviceLogReader logReader = IOSDeviceLogReader.test(
iMobileDevice: IMobileDevice(
artifacts: artifacts,
processManager: FakeProcessManager.any(),
cache: fakeCache,
logger: logger,
),
usingCISystem: true,
majorSdkVersion: 16,
);
expect(logReader.useSyslogLogging, isTrue);
expect(logReader.useIOSDeployLogging, isTrue);
expect(logReader.logSources.primarySource, IOSDeviceLogSource.iosDeploy);
expect(logReader.logSources.fallbackSource, IOSDeviceLogSource.idevicesyslog);
final Future<List<String>> logLines = logReader.logLines.toList();
logReader.addToLinesController(
'flutter: The Dart VM service is listening on http://127.0.0.1:63098/35ZezGIQLnw=/',
IOSDeviceLogSource.idevicesyslog,
);
logReader.addToLinesController(
'A second non-flutter message',
IOSDeviceLogSource.iosDeploy,
);
// Will be included because the first log from primary source wasn't a
// flutter log.
logReader.addToLinesController(
'flutter: A flutter message',
IOSDeviceLogSource.idevicesyslog,
);
// Will be excluded because was already added by fallback, however, it
// will be used to determine a flutter log was received by the primary source.
logReader.addToLinesController(
'flutter: The Dart VM service is listening on http://127.0.0.1:63098/35ZezGIQLnw=/',
IOSDeviceLogSource.iosDeploy,
);
// Will be excluded because flutter log from primary was received.
logReader.addToLinesController(
'flutter: A third flutter message',
IOSDeviceLogSource.idevicesyslog,
);
final List<String> lines = await logLines;
expect(lines, containsAllInOrder(<String>[
'flutter: The Dart VM service is listening on http://127.0.0.1:63098/35ZezGIQLnw=/', // from idevicesyslog
'A second non-flutter message', // from iosDeploy
'flutter: A flutter message', // from idevicesyslog
]));
});
testWithoutContext('non-flutter fallback messages are not included', () async {
final IOSDeviceLogReader logReader = IOSDeviceLogReader.test(
iMobileDevice: IMobileDevice(
artifacts: artifacts,
processManager: FakeProcessManager.any(),
cache: fakeCache,
logger: logger,
),
usingCISystem: true,
majorSdkVersion: 16,
);
expect(logReader.useSyslogLogging, isTrue);
expect(logReader.useIOSDeployLogging, isTrue);
expect(logReader.logSources.primarySource, IOSDeviceLogSource.iosDeploy);
expect(logReader.logSources.fallbackSource, IOSDeviceLogSource.idevicesyslog);
final Future<List<String>> logLines = logReader.logLines.toList();
logReader.addToLinesController(
'flutter: A flutter message',
IOSDeviceLogSource.idevicesyslog,
);
// Will be excluded because it's from fallback and not a flutter message.
logReader.addToLinesController(
'A non-flutter message',
IOSDeviceLogSource.idevicesyslog,
);
final List<String> lines = await logLines;
expect(lines, containsAllInOrder(<String>[
'flutter: A flutter message',
]));
});
});
});
}

View File

@@ -784,6 +784,69 @@ void main() {
expect(status, isTrue);
});
testWithoutContext('prints error message when deleting temporary directory that is nonexistant', () async {
final Xcode xcode = setupXcode(
fakeProcessManager: fakeProcessManager,
fileSystem: fileSystem,
flutterRoot: flutterRoot,
);
final XcodeDebugProject project = XcodeDebugProject(
scheme: 'Runner',
xcodeProject: xcodeproj,
xcodeWorkspace: xcworkspace,
isTemporaryProject: true,
);
final XcodeDebug xcodeDebug = XcodeDebug(
logger: logger,
processManager: fakeProcessManager,
xcode: xcode,
fileSystem: fileSystem,
);
fakeProcessManager.addCommands(<FakeCommand>[
FakeCommand(
command: <String>[
'xcrun',
'osascript',
'-l',
'JavaScript',
pathToXcodeAutomationScript,
'stop',
'--xcode-path',
pathToXcodeApp,
'--project-path',
project.xcodeProject.path,
'--workspace-path',
project.xcodeWorkspace.path,
'--close-window'
],
stdout: '''
{"status":true,"errorMessage":null,"debugResult":null}
''',
),
]);
xcodeDebug.startDebugActionProcess = FakeProcess();
xcodeDebug.currentDebuggingProject = project;
expect(xcodeDebug.startDebugActionProcess, isNotNull);
expect(xcodeDebug.currentDebuggingProject, isNotNull);
expect(projectDirectory.existsSync(), isFalse);
expect(xcodeproj.existsSync(), isFalse);
expect(xcworkspace.existsSync(), isFalse);
final bool status = await xcodeDebug.exit(skipDelay: true);
expect((xcodeDebug.startDebugActionProcess! as FakeProcess).killed, isTrue);
expect(xcodeDebug.currentDebuggingProject, isNull);
expect(projectDirectory.existsSync(), isFalse);
expect(xcodeproj.existsSync(), isFalse);
expect(xcworkspace.existsSync(), isFalse);
expect(logger.errorText, contains('Failed to delete temporary Xcode project'));
expect(fakeProcessManager, hasNoRemainingExpectations);
expect(status, isTrue);
});
testWithoutContext('kill Xcode when force exit', () async {
final Xcode xcode = setupXcode(
fakeProcessManager: FakeProcessManager.any(),
@@ -825,6 +888,46 @@ void main() {
expect(fakeProcessManager, hasNoRemainingExpectations);
expect(exitStatus, isTrue);
});
testWithoutContext('does not crash when deleting temporary directory that is nonexistant when force exiting', () async {
final Xcode xcode = setupXcode(
fakeProcessManager: FakeProcessManager.any(),
fileSystem: fileSystem,
flutterRoot: flutterRoot,
);
final XcodeDebugProject project = XcodeDebugProject(
scheme: 'Runner',
xcodeProject: xcodeproj,
xcodeWorkspace: xcworkspace,
isTemporaryProject: true,
);
final XcodeDebug xcodeDebug = XcodeDebug(
logger: logger,
processManager:FakeProcessManager.any(),
xcode: xcode,
fileSystem: fileSystem,
);
xcodeDebug.startDebugActionProcess = FakeProcess();
xcodeDebug.currentDebuggingProject = project;
expect(xcodeDebug.startDebugActionProcess, isNotNull);
expect(xcodeDebug.currentDebuggingProject, isNotNull);
expect(projectDirectory.existsSync(), isFalse);
expect(xcodeproj.existsSync(), isFalse);
expect(xcworkspace.existsSync(), isFalse);
final bool status = await xcodeDebug.exit(force: true);
expect((xcodeDebug.startDebugActionProcess! as FakeProcess).killed, isTrue);
expect(xcodeDebug.currentDebuggingProject, isNull);
expect(projectDirectory.existsSync(), isFalse);
expect(xcodeproj.existsSync(), isFalse);
expect(xcworkspace.existsSync(), isFalse);
expect(logger.errorText, isEmpty);
expect(fakeProcessManager, hasNoRemainingExpectations);
expect(status, isTrue);
});
});
group('stop app', () {