diff --git a/dev/bots/test.dart b/dev/bots/test.dart index 2993ca94ac..111dc3732c 100644 --- a/dev/bots/test.dart +++ b/dev/bots/test.dart @@ -301,6 +301,8 @@ Future _runToolTests() async { forceSingleCore: subshard != 'general', testPaths: [path.join(kTest, '$subshard$kDotShard', suffix)], enableFlutterToolAsserts: subshard != 'general', + // Detect unit test time regressions (poor time delay handling, etc). + perTestTimeout: (subshard == 'general') ? const Duration(seconds: 2) : null, ); }, ); diff --git a/packages/flutter_tools/test/general.shard/resident_runner_test.dart b/packages/flutter_tools/test/general.shard/resident_runner_test.dart index 70c730c262..85fb96ce2e 100644 --- a/packages/flutter_tools/test/general.shard/resident_runner_test.dart +++ b/packages/flutter_tools/test/general.shard/resident_runner_test.dart @@ -587,7 +587,7 @@ void main() { expect(result.code, 1); expect(result.message, contains('Device initialization has not completed.')); expect(fakeVmServiceHost.hasRemainingExpectations, false); - })); + }), timeout: const Timeout(Duration(seconds: 15))); // https://github.com/flutter/flutter/issues/74539 testUsingContext('ResidentRunner can handle an reload-barred exception from hot reload', () => testbed.run(() async { fakeVmServiceHost = FakeVmServiceHost(requests: [ diff --git a/packages/flutter_tools/test/src/context.dart b/packages/flutter_tools/test/src/context.dart index c86e1825be..bca89a247c 100644 --- a/packages/flutter_tools/test/src/context.dart +++ b/packages/flutter_tools/test/src/context.dart @@ -58,6 +58,7 @@ void testUsingContext( Map overrides = const {}, bool initializeFlutterRoot = true, String testOn, + Timeout timeout, bool skip, // should default to `false`, but https://github.com/dart-lang/test/issues/545 doesn't allow this }) { if (overrides[FileSystem] != null && overrides[ProcessManager] == null) { @@ -174,7 +175,7 @@ void testUsingContext( // BotDetector implementation in the overrides. BotDetector: overrides[BotDetector] ?? () => const AlwaysTrueBotDetector(), }); - }, testOn: testOn, skip: skip); + }, testOn: testOn, skip: skip, timeout: timeout); } void _printBufferedErrors(AppContext testContext) {