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 '
|
'Instructions for connecting with a debugger are printed to the '
|
||||||
'console once the test has started.',
|
'console once the test has started.',
|
||||||
)
|
)
|
||||||
|
..addFlag('fail-fast',
|
||||||
|
help: 'Stop running tests after the first failure.',
|
||||||
|
)
|
||||||
..addFlag('run-skipped',
|
..addFlag('run-skipped',
|
||||||
help: 'Run skipped tests instead of skipping them.',
|
help: 'Run skipped tests instead of skipping them.',
|
||||||
)
|
)
|
||||||
@ -578,6 +581,7 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
|
|||||||
reporter: stringArg('reporter'),
|
reporter: stringArg('reporter'),
|
||||||
fileReporter: stringArg('file-reporter'),
|
fileReporter: stringArg('file-reporter'),
|
||||||
timeout: stringArg('timeout'),
|
timeout: stringArg('timeout'),
|
||||||
|
failFast: boolArg('fail-fast'),
|
||||||
runSkipped: boolArg('run-skipped'),
|
runSkipped: boolArg('run-skipped'),
|
||||||
shardIndex: shardIndex,
|
shardIndex: shardIndex,
|
||||||
totalShards: totalShards,
|
totalShards: totalShards,
|
||||||
@ -605,6 +609,7 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
|
|||||||
reporter: stringArg('reporter'),
|
reporter: stringArg('reporter'),
|
||||||
fileReporter: stringArg('file-reporter'),
|
fileReporter: stringArg('file-reporter'),
|
||||||
timeout: stringArg('timeout'),
|
timeout: stringArg('timeout'),
|
||||||
|
failFast: boolArg('fail-fast'),
|
||||||
runSkipped: boolArg('run-skipped'),
|
runSkipped: boolArg('run-skipped'),
|
||||||
shardIndex: shardIndex,
|
shardIndex: shardIndex,
|
||||||
totalShards: totalShards,
|
totalShards: totalShards,
|
||||||
|
@ -56,6 +56,7 @@ abstract class FlutterTestRunner {
|
|||||||
String? reporter,
|
String? reporter,
|
||||||
String? fileReporter,
|
String? fileReporter,
|
||||||
String? timeout,
|
String? timeout,
|
||||||
|
bool failFast = false,
|
||||||
bool runSkipped = false,
|
bool runSkipped = false,
|
||||||
int? shardIndex,
|
int? shardIndex,
|
||||||
int? totalShards,
|
int? totalShards,
|
||||||
@ -84,6 +85,7 @@ abstract class FlutterTestRunner {
|
|||||||
String? reporter,
|
String? reporter,
|
||||||
String? fileReporter,
|
String? fileReporter,
|
||||||
String? timeout,
|
String? timeout,
|
||||||
|
bool failFast = false,
|
||||||
bool runSkipped = false,
|
bool runSkipped = false,
|
||||||
int? shardIndex,
|
int? shardIndex,
|
||||||
int? totalShards,
|
int? totalShards,
|
||||||
@ -121,6 +123,7 @@ class _FlutterTestRunnerImpl implements FlutterTestRunner {
|
|||||||
String? reporter,
|
String? reporter,
|
||||||
String? fileReporter,
|
String? fileReporter,
|
||||||
String? timeout,
|
String? timeout,
|
||||||
|
bool failFast = false,
|
||||||
bool runSkipped = false,
|
bool runSkipped = false,
|
||||||
int? shardIndex,
|
int? shardIndex,
|
||||||
int? totalShards,
|
int? totalShards,
|
||||||
@ -158,6 +161,8 @@ class _FlutterTestRunnerImpl implements FlutterTestRunner {
|
|||||||
...<String>['--tags', tags],
|
...<String>['--tags', tags],
|
||||||
if (excludeTags != null)
|
if (excludeTags != null)
|
||||||
...<String>['--exclude-tags', excludeTags],
|
...<String>['--exclude-tags', excludeTags],
|
||||||
|
if (failFast)
|
||||||
|
'--fail-fast',
|
||||||
if (runSkipped)
|
if (runSkipped)
|
||||||
'--run-skipped',
|
'--run-skipped',
|
||||||
if (totalShards != null)
|
if (totalShards != null)
|
||||||
@ -665,6 +670,7 @@ class SpawnPlugin extends PlatformPlugin {
|
|||||||
String? reporter,
|
String? reporter,
|
||||||
String? fileReporter,
|
String? fileReporter,
|
||||||
String? timeout,
|
String? timeout,
|
||||||
|
bool failFast = false,
|
||||||
bool runSkipped = false,
|
bool runSkipped = false,
|
||||||
int? shardIndex,
|
int? shardIndex,
|
||||||
int? totalShards,
|
int? totalShards,
|
||||||
@ -734,6 +740,8 @@ class SpawnPlugin extends PlatformPlugin {
|
|||||||
...<String>['--tags', tags],
|
...<String>['--tags', tags],
|
||||||
if (excludeTags != null)
|
if (excludeTags != null)
|
||||||
...<String>['--exclude-tags', excludeTags],
|
...<String>['--exclude-tags', excludeTags],
|
||||||
|
if (failFast)
|
||||||
|
'--fail-fast',
|
||||||
if (runSkipped)
|
if (runSkipped)
|
||||||
'--run-skipped',
|
'--run-skipped',
|
||||||
if (totalShards != null)
|
if (totalShards != null)
|
||||||
|
@ -189,29 +189,6 @@ dev_dependencies:
|
|||||||
ProcessManager: () => FakeProcessManager.any(),
|
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(
|
testUsingContext(
|
||||||
'Confirmation that the reporter, timeout, and concurrency args are not set by default',
|
'Confirmation that the reporter, timeout, and concurrency args are not set by default',
|
||||||
() async {
|
() async {
|
||||||
@ -492,54 +469,26 @@ dev_dependencies:
|
|||||||
ProcessManager: () => FakeProcessManager.any(),
|
ProcessManager: () => FakeProcessManager.any(),
|
||||||
});
|
});
|
||||||
|
|
||||||
testUsingContext('Pipes start-paused to package:test',
|
group('Pipes to package:test', () {
|
||||||
() async {
|
Future<void> expectPassesArgument(String value, [String? passValue]) async {
|
||||||
final FakePackageTest fakePackageTest = FakePackageTest();
|
final FakePackageTest fakePackageTest = FakePackageTest();
|
||||||
|
final TestCommand testCommand = TestCommand(testWrapper: fakePackageTest);
|
||||||
|
final CommandRunner<void> commandRunner = createTestCommandRunner(testCommand);
|
||||||
|
|
||||||
final TestCommand testCommand = TestCommand(testWrapper: fakePackageTest);
|
await commandRunner.run(<String>['test', '--no-pub', value]);
|
||||||
final CommandRunner<void> commandRunner =
|
expect(fakePackageTest.lastArgs, contains(passValue ?? value));
|
||||||
createTestCommandRunner(testCommand);
|
}
|
||||||
|
|
||||||
await commandRunner.run(const <String>[
|
testUsingContext('passes various CLI options through to package:test', () async {
|
||||||
'test',
|
await expectPassesArgument('--start-paused', '--pause-after-load');
|
||||||
'--no-pub',
|
await expectPassesArgument('--fail-fast');
|
||||||
'--start-paused',
|
await expectPassesArgument('--run-skipped');
|
||||||
'--',
|
await expectPassesArgument('--test-randomize-ordering-seed=random');
|
||||||
'test/fake_test.dart',
|
}, overrides: <Type, Generator>{
|
||||||
]);
|
FileSystem: () => fs,
|
||||||
expect(
|
ProcessManager: () => FakeProcessManager.any(),
|
||||||
fakePackageTest.lastArgs,
|
Cache: () => Cache.test(processManager: FakeProcessManager.any()),
|
||||||
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('Pipes enable-vmService', () async {
|
testUsingContext('Pipes enable-vmService', () async {
|
||||||
@ -674,6 +623,7 @@ dev_dependencies:
|
|||||||
'--test-randomize-ordering-seed=random',
|
'--test-randomize-ordering-seed=random',
|
||||||
'--tags=tag1',
|
'--tags=tag1',
|
||||||
'--exclude-tags=tag2',
|
'--exclude-tags=tag2',
|
||||||
|
'--fail-fast',
|
||||||
'--run-skipped',
|
'--run-skipped',
|
||||||
'--total-shards=1',
|
'--total-shards=1',
|
||||||
'--shard-index=1',
|
'--shard-index=1',
|
||||||
@ -715,6 +665,7 @@ const List<String> packageTestArgs = <String>[
|
|||||||
'tag1',
|
'tag1',
|
||||||
'--exclude-tags',
|
'--exclude-tags',
|
||||||
'tag2',
|
'tag2',
|
||||||
|
'--fail-fast',
|
||||||
'--run-skipped',
|
'--run-skipped',
|
||||||
'--total-shards=1',
|
'--total-shards=1',
|
||||||
'--shard-index=1',
|
'--shard-index=1',
|
||||||
@ -1466,6 +1417,7 @@ class FakeFlutterTestRunner implements FlutterTestRunner {
|
|||||||
String? reporter,
|
String? reporter,
|
||||||
String? fileReporter,
|
String? fileReporter,
|
||||||
String? timeout,
|
String? timeout,
|
||||||
|
bool failFast = false,
|
||||||
bool runSkipped = false,
|
bool runSkipped = false,
|
||||||
int? shardIndex,
|
int? shardIndex,
|
||||||
int? totalShards,
|
int? totalShards,
|
||||||
@ -1513,6 +1465,7 @@ class FakeFlutterTestRunner implements FlutterTestRunner {
|
|||||||
String? reporter,
|
String? reporter,
|
||||||
String? fileReporter,
|
String? fileReporter,
|
||||||
String? timeout,
|
String? timeout,
|
||||||
|
bool failFast = false,
|
||||||
bool runSkipped = false,
|
bool runSkipped = false,
|
||||||
int? shardIndex,
|
int? shardIndex,
|
||||||
int? totalShards,
|
int? totalShards,
|
||||||
|
Loading…
Reference in New Issue
Block a user