Unverified Commit 4ff505c8 authored by Christopher Fujino's avatar Christopher Fujino Committed by GitHub

[flutter_tools] more debugging for timeouts in break_on_framework_exceptions test (#125584)

Better debugging to investigate: https://github.com/flutter/flutter/issues/125241

When the `test/integration.shard/break_on_framework_exceptions_test.dart` test times out, log out verbose logging to give clues as to why it did not complete.

From one local run it looks like the test runner is failing to load a test file (when I checked the path locally, the file was there, and re-running the `flutter test ...` invocation succeeded--in that the app threw an exception):

```
14:12 +26 -1: breaks when StatefulWidget.build throws [E]
  Timed out launching `flutter test`
  package:matcher                                                        fail
  test/integration.shard/break_on_framework_exceptions_test.dart 623:11  _timeoutAfter.<fn>

250s            Spawning flutter [test, --disable-service-auth-codes, --machine, --start-paused, test/test.dart] in /tmp/flutter_break_on_framework_exceptions.GUJDAZ

251s <=stdout=  {"protocolVersion":"0.1.1","runnerVersion":null,"pid":25763,"type":"start","time":0}

<=stdout=  {"suite":{"id":0,"platform":"vm","path":"/tmp/flutter_break_on_framework_exceptions.GUJDAZ/test/test.dart"},"type":"suite","time":0}

<=stdout=  {"test":{"id":1,"name":"loading /tmp/flutter_break_on_framework_exceptions.GUJDAZ/test/test.dart","suiteID":0,"groupIDs":[],"metadata":{"skip":false,"skipReason":null},"line":null,"column":null,"url":null},"type":"testStart","time":0}

258s <=stdout=  {"testID":1,"error":"Exception: the Dart compiler exited unexpectedly.","stackTrace":"package:flutter_tools/src/base/common.dart 10:3  throwToolExit\npackage:flutter_tools/src/compile.dart 813:13    DefaultResidentCompiler._compile.<fn>\ndart:async/zone.dart 1391:47                     _rootRun\ndart:async/zone.dart 1301:19                     _CustomZone.run\ndart:async/zone.dart 1209:7                      _CustomZone.runGuarded\ndart:async/stream_impl.dart 392:13               _BufferingStreamSubscription._sendDone.sendDone\ndart:async/stream_impl.dart 402:7                _BufferingStreamSubscription._sendDone\ndart:async/stream_impl.dart 291:7                _BufferingStreamSubscription._close\ndart:async/stream_transformers.dart 87:11        _SinkTransformerStreamSubscription._close\ndart:async/stream_transformers.dart 21:11        _EventSinkWrapper.close\ndart:convert/string_conversion.dart 241:11       _StringAdapterSink.close\ndart:convert/line_splitter.dart 141:11           _LineSplitterSink.close\ndart:async/stream_transformers.dart 132:24       _SinkTransformerStreamSubscription._handleDone\ndart:async/zone.dart 1391:47                     _rootRun\ndart:async/zone.dart 1301:19                     _CustomZone.run\ndart:async/zone.dart 1209:7                      _CustomZone.runGuarded\ndart:async/stream_impl.dart 392:13               _BufferingStreamSubscription._sendDone.sendDone\ndart:async/stream_impl.dart 402:7                _BufferingStreamSubscription._sendDone\ndart:async/stream_impl.dart 291:7                _BufferingStreamSubscription._close\ndart:async/stream_transformers.dart 87:11        _SinkTransformerStreamSubscription._close\ndart:async/stream_transformers.dart 21:11        _EventSinkWrapper.close\ndart:convert/string_conversion.dart 241:11       _StringAdapterSink.close\ndart:convert/string_conversion.dart 295:20       _Utf8ConversionSink.close\ndart:convert/chunked_conversion.dart 78:18       _ConverterStreamEventSink.close\ndart:async/stream_transformers.dart 132:24       _SinkTransformerStreamSubscription._handleDone\ndart:async/zone.dart 1391:47                     _rootRun\ndart:async/zone.dart 1301:19                     _CustomZone.run\ndart:async/zone.dart 1209:7                      _CustomZone.runGuarded\ndart:async/stream_impl.dart 392:13               _BufferingStreamSubscription._sendDone.sendDone\ndart:async/stream_impl.dart 402:7                _BufferingStreamSubscription._sendDone\ndart:async/stream_impl.dart...

<=stdout=  {"testID":1,"error":"Failed to load \"/tmp/flutter_break_on_framework_exceptions.GUJDAZ/test/test.dart\": Compilation failed for testPath=/tmp/flutter_break_on_framework_exceptions.GUJDAZ/test/test.dart","stackTrace":"","isFailure":false,"type":"error","time":7518}

<=stdout=  {"testID":1,"result":"error","skipped":false,"hidden":false,"type":"testDone","time":7521}

<=stdout=  {"count":1,"time":7526,"type":"allSuites"}

<=stdout=  {"success":false,"type":"done","time":7529}

259s            Process exited (1)

371s            Expecting test.startedProcess event
[+    95] <=stdout=  {"suite":{"id":0,"platform":"vm","path":"/tmp/flutter_break_on_framework_exceptions.GUJDAZ/test/test.dart"},"type":"suite","time":0}
[+    95] <=stdout=  {"test":{"id":1,"name":"loading /tmp/flutter_break_on_framework_exceptions.GUJDAZ/test/test.dart","suiteID":0,"groupIDs":[],"metadata":{"skip":false,"skipReason":null},"line":null,"column":null,"url":null},"type":"testStart","time":0}
[+  7600] <=stdout=  {"testID":1,"error":"Exception: the Dart compiler exited unexpectedly.","stackTrace":"package:flutter_tools/src/base/common.dart 10:3  throwToolExit\npackage:flutter_tools/src/compile.dart 813:13    DefaultResidentCompiler._compile.<fn>\ndart:async/zone.dart 1391:47                     _rootRun\ndart:async/zone.dart 1301:19                     _CustomZone.run\ndart:async/zone.dart 1209:7                      _CustomZone.runGuarded\ndart:async/stream_impl.dart 392:13               _BufferingStreamSubscription._sendDone.sendDone\ndart:async/stream_impl.dart 402:7                _BufferingStreamSubscription._sendDone\ndart:async/stream_impl.dart 291:7                _BufferingStreamSubscription._close\ndart:async/stream_transformers.dart 87:11        _SinkTransformerStreamSubscription._close\ndart:async/stream_transformers.dart 21:11        _EventSinkWrapper.close\ndart:convert/string_conversion.dart 241:11       _StringAdapterSink.close\ndart:convert/line_splitter.dart 141:11           _LineSplitterSink.close\ndart:async/stream_transformers.dart 132:24       _SinkTransformerStreamSubscription._handleDone\ndart:async/zone.dart 1391:47                     _rootRun\ndart:async/zone.dart 1301:19                     _CustomZone.run\ndart:async/zone.dart 1209:7                      _CustomZone.runGuarded\ndart:async/stream_impl.dart 392:13               _BufferingStreamSubscription._sendDone.sendDone\ndart:async/stream_impl.dart 402:7                _BufferingStreamSubscription._sendDone\ndart:async/stream_impl.dart 291:7                _BufferingStreamSubscription._close\ndart:async/stream_transformers.dart 87:11        _SinkTransformerStreamSubscription._close\ndart:async/stream_transformers.dart 21:11        _EventSinkWrapper.close\ndart:convert/string_conversion.dart 241:11       _StringAdapterSink.close\ndart:convert/string_conversion.dart 295:20       _Utf8ConversionSink.close\ndart:convert/chunked_conversion.dart 78:18       _ConverterStreamEventSink.close\ndart:async/stream_transformers.dart 132:24...

Expecting test.startedProcess event is taking longer than usual...
```
parent 84e8d498
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
@Tags(<String>['no-shuffle']) @Tags(<String>['no-shuffle'])
library; library;
import 'dart:async';
import 'package:file/file.dart'; import 'package:file/file.dart';
import '../src/common.dart'; import '../src/common.dart';
...@@ -27,6 +29,33 @@ void main() { ...@@ -27,6 +29,33 @@ void main() {
tryToDelete(tempDir); tryToDelete(tempDir);
}); });
Future<void> expectException(TestProject project, String exceptionMessage) async {
await _timeoutAfter(
message: 'Timed out setting up project in $tempDir',
work: () => project.setUpIn(tempDir),
);
final FlutterTestTestDriver flutter = FlutterTestTestDriver(tempDir);
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,
);
int? breakLine;
await _timeoutAfter(
message: 'Timed out getting source location of top stack frome',
work: () async => breakLine = (await flutter.getSourceLocation())?.line,
);
expect(breakLine, project.lineContaining(project.test, exceptionMessage));
}
testWithoutContext('breaks when AnimationController listener throws', () async { testWithoutContext('breaks when AnimationController listener throws', () async {
final TestProject project = TestProject( final TestProject project = TestProject(
r''' r'''
...@@ -37,13 +66,8 @@ void main() { ...@@ -37,13 +66,8 @@ void main() {
..forward(); ..forward();
''' '''
); );
await project.setUpIn(tempDir);
final FlutterTestTestDriver flutter = FlutterTestTestDriver(tempDir);
await flutter.test(withDebugger: true, pauseOnExceptions: true);
await flutter.waitForPause();
final int? breakLine = (await flutter.getSourceLocation())?.line; await expectException(project, "throw 'AnimationController listener';");
expect(breakLine, project.lineContaining(project.test, "throw 'AnimationController listener';"));
}); });
testWithoutContext('breaks when AnimationController status listener throws', () async { testWithoutContext('breaks when AnimationController status listener throws', () async {
...@@ -56,13 +80,8 @@ void main() { ...@@ -56,13 +80,8 @@ void main() {
..forward(); ..forward();
''' '''
); );
await project.setUpIn(tempDir);
final FlutterTestTestDriver flutter = FlutterTestTestDriver(tempDir);
await flutter.test(withDebugger: true, pauseOnExceptions: true);
await flutter.waitForPause();
final int? breakLine = (await flutter.getSourceLocation())?.line; await expectException(project, "throw 'AnimationController status listener';");
expect(breakLine, project.lineContaining(project.test, "throw 'AnimationController status listener';"));
}); });
testWithoutContext('breaks when ChangeNotifier listener throws', () async { testWithoutContext('breaks when ChangeNotifier listener throws', () async {
...@@ -75,13 +94,8 @@ void main() { ...@@ -75,13 +94,8 @@ void main() {
..value = 1; ..value = 1;
''' '''
); );
await project.setUpIn(tempDir);
final FlutterTestTestDriver flutter = FlutterTestTestDriver(tempDir);
await flutter.test(withDebugger: true, pauseOnExceptions: true);
await flutter.waitForPause();
final int? breakLine = (await flutter.getSourceLocation())?.line; await expectException(project, "throw 'ValueNotifier listener';");
expect(breakLine, project.lineContaining(project.test, "throw 'ValueNotifier listener';"));
}); });
testWithoutContext('breaks when handling a gesture throws', () async { testWithoutContext('breaks when handling a gesture throws', () async {
...@@ -102,13 +116,8 @@ void main() { ...@@ -102,13 +116,8 @@ void main() {
await tester.tap(find.byType(ElevatedButton)); await tester.tap(find.byType(ElevatedButton));
''' '''
); );
await project.setUpIn(tempDir);
final FlutterTestTestDriver flutter = FlutterTestTestDriver(tempDir);
await flutter.test(withDebugger: true, pauseOnExceptions: true);
await flutter.waitForPause();
final int? breakLine = (await flutter.getSourceLocation())?.line; await expectException(project, "throw 'while handling a gesture';");
expect(breakLine, project.lineContaining(project.test, "throw 'while handling a gesture';"));
}); });
testWithoutContext('breaks when platform message callback throws', () async { testWithoutContext('breaks when platform message callback throws', () async {
...@@ -120,13 +129,8 @@ void main() { ...@@ -120,13 +129,8 @@ void main() {
tester.binding.defaultBinaryMessenger.handlePlatformMessage('foo', const StringCodec().encodeMessage('Hello'), (_) {}); tester.binding.defaultBinaryMessenger.handlePlatformMessage('foo', const StringCodec().encodeMessage('Hello'), (_) {});
''' '''
); );
await project.setUpIn(tempDir);
final FlutterTestTestDriver flutter = FlutterTestTestDriver(tempDir);
await flutter.test(withDebugger: true, pauseOnExceptions: true);
await flutter.waitForPause();
final int? breakLine = (await flutter.getSourceLocation())?.line; await expectException(project, "throw 'platform message callback';");
expect(breakLine, project.lineContaining(project.test, "throw 'platform message callback';"));
}); });
testWithoutContext('breaks when SliverChildBuilderDelegate.builder throws', () async { testWithoutContext('breaks when SliverChildBuilderDelegate.builder throws', () async {
...@@ -141,13 +145,8 @@ void main() { ...@@ -141,13 +145,8 @@ void main() {
)); ));
''' '''
); );
await project.setUpIn(tempDir);
final FlutterTestTestDriver flutter = FlutterTestTestDriver(tempDir);
await flutter.test(withDebugger: true, pauseOnExceptions: true);
await flutter.waitForPause();
final int? breakLine = (await flutter.getSourceLocation())?.line; await expectException(project, "throw 'cannot build child';");
expect(breakLine, project.lineContaining(project.test, "throw 'cannot build child';"));
}); });
testWithoutContext('breaks when EditableText.onChanged throws', () async { testWithoutContext('breaks when EditableText.onChanged throws', () async {
...@@ -165,13 +164,8 @@ void main() { ...@@ -165,13 +164,8 @@ void main() {
await tester.enterText(find.byType(TextField), 'foo'); await tester.enterText(find.byType(TextField), 'foo');
''' '''
); );
await project.setUpIn(tempDir);
final FlutterTestTestDriver flutter = FlutterTestTestDriver(tempDir);
await flutter.test(withDebugger: true, pauseOnExceptions: true);
await flutter.waitForPause();
final int? breakLine = (await flutter.getSourceLocation())?.line; await expectException(project, "throw 'onChanged';");
expect(breakLine, project.lineContaining(project.test, "throw 'onChanged';"));
}); });
testWithoutContext('breaks when EditableText.onEditingComplete throws', () async { testWithoutContext('breaks when EditableText.onEditingComplete throws', () async {
...@@ -191,13 +185,8 @@ void main() { ...@@ -191,13 +185,8 @@ void main() {
await tester.testTextInput.receiveAction(TextInputAction.done); await tester.testTextInput.receiveAction(TextInputAction.done);
''' '''
); );
await project.setUpIn(tempDir);
final FlutterTestTestDriver flutter = FlutterTestTestDriver(tempDir);
await flutter.test(withDebugger: true, pauseOnExceptions: true);
await flutter.waitForPause();
final int? breakLine = (await flutter.getSourceLocation())?.line; await expectException(project, "throw 'onEditingComplete';");
expect(breakLine, project.lineContaining(project.test, "throw 'onEditingComplete';"));
}); });
testWithoutContext('breaks when EditableText.onSelectionChanged throws', () async { testWithoutContext('breaks when EditableText.onSelectionChanged throws', () async {
...@@ -213,13 +202,8 @@ void main() { ...@@ -213,13 +202,8 @@ void main() {
await tester.tap(find.byType(SelectableText)); await tester.tap(find.byType(SelectableText));
''' '''
); );
await project.setUpIn(tempDir);
final FlutterTestTestDriver flutter = FlutterTestTestDriver(tempDir);
await flutter.test(withDebugger: true, pauseOnExceptions: true);
await flutter.waitForPause();
final int? breakLine = (await flutter.getSourceLocation())?.line; await expectException(project, "throw 'onSelectionChanged';");
expect(breakLine, project.lineContaining(project.test, "throw 'onSelectionChanged';"));
}); });
testWithoutContext('breaks when Action listener throws', () async { testWithoutContext('breaks when Action listener throws', () async {
...@@ -232,13 +216,8 @@ void main() { ...@@ -232,13 +216,8 @@ void main() {
..notifyActionListeners(); ..notifyActionListeners();
''' '''
); );
await project.setUpIn(tempDir);
final FlutterTestTestDriver flutter = FlutterTestTestDriver(tempDir);
await flutter.test(withDebugger: true, pauseOnExceptions: true);
await flutter.waitForPause();
final int? breakLine = (await flutter.getSourceLocation())?.line; await expectException(project, "throw 'action listener';");
expect(breakLine, project.lineContaining(project.test, "throw 'action listener';"));
}); });
testWithoutContext('breaks when pointer route throws', () async { testWithoutContext('breaks when pointer route throws', () async {
...@@ -251,13 +230,8 @@ void main() { ...@@ -251,13 +230,8 @@ void main() {
..route(TestPointer(2).down(Offset.zero)); ..route(TestPointer(2).down(Offset.zero));
''' '''
); );
await project.setUpIn(tempDir);
final FlutterTestTestDriver flutter = FlutterTestTestDriver(tempDir);
await flutter.test(withDebugger: true, pauseOnExceptions: true);
await flutter.waitForPause();
final int? breakLine = (await flutter.getSourceLocation())?.line; await expectException(project, "throw 'pointer route';");
expect(breakLine, project.lineContaining(project.test, "throw 'pointer route';"));
}); });
testWithoutContext('breaks when PointerSignalResolver callback throws', () async { testWithoutContext('breaks when PointerSignalResolver callback throws', () async {
...@@ -271,13 +245,8 @@ void main() { ...@@ -271,13 +245,8 @@ void main() {
..resolve(originalEvent); ..resolve(originalEvent);
''' '''
); );
await project.setUpIn(tempDir);
final FlutterTestTestDriver flutter = FlutterTestTestDriver(tempDir);
await flutter.test(withDebugger: true, pauseOnExceptions: true);
await flutter.waitForPause();
final int? breakLine = (await flutter.getSourceLocation())?.line; await expectException(project, "throw 'PointerSignalResolver callback';");
expect(breakLine, project.lineContaining(project.test, "throw 'PointerSignalResolver callback';"));
}); });
testWithoutContext('breaks when PointerSignalResolver callback throws', () async { testWithoutContext('breaks when PointerSignalResolver callback throws', () async {
...@@ -291,13 +260,8 @@ void main() { ...@@ -291,13 +260,8 @@ void main() {
..highlightStrategy = FocusHighlightStrategy.alwaysTraditional; ..highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
''' '''
); );
await project.setUpIn(tempDir);
final FlutterTestTestDriver flutter = FlutterTestTestDriver(tempDir);
await flutter.test(withDebugger: true, pauseOnExceptions: true);
await flutter.waitForPause();
final int? breakLine = (await flutter.getSourceLocation())?.line; await expectException(project, "throw 'highlight mode listener';");
expect(breakLine, project.lineContaining(project.test, "throw 'highlight mode listener';"));
}); });
testWithoutContext('breaks when GestureBinding.dispatchEvent throws', () async { testWithoutContext('breaks when GestureBinding.dispatchEvent throws', () async {
...@@ -318,13 +282,8 @@ void main() { ...@@ -318,13 +282,8 @@ void main() {
gesture.removePointer(); gesture.removePointer();
''' '''
); );
await project.setUpIn(tempDir);
final FlutterTestTestDriver flutter = FlutterTestTestDriver(tempDir);
await flutter.test(withDebugger: true, pauseOnExceptions: true);
await flutter.waitForPause();
final int? breakLine = (await flutter.getSourceLocation())?.line; await expectException(project, "throw 'onHover';");
expect(breakLine, project.lineContaining(project.test, "throw 'onHover';"));
}); });
testWithoutContext('breaks when ImageStreamListener.onImage throws', () async { testWithoutContext('breaks when ImageStreamListener.onImage throws', () async {
...@@ -344,13 +303,8 @@ void main() { ...@@ -344,13 +303,8 @@ void main() {
}); });
''' '''
); );
await project.setUpIn(tempDir);
final FlutterTestTestDriver flutter = FlutterTestTestDriver(tempDir);
await flutter.test(withDebugger: true, pauseOnExceptions: true);
await flutter.waitForPause();
final int? breakLine = (await flutter.getSourceLocation())?.line; await expectException(project, "throw 'setImage';");
expect(breakLine, project.lineContaining(project.test, "throw 'setImage';"));
}); });
testWithoutContext('breaks when ImageStreamListener.onError throws', () async { testWithoutContext('breaks when ImageStreamListener.onError throws', () async {
...@@ -367,13 +321,8 @@ void main() { ...@@ -367,13 +321,8 @@ void main() {
completer.completeError('ERROR'); completer.completeError('ERROR');
''' '''
); );
await project.setUpIn(tempDir);
final FlutterTestTestDriver flutter = FlutterTestTestDriver(tempDir);
await flutter.test(withDebugger: true, pauseOnExceptions: true);
await flutter.waitForPause();
final int? breakLine = (await flutter.getSourceLocation())?.line; await expectException(project, "throw 'onError';");
expect(breakLine, project.lineContaining(project.test, "throw 'onError';"));
}); });
testWithoutContext('breaks when LayoutBuilder.builder throws', () async { testWithoutContext('breaks when LayoutBuilder.builder throws', () async {
...@@ -386,13 +335,8 @@ void main() { ...@@ -386,13 +335,8 @@ void main() {
)); ));
''' '''
); );
await project.setUpIn(tempDir);
final FlutterTestTestDriver flutter = FlutterTestTestDriver(tempDir);
await flutter.test(withDebugger: true, pauseOnExceptions: true);
await flutter.waitForPause();
final int? breakLine = (await flutter.getSourceLocation())?.line; await expectException(project, "throw 'LayoutBuilder.builder';");
expect(breakLine, project.lineContaining(project.test, "throw 'LayoutBuilder.builder';"));
}); });
testWithoutContext('breaks when _CallbackHookProvider callback throws', () async { testWithoutContext('breaks when _CallbackHookProvider callback throws', () async {
...@@ -405,13 +349,8 @@ void main() { ...@@ -405,13 +349,8 @@ void main() {
..invokeCallback(Future.value(false)); ..invokeCallback(Future.value(false));
''' '''
); );
await project.setUpIn(tempDir);
final FlutterTestTestDriver flutter = FlutterTestTestDriver(tempDir);
await flutter.test(withDebugger: true, pauseOnExceptions: true);
await flutter.waitForPause();
final int? breakLine = (await flutter.getSourceLocation())?.line; await expectException(project, "throw '_CallbackHookProvider.callback';");
expect(breakLine, project.lineContaining(project.test, "throw '_CallbackHookProvider.callback';"));
}); });
testWithoutContext('breaks when TimingsCallback throws', () async { testWithoutContext('breaks when TimingsCallback throws', () async {
...@@ -423,13 +362,8 @@ void main() { ...@@ -423,13 +362,8 @@ void main() {
ui.window.onReportTimings!(<FrameTiming>[]); ui.window.onReportTimings!(<FrameTiming>[]);
''' '''
); );
await project.setUpIn(tempDir);
final FlutterTestTestDriver flutter = FlutterTestTestDriver(tempDir);
await flutter.test(withDebugger: true, pauseOnExceptions: true);
await flutter.waitForPause();
final int? breakLine = (await flutter.getSourceLocation())?.line; await expectException(project, "throw 'TimingsCallback';");
expect(breakLine, project.lineContaining(project.test, "throw 'TimingsCallback';"));
}); });
testWithoutContext('breaks when TimingsCallback throws', () async { testWithoutContext('breaks when TimingsCallback throws', () async {
...@@ -444,13 +378,8 @@ void main() { ...@@ -444,13 +378,8 @@ void main() {
await tester.pumpAndSettle(); await tester.pumpAndSettle();
''' '''
); );
await project.setUpIn(tempDir);
final FlutterTestTestDriver flutter = FlutterTestTestDriver(tempDir);
await flutter.test(withDebugger: true, pauseOnExceptions: true);
await flutter.waitForPause();
final int? breakLine = (await flutter.getSourceLocation())?.line; await expectException(project, "throw 'scheduled task';");
expect(breakLine, project.lineContaining(project.test, "throw 'scheduled task';"));
}); });
testWithoutContext('breaks when FrameCallback throws', () async { testWithoutContext('breaks when FrameCallback throws', () async {
...@@ -462,13 +391,8 @@ void main() { ...@@ -462,13 +391,8 @@ void main() {
await tester.pump(); await tester.pump();
''' '''
); );
await project.setUpIn(tempDir);
final FlutterTestTestDriver flutter = FlutterTestTestDriver(tempDir);
await flutter.test(withDebugger: true, pauseOnExceptions: true);
await flutter.waitForPause();
final int? breakLine = (await flutter.getSourceLocation())?.line; await expectException(project, "throw 'FrameCallback';");
expect(breakLine, project.lineContaining(project.test, "throw 'FrameCallback';"));
}); });
testWithoutContext('breaks when attaching to render tree throws', () async { testWithoutContext('breaks when attaching to render tree throws', () async {
...@@ -488,13 +412,8 @@ void main() { ...@@ -488,13 +412,8 @@ void main() {
} }
''', ''',
); );
await project.setUpIn(tempDir);
final FlutterTestTestDriver flutter = FlutterTestTestDriver(tempDir);
await flutter.test(withDebugger: true, pauseOnExceptions: true);
await flutter.waitForPause();
final int? breakLine = (await flutter.getSourceLocation())?.line; await expectException(project, "throw 'create element';");
expect(breakLine, project.lineContaining(project.test, "throw 'create element';"));
}); });
testWithoutContext('breaks when RenderObject.performLayout throws', () async { testWithoutContext('breaks when RenderObject.performLayout throws', () async {
...@@ -511,13 +430,8 @@ void main() { ...@@ -511,13 +430,8 @@ void main() {
} }
''', ''',
); );
await project.setUpIn(tempDir);
final FlutterTestTestDriver flutter = FlutterTestTestDriver(tempDir);
await flutter.test(withDebugger: true, pauseOnExceptions: true);
await flutter.waitForPause();
final int? breakLine = (await flutter.getSourceLocation())?.line; await expectException(project, "throw 'performLayout';");
expect(breakLine, project.lineContaining(project.test, "throw 'performLayout';"));
}); });
testWithoutContext('breaks when RenderObject.performResize throws', () async { testWithoutContext('breaks when RenderObject.performResize throws', () async {
...@@ -537,13 +451,8 @@ void main() { ...@@ -537,13 +451,8 @@ void main() {
} }
''', ''',
); );
await project.setUpIn(tempDir);
final FlutterTestTestDriver flutter = FlutterTestTestDriver(tempDir);
await flutter.test(withDebugger: true, pauseOnExceptions: true);
await flutter.waitForPause();
final int? breakLine = (await flutter.getSourceLocation())?.line; await expectException(project, "throw 'performResize';");
expect(breakLine, project.lineContaining(project.test, "throw 'performResize';"));
}); });
testWithoutContext('breaks when RenderObject.performLayout (without resize) throws', () async { testWithoutContext('breaks when RenderObject.performLayout (without resize) throws', () async {
...@@ -580,13 +489,8 @@ void main() { ...@@ -580,13 +489,8 @@ void main() {
} }
''', ''',
); );
await project.setUpIn(tempDir);
final FlutterTestTestDriver flutter = FlutterTestTestDriver(tempDir);
await flutter.test(withDebugger: true, pauseOnExceptions: true);
await flutter.waitForPause();
final int? breakLine = (await flutter.getSourceLocation())?.line; await expectException(project, "throw 'performLayout without resize';");
expect(breakLine, project.lineContaining(project.test, "throw 'performLayout without resize';"));
}); });
testWithoutContext('breaks when StatelessWidget.build throws', () async { testWithoutContext('breaks when StatelessWidget.build throws', () async {
...@@ -603,13 +507,8 @@ void main() { ...@@ -603,13 +507,8 @@ void main() {
} }
''', ''',
); );
await project.setUpIn(tempDir);
final FlutterTestTestDriver flutter = FlutterTestTestDriver(tempDir);
await flutter.test(withDebugger: true, pauseOnExceptions: true);
await flutter.waitForPause();
final int? breakLine = (await flutter.getSourceLocation())?.line; await expectException(project, "throw 'StatelessWidget.build';");
expect(breakLine, project.lineContaining(project.test, "throw 'StatelessWidget.build';"));
}); });
testWithoutContext('breaks when StatefulWidget.build throws', () async { testWithoutContext('breaks when StatefulWidget.build throws', () async {
...@@ -631,13 +530,8 @@ void main() { ...@@ -631,13 +530,8 @@ void main() {
} }
''', ''',
); );
await project.setUpIn(tempDir);
final FlutterTestTestDriver flutter = FlutterTestTestDriver(tempDir);
await flutter.test(withDebugger: true, pauseOnExceptions: true);
await flutter.waitForPause();
final int? breakLine = (await flutter.getSourceLocation())?.line; await expectException(project, "throw 'StatefulWidget.build';");
expect(breakLine, project.lineContaining(project.test, "throw 'StatefulWidget.build';"));
}); });
testWithoutContext('breaks when finalizing the tree throws', () async { testWithoutContext('breaks when finalizing the tree throws', () async {
...@@ -663,13 +557,8 @@ void main() { ...@@ -663,13 +557,8 @@ void main() {
} }
''', ''',
); );
await project.setUpIn(tempDir);
final FlutterTestTestDriver flutter = FlutterTestTestDriver(tempDir);
await flutter.test(withDebugger: true, pauseOnExceptions: true);
await flutter.waitForPause();
final int? breakLine = (await flutter.getSourceLocation())?.line; await expectException(project, "throw 'dispose';");
expect(breakLine, project.lineContaining(project.test, "throw 'dispose';"));
}); });
testWithoutContext('breaks when rebuilding dirty elements throws', () async { testWithoutContext('breaks when rebuilding dirty elements throws', () async {
...@@ -711,16 +600,32 @@ void main() { ...@@ -711,16 +600,32 @@ void main() {
} }
''', ''',
); );
await project.setUpIn(tempDir);
final FlutterTestTestDriver flutter = FlutterTestTestDriver(tempDir);
await flutter.test(withDebugger: true, pauseOnExceptions: true);
await flutter.waitForPause();
final int? breakLine = (await flutter.getSourceLocation())?.line; await expectException(project, "throw 'rebuild';");
expect(breakLine, project.lineContaining(project.test, "throw 'rebuild';"));
}); });
} }
/// A debugging wrapper to help diagnose tests that are already timing out.
///
/// When these tests are timed out by package:test (after 15 minutes), there
/// is no hint in logs as to where the test got stuck. By passing async calls
/// to this function with a [duration] less than that configured in
/// package:test can be set and a helpful message used to help debugging.
///
/// See https://github.com/flutter/flutter/issues/125241 for more context.
Future<void> _timeoutAfter({
required String message,
Duration duration = const Duration(minutes: 10),
required Future<void> Function() work,
}) async {
final Timer timer = Timer(
duration,
() => fail(message),
);
await work();
timer.cancel();
}
class TestProject extends Project { class TestProject extends Project {
TestProject(this.testBody, { this.setup, this.classes }); TestProject(this.testBody, { this.setup, this.classes });
......
...@@ -81,6 +81,8 @@ abstract class FlutterTestDriver { ...@@ -81,6 +81,8 @@ abstract class FlutterTestDriver {
// intended only for use in local debugging. // intended only for use in local debugging.
// ignore: avoid_print // ignore: avoid_print
print('$time$_logPrefix$line'); print('$time$_logPrefix$line');
} else {
printOnFailure('$time$_logPrefix$line');
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment