From 8536b96ebb3eaaebdc34a56b862b33bbc2d79a75 Mon Sep 17 00:00:00 2001 From: Matan Lurey Date: Tue, 19 Nov 2024 08:16:08 -0800 Subject: [PATCH] Terminate `flutter test` when no longer needed in integration test. (#159117) Towards https://github.com/flutter/flutter/issues/51421. ```sh flutter_tools % dart test test/integration.shard/break_on_framework_exceptions_test.dart 02:38 +29: All tests passed! 54692 ttys003 0:00.02 /opt/homebrew/bin/zsh -il ``` Requires https://github.com/flutter/flutter/pull/159115 for the process cleanup to work properly, but this is safe to land as-is, otherwise we still accumulate `flutter` processes over and over as each test case runs which is not WAI. --- .../break_on_framework_exceptions_test.dart | 34 +++++++++++-------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/packages/flutter_tools/test/integration.shard/break_on_framework_exceptions_test.dart b/packages/flutter_tools/test/integration.shard/break_on_framework_exceptions_test.dart index dd699b5a46..c6591810e9 100644 --- a/packages/flutter_tools/test/integration.shard/break_on_framework_exceptions_test.dart +++ b/packages/flutter_tools/test/integration.shard/break_on_framework_exceptions_test.dart @@ -33,23 +33,29 @@ void main() { final FlutterTestTestDriver flutter = FlutterTestTestDriver(tempDir); - await _timeoutAfter( - message: 'Timed out launching `flutter test`', - work: () => flutter.test(withDebugger: true, pauseOnExceptions: true), - ); + try { + await _timeoutAfter( + message: 'Timed out launching `flutter test`', + work: () => flutter.test(withDebugger: true, pauseOnExceptions: true), + ); - await _timeoutAfter( - message: 'Timed out waiting for VM service pause debug event', - work: flutter.waitForPause, - ); + await _timeoutAfter( + message: 'Timed out waiting for VM service pause debug event', + work: flutter.waitForPause, + ); - int? breakLine; - await _timeoutAfter( - message: 'Timed out getting source location of top stack frame', - work: () async => breakLine = (await flutter.getSourceLocation())?.line, - ); + int? breakLine; + await _timeoutAfter( + message: 'Timed out getting source location of top stack frame', + work: () async => breakLine = (await flutter.getSourceLocation())?.line, + ); - expect(breakLine, project.lineContaining(project.test, exceptionMessage)); + expect(breakLine, project.lineContaining(project.test, exceptionMessage)); + } finally { + // Some of the tests will quit naturally, and others won't. + // By this point we don't need the tool anymore, so just force quit. + await flutter.quit(); + } } testWithoutContext('breaks when AnimationController listener throws', () async {