From 445e02dd631aa9e9665e58d9fc4133950d199efd Mon Sep 17 00:00:00 2001 From: Andrew Kolos Date: Thu, 7 Sep 2023 12:36:55 -0700 Subject: [PATCH] fix `--exit` flag in dev/devicelab/bin/run.dart (#134162) Fixes #134154 This PR also changes the default value of the `--exit` flag from `true` to `false`. Effectively, this is not a change in behavior since `--exit` didn't previously work. --- dev/devicelab/bin/run.dart | 1 - dev/devicelab/lib/framework/runner.dart | 15 +++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/dev/devicelab/bin/run.dart b/dev/devicelab/bin/run.dart index a666e1aa48f..e90ffe36bb0 100644 --- a/dev/devicelab/bin/run.dart +++ b/dev/devicelab/bin/run.dart @@ -293,7 +293,6 @@ ArgParser createArgParser(List taskNames) { ) ..addFlag( 'exit', - defaultsTo: true, help: 'Exit on the first test failure. Currently flakes are intentionally (though ' 'incorrectly) not considered to be failures.', ) diff --git a/dev/devicelab/lib/framework/runner.dart b/dev/devicelab/lib/framework/runner.dart index 5f11b4ffc76..39d0015db5e 100644 --- a/dev/devicelab/lib/framework/runner.dart +++ b/dev/devicelab/lib/framework/runner.dart @@ -47,8 +47,8 @@ Future runTasks( }) async { for (final String taskName in taskNames) { TaskResult result = TaskResult.success(null); - int retry = 0; - while (retry <= Cocoon.retryNumber) { + int failureCount = 0; + while (failureCount <= Cocoon.retryNumber) { result = await rerunTask( taskName, deviceId: deviceId, @@ -66,11 +66,14 @@ Future runTasks( ); if (!result.succeeded) { - retry += 1; + failureCount += 1; + if (exitOnFirstTestFailure) { + break; + } } else { section('Flaky status for "$taskName"'); - if (retry > 0) { - print('Total ${retry+1} executions: $retry failures and 1 false positive.'); + if (failureCount > 0) { + print('Total ${failureCount+1} executions: $failureCount failures and 1 false positive.'); print('flaky: true'); // TODO(ianh): stop ignoring this failure. We should set exitCode=1, and quit // if exitOnFirstTestFailure is true. @@ -84,7 +87,7 @@ Future runTasks( if (!result.succeeded) { section('Flaky status for "$taskName"'); - print('Consistently failed across all $retry executions.'); + print('Consistently failed across all $failureCount executions.'); print('flaky: false'); exitCode = 1; if (exitOnFirstTestFailure) {