Include stdout/stderr in failure messages for devicelab's tests (#18990)
* Include stdout/stderr in failure messages Sometimes some of these tests unexpectedly fail with a non-zero exit code. This ensures stdout/stderr is included in the test failure message when this happens so that we can track down the issue. * Remove redundant info about exit code * Remove unnecessary indenting The [markers] make it fairly clear so this just makes the test code noisy.
This commit is contained in:
parent
9cb3cd4cb0
commit
0329f0c179
@ -13,7 +13,7 @@ void main() {
|
||||
const ProcessManager processManager = const LocalProcessManager();
|
||||
|
||||
group('run.dart script', () {
|
||||
Future<int> runScript(List<String> testNames) async {
|
||||
Future<ProcessResult> runScript(List<String> testNames) async {
|
||||
final List<String> options = <String>['bin/run.dart'];
|
||||
for (String testName in testNames) {
|
||||
options..addAll(<String>['-t', testName]);
|
||||
@ -22,39 +22,45 @@ void main() {
|
||||
final ProcessResult scriptProcess = processManager.runSync(
|
||||
<String>[dart]..addAll(options)
|
||||
);
|
||||
return scriptProcess.exitCode;
|
||||
return scriptProcess;
|
||||
}
|
||||
|
||||
Future<void> expectScriptResult(List<String> testNames, int expectedExitCode) async {
|
||||
final ProcessResult result = await runScript(testNames);
|
||||
expect(result.exitCode, expectedExitCode,
|
||||
reason: '[ stderr from test process ]\n\n${result.stderr}\n\n[ end of stderr ]'
|
||||
'\n\n[ stdout from test process ]\n\n${result.stdout}\n\n[ end of stdout ]');
|
||||
}
|
||||
|
||||
test('exits with code 0 when succeeds', () async {
|
||||
expect(await runScript(<String>['smoke_test_success']), 0);
|
||||
await expectScriptResult(<String>['smoke_test_success'], 0);
|
||||
});
|
||||
|
||||
test('accepts file paths', () async {
|
||||
expect(await runScript(<String>['bin/tasks/smoke_test_success.dart']), 0);
|
||||
await expectScriptResult(<String>['bin/tasks/smoke_test_success.dart'], 0);
|
||||
});
|
||||
|
||||
test('rejects invalid file paths', () async {
|
||||
expect(await runScript(<String>['lib/framework/adb.dart']), 1);
|
||||
await expectScriptResult(<String>['lib/framework/adb.dart'], 1);
|
||||
});
|
||||
|
||||
test('exits with code 1 when task throws', () async {
|
||||
expect(await runScript(<String>['smoke_test_throws']), 1);
|
||||
await expectScriptResult(<String>['smoke_test_throws'], 1);
|
||||
});
|
||||
|
||||
test('exits with code 1 when fails', () async {
|
||||
expect(await runScript(<String>['smoke_test_failure']), 1);
|
||||
await expectScriptResult(<String>['smoke_test_failure'], 1);
|
||||
});
|
||||
|
||||
test('exits with code 1 when fails to connect', () async {
|
||||
expect(await runScript(<String>['smoke_test_setup_failure']), 1);
|
||||
await expectScriptResult(<String>['smoke_test_setup_failure'], 1);
|
||||
}, skip: true); // https://github.com/flutter/flutter/issues/5901
|
||||
|
||||
test('exits with code 1 when results are mixed', () async {
|
||||
expect(
|
||||
await runScript(<String>[
|
||||
await expectScriptResult(<String>[
|
||||
'smoke_test_failure',
|
||||
'smoke_test_success',
|
||||
]),
|
||||
],
|
||||
1,
|
||||
);
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user