Skip to content

Commit 4ea319f

Browse files
authored
Fix integration test log parsing when running on the CI (#528)
1 parent a072016 commit 4ea319f

File tree

2 files changed

+11
-17
lines changed

2 files changed

+11
-17
lines changed

tools/lib/src/device.dart

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,6 @@ class Device {
9595
return _serial != null;
9696
}
9797

98-
static final RegExp _logPattern =
99-
RegExp(r'\d\d:\d\d\s+([(\+\d+\s+)|(~\d+\s+)|(\-\d+\s+)]+):\s+(.*)');
100-
10198
String? _findSerial() {
10299
final List<SdbDeviceInfo> deviceInfos = _tizenSdk.sdbDevices();
103100
for (final SdbDeviceInfo deviceInfo in deviceInfos) {
@@ -163,19 +160,16 @@ class Device {
163160
'If you expect the test to finish before timeout, check if the tests '
164161
'require device screen to be awake or if they require manually '
165162
'clicking the UI button for permissions.';
166-
} else if (lastLine.startsWith('No tests ran')) {
163+
} else if (lastLine.contains('No tests ran')) {
167164
error =
168165
'Missing integration tests (use --exclude if this is intentional).';
169-
} else if (lastLine.startsWith('No devices found')) {
166+
} else if (lastLine.contains('No devices found')) {
170167
error = 'Device was disconnected during test.';
171-
} else {
172-
final RegExpMatch? match = _logPattern.firstMatch(lastLine);
173-
if (match == null || match.group(2) == null) {
174-
error = 'Could not parse the log output.';
175-
} else if (!match.group(2)!.startsWith('All tests passed!')) {
176-
error = 'flutter-tizen test integration_test failed, see the output '
177-
'above for details.';
178-
}
168+
} else if (lastLine.contains('failed')) {
169+
error = 'flutter-tizen test integration_test failed, see the output '
170+
'above for details.';
171+
} else if (!lastLine.contains('passed')) {
172+
error = 'Could not parse the log output.';
179173
}
180174
return error;
181175
}

tools/test/device_test.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,11 @@ void main() {
108108
expect(error!.contains('Device was disconnected during test'), true);
109109
});
110110

111-
test('correctly parses log "All tests passed!"', () async {
111+
test('correctly parses log when all tests passed', () async {
112112
Future<void>.delayed(
113113
const Duration(seconds: 1),
114114
() {
115-
controller.add('00:00 +0: All tests passed!');
115+
controller.add('🎉 10 tests passed');
116116
completer.complete(0);
117117
controller.close();
118118
},
@@ -124,11 +124,11 @@ void main() {
124124
expect(error, isNull);
125125
});
126126

127-
test('correctly parses log "Some tests failed"', () async {
127+
test('correctly parses log when tests failed', () async {
128128
Future<void>.delayed(
129129
const Duration(seconds: 1),
130130
() {
131-
controller.add('00:00 +0 -1: Some tests failed');
131+
controller.add('::error::8 tests passed, 2 failed.');
132132
completer.complete(0);
133133
controller.close();
134134
},

0 commit comments

Comments
 (0)