Skip to content

Commit 70cd54c

Browse files
Add --ignore-timeouts flag for flutter test command (#164437)
As in #105913 described, running integration tests of your app often times out. The issue for this is that the `test` package has their own timeout for loading the test suite: https://github.com/dart-lang/test/blob/db8cf091506a67eba1e523215e0e49a0db7cd1fd/pkgs/test_core/lib/src/runner/load_suite.dart#L23-L29 This timeout is not configurable. However, you can bypass this timeout using `--ignore-timeouts` when running `dart test`. This PR adds the `--ignore-timeouts` flag to the `flutter test` command and passes it to the `test` package. Adding the flag would be the easiest fix for #105913. I will later add documentation to the integration test docs, that passing this flag will fix the timeout issue. Otherwise, we would need to make the load test suite timeout configurable in the `test` package and then somehow set it in the `flutter test` command. Fixes #105913 ![Screenshot 2025-03-02 at 00 08 59](https://github.com/user-attachments/assets/af84efe3-2174-4531-919f-bffdf1500430) A screenshot of running `flutter test integration_test --ignore-timeouts` which surpasses the previous timeout of 12 minutes. ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
1 parent 80a33f4 commit 70cd54c

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

packages/flutter_tools/lib/src/commands/test.dart

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -273,10 +273,19 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
273273
..addOption(
274274
'timeout',
275275
help:
276-
'The default test timeout, specified either '
277-
'in seconds (e.g. "60s"), '
278-
'as a multiplier of the default timeout (e.g. "2x"), '
279-
'or as the string "none" to disable the timeout entirely.',
276+
'The default timeout for individual tests, specified either in '
277+
'seconds (e.g. "60s"), as a multiplier of the default test timeout '
278+
'(e.g. "2x"), or as the string "none" to disable test timeouts '
279+
'entirely. This value does not apply to the default test suite '
280+
'loading timeout.',
281+
)
282+
..addFlag(
283+
'ignore-timeouts',
284+
help:
285+
'Ignore all timeouts. Useful when testing a big application '
286+
'that requires a longer time to compile (e.g. running integration '
287+
'tests for a Flutter app).',
288+
negatable: false,
280289
)
281290
..addFlag(
282291
FlutterOptions.kWebWasmFlag,
@@ -647,6 +656,7 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
647656
reporter: stringArg('reporter'),
648657
fileReporter: stringArg('file-reporter'),
649658
timeout: stringArg('timeout'),
659+
ignoreTimeouts: boolArg('ignore-timeouts'),
650660
failFast: boolArg('fail-fast'),
651661
runSkipped: boolArg('run-skipped'),
652662
shardIndex: shardIndex,
@@ -675,6 +685,7 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
675685
reporter: stringArg('reporter'),
676686
fileReporter: stringArg('file-reporter'),
677687
timeout: stringArg('timeout'),
688+
ignoreTimeouts: boolArg('ignore-timeouts'),
678689
failFast: boolArg('fail-fast'),
679690
runSkipped: boolArg('run-skipped'),
680691
shardIndex: shardIndex,

packages/flutter_tools/lib/src/test/runner.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ interface class FlutterTestRunner {
5555
String? reporter,
5656
String? fileReporter,
5757
String? timeout,
58+
bool ignoreTimeouts = false,
5859
bool failFast = false,
5960
bool runSkipped = false,
6061
int? shardIndex,
@@ -75,6 +76,7 @@ interface class FlutterTestRunner {
7576
if (machine) ...<String>['-r', 'json'] else if (reporter != null) ...<String>['-r', reporter],
7677
if (fileReporter != null) '--file-reporter=$fileReporter',
7778
if (timeout != null) ...<String>['--timeout', timeout],
79+
if (ignoreTimeouts) '--ignore-timeouts',
7880
if (concurrency != null) '--concurrency=$concurrency',
7981
for (final String name in names) ...<String>['--name', name],
8082
for (final String plainName in plainNames) ...<String>['--plain-name', plainName],
@@ -588,6 +590,7 @@ class SpawnPlugin extends PlatformPlugin {
588590
String? reporter,
589591
String? fileReporter,
590592
String? timeout,
593+
bool ignoreTimeouts = false,
591594
bool failFast = false,
592595
bool runSkipped = false,
593596
int? shardIndex,
@@ -637,6 +640,7 @@ class SpawnPlugin extends PlatformPlugin {
637640
if (machine) ...<String>['-r', 'json'] else if (reporter != null) ...<String>['-r', reporter],
638641
if (fileReporter != null) '--file-reporter=$fileReporter',
639642
if (timeout != null) ...<String>['--timeout', timeout],
643+
if (ignoreTimeouts) '--ignore-timeouts',
640644
if (concurrency != null) '--concurrency=$concurrency',
641645
for (final String name in names) ...<String>['--name', name],
642646
for (final String plainName in plainNames) ...<String>['--plain-name', plainName],

packages/flutter_tools/test/commands.shard/hermetic/test_test.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ dev_dependencies:
157157
expect(fakePackageTest.lastArgs, isNot(contains('compact')));
158158
expect(fakePackageTest.lastArgs, isNot(contains('--timeout')));
159159
expect(fakePackageTest.lastArgs, isNot(contains('30s')));
160+
expect(fakePackageTest.lastArgs, isNot(contains('--ignore-timeouts')));
160161
expect(fakePackageTest.lastArgs, isNot(contains('--concurrency')));
161162
},
162163
overrides: <Type, Generator>{
@@ -583,6 +584,7 @@ dev_dependencies:
583584
'--reporter=compact',
584585
'--file-reporter=json:reports/tests.json',
585586
'--timeout=100',
587+
'--ignore-timeouts',
586588
'--concurrency=3',
587589
'--name=name1',
588590
'--plain-name=name2',
@@ -616,6 +618,7 @@ const List<String> packageTestArgs = <String>[
616618
'--file-reporter=json:reports/tests.json',
617619
'--timeout',
618620
'100',
621+
'--ignore-timeouts',
619622
'--concurrency=3',
620623
'--name',
621624
'name1',
@@ -1562,6 +1565,7 @@ class FakeFlutterTestRunner implements FlutterTestRunner {
15621565
String? reporter,
15631566
String? fileReporter,
15641567
String? timeout,
1568+
bool ignoreTimeouts = false,
15651569
bool failFast = false,
15661570
bool runSkipped = false,
15671571
int? shardIndex,
@@ -1611,6 +1615,7 @@ class FakeFlutterTestRunner implements FlutterTestRunner {
16111615
String? reporter,
16121616
String? fileReporter,
16131617
String? timeout,
1618+
bool ignoreTimeouts = false,
16141619
bool failFast = false,
16151620
bool runSkipped = false,
16161621
int? shardIndex,

0 commit comments

Comments
 (0)