From d87a779c005f5661656e70349d72dc1bb75fe70f Mon Sep 17 00:00:00 2001 From: Swift Kim Date: Mon, 12 Dec 2022 14:09:23 +0900 Subject: [PATCH] Run integration test once again on unexpected failure --- tools/lib/src/device.dart | 22 +++++++++++++-------- tools/lib/src/integration_test_command.dart | 11 +++++++---- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/tools/lib/src/device.dart b/tools/lib/src/device.dart index 32a14f3b5..4d7b3dc84 100644 --- a/tools/lib/src/device.dart +++ b/tools/lib/src/device.dart @@ -127,8 +127,9 @@ class Device { /// nor [PackageResult.exclude]. Future runIntegrationTest( Directory workingDir, - Duration timeout, - ) async { + Duration timeout, { + bool debug = false, + }) async { if (!isConnected) { return PackageResult.fail( ['Device $name ($profile) is not connected.']); @@ -136,7 +137,13 @@ class Device { final io.Process process = await _processRunner.start( 'flutter-tizen', - ['-d', serial!, 'test', 'integration_test'], + [ + if (debug) '-v', + '-d', + serial!, + 'test', + 'integration_test', + ], workingDirectory: workingDir, ); @@ -393,11 +400,11 @@ class EmulatorDevice extends Device { @override Future runIntegrationTest( Directory workingDir, - Duration timeout, - ) async { + Duration timeout, { + bool debug = false, + }) async { bool autoLaunched = false; bool autoCreated = false; - late final PackageResult result; try { if (!exists) { autoCreated = true; @@ -408,7 +415,7 @@ class EmulatorDevice extends Device { await launch(); } _disablePermissionPopups(); - result = await super.runIntegrationTest(workingDir, timeout); + return await super.runIntegrationTest(workingDir, timeout, debug: debug); } finally { if (autoLaunched) { await close(); @@ -417,6 +424,5 @@ class EmulatorDevice extends Device { await delete(); } } - return result; } } diff --git a/tools/lib/src/integration_test_command.dart b/tools/lib/src/integration_test_command.dart index 73e81f80d..da885b481 100644 --- a/tools/lib/src/integration_test_command.dart +++ b/tools/lib/src/integration_test_command.dart @@ -224,10 +224,13 @@ class IntegrationTestCommand extends PackageLoopingCommand { } for (final Device device in devices) { - final PackageResult packageResult = await device.runIntegrationTest( - example.directory, - _timeout, - ); + PackageResult packageResult = + await device.runIntegrationTest(example.directory, _timeout); + if (packageResult.state == RunState.failed) { + // Tests may fail unexpectedly on a self-hosted runner. Try again. + packageResult = await device + .runIntegrationTest(example.directory, _timeout, debug: true); + } if (packageResult.state == RunState.failed) { errors.addAll(packageResult.details); }