Add 'fail-fast' argument to flutter test (#149587)

This adds the 'fail-fast' argument to flutter test, since dart test already supports this feature. Tests can now be stopped after first failure. 

Fixes #124406
This commit is contained in:
Lexycon
2024-06-17 23:06:07 +01:00
committed by GitHub
parent a97a9b33fc
commit 0287c22564
3 changed files with 35 additions and 69 deletions

View File

@@ -111,6 +111,9 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
'Instructions for connecting with a debugger are printed to the '
'console once the test has started.',
)
..addFlag('fail-fast',
help: 'Stop running tests after the first failure.',
)
..addFlag('run-skipped',
help: 'Run skipped tests instead of skipping them.',
)
@@ -578,6 +581,7 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
reporter: stringArg('reporter'),
fileReporter: stringArg('file-reporter'),
timeout: stringArg('timeout'),
failFast: boolArg('fail-fast'),
runSkipped: boolArg('run-skipped'),
shardIndex: shardIndex,
totalShards: totalShards,
@@ -605,6 +609,7 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
reporter: stringArg('reporter'),
fileReporter: stringArg('file-reporter'),
timeout: stringArg('timeout'),
failFast: boolArg('fail-fast'),
runSkipped: boolArg('run-skipped'),
shardIndex: shardIndex,
totalShards: totalShards,

View File

@@ -56,6 +56,7 @@ abstract class FlutterTestRunner {
String? reporter,
String? fileReporter,
String? timeout,
bool failFast = false,
bool runSkipped = false,
int? shardIndex,
int? totalShards,
@@ -84,6 +85,7 @@ abstract class FlutterTestRunner {
String? reporter,
String? fileReporter,
String? timeout,
bool failFast = false,
bool runSkipped = false,
int? shardIndex,
int? totalShards,
@@ -121,6 +123,7 @@ class _FlutterTestRunnerImpl implements FlutterTestRunner {
String? reporter,
String? fileReporter,
String? timeout,
bool failFast = false,
bool runSkipped = false,
int? shardIndex,
int? totalShards,
@@ -158,6 +161,8 @@ class _FlutterTestRunnerImpl implements FlutterTestRunner {
...<String>['--tags', tags],
if (excludeTags != null)
...<String>['--exclude-tags', excludeTags],
if (failFast)
'--fail-fast',
if (runSkipped)
'--run-skipped',
if (totalShards != null)
@@ -665,6 +670,7 @@ class SpawnPlugin extends PlatformPlugin {
String? reporter,
String? fileReporter,
String? timeout,
bool failFast = false,
bool runSkipped = false,
int? shardIndex,
int? totalShards,
@@ -734,6 +740,8 @@ class SpawnPlugin extends PlatformPlugin {
...<String>['--tags', tags],
if (excludeTags != null)
...<String>['--exclude-tags', excludeTags],
if (failFast)
'--fail-fast',
if (runSkipped)
'--run-skipped',
if (totalShards != null)