Commit 74af8554 authored by xster's avatar xster Committed by Flutter GitHub Bot

Fix run_release_test flakiness (#45417)

parent a82a3997
...@@ -38,7 +38,11 @@ void main() { ...@@ -38,7 +38,11 @@ void main() {
!line.startsWith('Running "flutter pub get" in ui...') && !line.startsWith('Running "flutter pub get" in ui...') &&
!line.startsWith('Initializing gradle...') && !line.startsWith('Initializing gradle...') &&
!line.contains('settings_aar.gradle') && !line.contains('settings_aar.gradle') &&
!line.startsWith('Resolving dependencies...') !line.startsWith('Resolving dependencies...') &&
// Catch engine piped output from unrelated concurrent Flutter apps
!line.contains(RegExp(r'[A-Z]\/flutter \([0-9]+\):')) &&
// Empty lines could be due to the progress spinner breaking up.
line.length > 1
) { ) {
stdout.add(line); stdout.add(line);
} }
...@@ -65,26 +69,70 @@ void main() { ...@@ -65,26 +69,70 @@ void main() {
if (stderr.isNotEmpty) { if (stderr.isNotEmpty) {
throw 'flutter run --release had output on standard error.'; throw 'flutter run --release had output on standard error.';
} }
if (!(stdout.first.startsWith('Launching lib/main.dart on ') && stdout.first.endsWith(' in release mode...'))){
throw 'flutter run --release had unexpected first line: ${stdout.first}'; _findNextMatcherInList(
} stdout,
stdout.removeAt(0); (String line) => line.startsWith('Launching lib/main.dart on ') && line.endsWith(' in release mode...'),
if (!stdout.first.startsWith('Running Gradle task \'assembleRelease\'...')) { 'Launching lib/main.dart on',
throw 'flutter run --release had unexpected second line: ${stdout.first}'; );
}
stdout.removeAt(0); _findNextMatcherInList(
if (!(stdout.first.contains('Built build/app/outputs/apk/release/app-release.apk (') && stdout.first.contains('MB).'))) { stdout,
throw 'flutter run --release had unexpected third line: ${stdout.first}'; (String line) => line.startsWith('Running Gradle task \'assembleRelease\'...'),
} 'Running Gradle task \'assembleRelease\'...',
stdout.removeAt(0); );
if (stdout.first.startsWith('Installing build/app/outputs/apk/app.apk...')) {
stdout.removeAt(0); _findNextMatcherInList(
} stdout,
if (stdout.join('\n') != '\nTo quit, press "q".\n\nApplication finished.') { (String line) => line.contains('Built build/app/outputs/apk/release/app-release.apk (') && line.contains('MB).'),
throw 'flutter run --release had unexpected output after third line:\n' 'Built build/app/outputs/apk/release/app-release.apk',
'${stdout.join('\n')}'; );
}
_findNextMatcherInList(
stdout,
(String line) => line.startsWith('Installing build/app/outputs/apk/app.apk...'),
'Installing build/app/outputs/apk/app.apk...',
);
_findNextMatcherInList(
stdout,
(String line) => line == 'To quit, press "q".',
'To quit, press "q".',
);
_findNextMatcherInList(
stdout,
(String line) => line == 'Application finished.',
'Application finished.',
);
}); });
return TaskResult.success(null); return TaskResult.success(null);
}); });
} }
void _findNextMatcherInList(
List<String> list,
bool Function(String testLine) matcher,
String errorMessageExpectedLine
) {
final List<String> copyOfListForErrorMessage = List<String>.from(list);
while (list.isNotEmpty) {
final String nextLine = list.first;
list.removeAt(0);
if (matcher(nextLine)) {
return;
}
}
throw '''
Did not find expected line
$errorMessageExpectedLine
in flutter run --release stdout
$copyOfListForErrorMessage
''';
}
...@@ -220,6 +220,7 @@ tasks: ...@@ -220,6 +220,7 @@ tasks:
Checks that `flutter run --release` does not crash. Checks that `flutter run --release` does not crash.
stage: devicelab stage: devicelab
required_agent_capabilities: ["mac/android"] required_agent_capabilities: ["mac/android"]
flaky: true # https://github.com/flutter/flutter/issues/45416.
platform_interaction_test: platform_interaction_test:
description: > description: >
......
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