mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
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:
parent
a97a9b33fc
commit
0287c22564
@ -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,
|
||||
|
@ -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)
|
||||
|
@ -189,29 +189,6 @@ dev_dependencies:
|
||||
ProcessManager: () => FakeProcessManager.any(),
|
||||
});
|
||||
|
||||
testUsingContext('Pipes test-randomize-ordering-seed to package:test',
|
||||
() async {
|
||||
final FakePackageTest fakePackageTest = FakePackageTest();
|
||||
|
||||
final TestCommand testCommand = TestCommand(testWrapper: fakePackageTest);
|
||||
final CommandRunner<void> commandRunner =
|
||||
createTestCommandRunner(testCommand);
|
||||
|
||||
await commandRunner.run(const <String>[
|
||||
'test',
|
||||
'--test-randomize-ordering-seed=random',
|
||||
'--no-pub',
|
||||
]);
|
||||
expect(
|
||||
fakePackageTest.lastArgs,
|
||||
contains('--test-randomize-ordering-seed=random'),
|
||||
);
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => fs,
|
||||
ProcessManager: () => FakeProcessManager.any(),
|
||||
Cache: () => Cache.test(processManager: FakeProcessManager.any()),
|
||||
});
|
||||
|
||||
testUsingContext(
|
||||
'Confirmation that the reporter, timeout, and concurrency args are not set by default',
|
||||
() async {
|
||||
@ -492,54 +469,26 @@ dev_dependencies:
|
||||
ProcessManager: () => FakeProcessManager.any(),
|
||||
});
|
||||
|
||||
testUsingContext('Pipes start-paused to package:test',
|
||||
() async {
|
||||
final FakePackageTest fakePackageTest = FakePackageTest();
|
||||
group('Pipes to package:test', () {
|
||||
Future<void> expectPassesArgument(String value, [String? passValue]) async {
|
||||
final FakePackageTest fakePackageTest = FakePackageTest();
|
||||
final TestCommand testCommand = TestCommand(testWrapper: fakePackageTest);
|
||||
final CommandRunner<void> commandRunner = createTestCommandRunner(testCommand);
|
||||
|
||||
final TestCommand testCommand = TestCommand(testWrapper: fakePackageTest);
|
||||
final CommandRunner<void> commandRunner =
|
||||
createTestCommandRunner(testCommand);
|
||||
await commandRunner.run(<String>['test', '--no-pub', value]);
|
||||
expect(fakePackageTest.lastArgs, contains(passValue ?? value));
|
||||
}
|
||||
|
||||
await commandRunner.run(const <String>[
|
||||
'test',
|
||||
'--no-pub',
|
||||
'--start-paused',
|
||||
'--',
|
||||
'test/fake_test.dart',
|
||||
]);
|
||||
expect(
|
||||
fakePackageTest.lastArgs,
|
||||
contains('--pause-after-load'),
|
||||
);
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => fs,
|
||||
ProcessManager: () => FakeProcessManager.any(),
|
||||
Cache: () => Cache.test(processManager: FakeProcessManager.any()),
|
||||
});
|
||||
|
||||
testUsingContext('Pipes run-skipped to package:test',
|
||||
() async {
|
||||
final FakePackageTest fakePackageTest = FakePackageTest();
|
||||
|
||||
final TestCommand testCommand = TestCommand(testWrapper: fakePackageTest);
|
||||
final CommandRunner<void> commandRunner =
|
||||
createTestCommandRunner(testCommand);
|
||||
|
||||
await commandRunner.run(const <String>[
|
||||
'test',
|
||||
'--no-pub',
|
||||
'--run-skipped',
|
||||
'--',
|
||||
'test/fake_test.dart',
|
||||
]);
|
||||
expect(
|
||||
fakePackageTest.lastArgs,
|
||||
contains('--run-skipped'),
|
||||
);
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => fs,
|
||||
ProcessManager: () => FakeProcessManager.any(),
|
||||
Cache: () => Cache.test(processManager: FakeProcessManager.any()),
|
||||
testUsingContext('passes various CLI options through to package:test', () async {
|
||||
await expectPassesArgument('--start-paused', '--pause-after-load');
|
||||
await expectPassesArgument('--fail-fast');
|
||||
await expectPassesArgument('--run-skipped');
|
||||
await expectPassesArgument('--test-randomize-ordering-seed=random');
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => fs,
|
||||
ProcessManager: () => FakeProcessManager.any(),
|
||||
Cache: () => Cache.test(processManager: FakeProcessManager.any()),
|
||||
});
|
||||
});
|
||||
|
||||
testUsingContext('Pipes enable-vmService', () async {
|
||||
@ -674,6 +623,7 @@ dev_dependencies:
|
||||
'--test-randomize-ordering-seed=random',
|
||||
'--tags=tag1',
|
||||
'--exclude-tags=tag2',
|
||||
'--fail-fast',
|
||||
'--run-skipped',
|
||||
'--total-shards=1',
|
||||
'--shard-index=1',
|
||||
@ -715,6 +665,7 @@ const List<String> packageTestArgs = <String>[
|
||||
'tag1',
|
||||
'--exclude-tags',
|
||||
'tag2',
|
||||
'--fail-fast',
|
||||
'--run-skipped',
|
||||
'--total-shards=1',
|
||||
'--shard-index=1',
|
||||
@ -1466,6 +1417,7 @@ class FakeFlutterTestRunner implements FlutterTestRunner {
|
||||
String? reporter,
|
||||
String? fileReporter,
|
||||
String? timeout,
|
||||
bool failFast = false,
|
||||
bool runSkipped = false,
|
||||
int? shardIndex,
|
||||
int? totalShards,
|
||||
@ -1513,6 +1465,7 @@ class FakeFlutterTestRunner implements FlutterTestRunner {
|
||||
String? reporter,
|
||||
String? fileReporter,
|
||||
String? timeout,
|
||||
bool failFast = false,
|
||||
bool runSkipped = false,
|
||||
int? shardIndex,
|
||||
int? totalShards,
|
||||
|
Loading…
Reference in New Issue
Block a user