Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Capture FAILURES!!! when running Android scenario_app tests. #50255

Merged
Merged
2 changes: 2 additions & 0 deletions .ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ targets:
- DEPS
- lib/ui/**
- shell/platform/android/**
- testing/scenario_app/**

# Task to run Linux linux_android_emulator_tests on AVDs running Android 33
# instead of 34 for investigating https://github.com/flutter/flutter/issues/137947.
Expand All @@ -74,6 +75,7 @@ targets:
- DEPS
- lib/ui/**
- shell/platform/android/**
- testing/scenario_app/**

- name: Linux builder_cache
enabled_branches:
Expand Down
11 changes: 8 additions & 3 deletions testing/scenario_app/bin/android_integration_tests.dart
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,20 @@ void main(List<String> args) async {
});

await step('Running instrumented tests...', () async {
final int exitCode = await pm.runAndForward(<String>[
final (int exitCode, StringBuffer out) = await pm.runAndCapture(<String>[
adb.path,
'shell',
'am',
'instrument',
'-w', 'dev.flutter.scenarios.test/dev.flutter.TestRunner',
'-w',
'dev.flutter.scenarios.test/dev.flutter.TestRunner',
]);
if (exitCode != 0) {
panic(<String>['could not install test apk']);
panic(<String>['instrumented tests failed to run']);
}
if (out.toString().contains('FAILURES!!!')) {
matanlurey marked this conversation as resolved.
Show resolved Hide resolved
stdout.write(out);
panic(<String>['1 or more tests failed']);
}
});
} finally {
Expand Down
1 change: 1 addition & 0 deletions testing/scenario_app/bin/utils/logs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@ void panic(List<String> messages) {
for (final String message in messages) {
stderr.writeln('$_red$message$_reset');
}
exitCode = 1;
throw 'panic';
}
7 changes: 7 additions & 0 deletions testing/scenario_app/bin/utils/process_manager_extension.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,11 @@ extension RunAndForward on ProcessManager {
Future<int> runAndForward(List<String> cmd) async {
return pipeProcessStreams(await start(cmd), out: stdout);
}

/// Runs [cmd], and captures the stdout and stderr pipes.
Future<(int, StringBuffer)> runAndCapture(List<String> cmd) async {
final StringBuffer buffer = StringBuffer();
final int exitCode = await pipeProcessStreams(await start(cmd), out: buffer);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need a try block here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No I don't believe so, it's OK for any errors to bubble up.

return (exitCode, buffer);
}
}