diff --git a/analysis_options.yaml b/analysis_options.yaml index 55c346a3c6a..e5203782a1e 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -71,8 +71,8 @@ linter: - avoid_init_to_null # - avoid_js_rounded_ints # only useful when targeting JS runtime - avoid_null_checks_in_equality_operators - # - avoid_positional_boolean_parameters # would have been nice to enable this but by now there's too many places that break it - - avoid_print + # - avoid_positional_boolean_parameters # not yet tested + # - avoid_print # not yet tested # - avoid_private_typedef_functions # we prefer having typedef (discussion in https://github.com/flutter/flutter/pull/16356) # - avoid_redundant_argument_values # not yet tested - avoid_relative_lib_imports diff --git a/dev/analysis_options.yaml b/dev/analysis_options.yaml deleted file mode 100644 index 68626cc5f40..00000000000 --- a/dev/analysis_options.yaml +++ /dev/null @@ -1,5 +0,0 @@ -include: ../analysis_options.yaml - -linter: - rules: - avoid_print: false # We use prints as debugging tools here all the time. diff --git a/dev/automated_tests/flutter_test/flutter_gold_expectation.txt b/dev/automated_tests/flutter_test/flutter_gold_expectation.txt deleted file mode 100644 index b7d012748cb..00000000000 --- a/dev/automated_tests/flutter_test/flutter_gold_expectation.txt +++ /dev/null @@ -1,7 +0,0 @@ -[0-9]+:[0-9]+ [+]0: Local passes non-existent baseline for new test, null expectation * - *No expectations provided by Skia Gold for test: library.flutter.new_golden_test.1. This may be a new test. If this is an unexpected result, check https://flutter-gold.skia.org. - *Validate image output found at flutter/test/library/ -[0-9]+:[0-9]+ [+]0 ~1: Local passes non-existent baseline for new test, empty expectation * - *No expectations provided by Skia Gold for test: library.flutter.new_golden_test.2. This may be a new test. If this is an unexpected result, check https://flutter-gold.skia.org. - *Validate image output found at flutter/test/library/ -[0-9]+:[0-9]+ [+]0 ~2: All tests skipped. * diff --git a/dev/automated_tests/flutter_test/flutter_gold_test.dart b/dev/automated_tests/flutter_test/flutter_gold_test.dart deleted file mode 100644 index 36831b6623c..00000000000 --- a/dev/automated_tests/flutter_test/flutter_gold_test.dart +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2014 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// See also packages/flutter_goldens/test/flutter_goldens_test.dart - -import 'dart:typed_data'; - -import 'package:file/file.dart'; -import 'package:file/memory.dart'; -import 'package:flutter_goldens/flutter_goldens.dart'; -import 'package:flutter_test/flutter_test.dart'; -import 'package:platform/platform.dart'; - -// 1x1 colored pixel -const List _kFailPngBytes = [137, 80, 78, 71, 13, 10, 26, 10, 0, 0, 0, - 13, 73, 72, 68, 82, 0, 0, 0, 1, 0, 0, 0, 1, 8, 6, 0, 0, 0, 31, 21, 196, 137, - 0, 0, 0, 13, 73, 68, 65, 84, 120, 1, 99, 249, 207, 240, 255, 63, 0, 7, 18, 3, - 2, 164, 147, 160, 197, 0, 0, 0, 0, 73, 69, 78, 68, 174, 66, 96, 130]; - -void main() { - final MemoryFileSystem fs = MemoryFileSystem(); - final Directory basedir = fs.directory('flutter/test/library/') - ..createSync(recursive: true); - final FakeSkiaGoldClient fakeSkiaClient = FakeSkiaGoldClient() - ..expectationForTestValues['flutter.new_golden_test.1'] = ''; - final FlutterLocalFileComparator comparator = FlutterLocalFileComparator( - basedir.uri, - fakeSkiaClient, - fs: fs, - platform: FakePlatform( - environment: {'FLUTTER_ROOT': '/flutter'}, - operatingSystem: 'macos' - ), - ); - - test('Local passes non-existent baseline for new test, null expectation', () async { - expect( - await comparator.compare( - Uint8List.fromList(_kFailPngBytes), - Uri.parse('flutter.new_golden_test.1'), - ), - isTrue, - ); - }); - - test('Local passes non-existent baseline for new test, empty expectation', () async { - expect( - await comparator.compare( - Uint8List.fromList(_kFailPngBytes), - Uri.parse('flutter.new_golden_test.2'), - ), - isTrue, - ); - }); -} - -// See also packages/flutter_goldens/test/flutter_goldens_test.dart -class FakeSkiaGoldClient extends Fake implements SkiaGoldClient { - Map expectationForTestValues = {}; - Object? getExpectationForTestThrowable; - @override - Future getExpectationForTest(String testName) async { - if (getExpectationForTestThrowable != null) { - throw getExpectationForTestThrowable!; - } - return expectationForTestValues[testName] ?? ''; - } - - Map> imageBytesValues = >{}; - @override - Future> getImageBytes(String imageHash) async => imageBytesValues[imageHash]!; - - Map cleanTestNameValues = {}; - @override - String cleanTestName(String fileName) => cleanTestNameValues[fileName] ?? ''; -} diff --git a/dev/automated_tests/flutter_test/working_directory_test.dart b/dev/automated_tests/flutter_test/working_directory_test.dart index 370228c4102..8b5ac9bef57 100644 --- a/dev/automated_tests/flutter_test/working_directory_test.dart +++ b/dev/automated_tests/flutter_test/working_directory_test.dart @@ -8,5 +8,5 @@ import 'package:test/test.dart' hide TypeMatcher, isInstanceOf; void main() { test('working directory is the root of this package', () { expect(Directory.current.path, endsWith('automated_tests')); - }); + }); } diff --git a/dev/automated_tests/pubspec.yaml b/dev/automated_tests/pubspec.yaml index f523877959c..eed7e95cb2e 100644 --- a/dev/automated_tests/pubspec.yaml +++ b/dev/automated_tests/pubspec.yaml @@ -8,8 +8,6 @@ dependencies: sdk: flutter flutter_test: sdk: flutter - flutter_goldens: - sdk: flutter integration_test: sdk: flutter test: 1.17.12 diff --git a/dev/conductor/core/analysis_options.yaml b/dev/conductor/core/analysis_options.yaml index 2d24879e534..59d57729f5f 100644 --- a/dev/conductor/core/analysis_options.yaml +++ b/dev/conductor/core/analysis_options.yaml @@ -1,10 +1,12 @@ -include: ../../analysis_options.yaml +# Use the analysis options settings from the top level of the repo (not +# the ones from above, which include the `public_member_api_docs` rule). + +include: ../../../analysis_options.yaml analyzer: exclude: - # Ignore protoc generated files + # Ignore protoc generated files - "lib/src/proto/*" - linter: rules: avoid_catches_without_on_clauses: true diff --git a/dev/conductor/ui/analysis_options.yaml b/dev/conductor/ui/analysis_options.yaml index 60e37337062..405ebb6adb8 100644 --- a/dev/conductor/ui/analysis_options.yaml +++ b/dev/conductor/ui/analysis_options.yaml @@ -1,4 +1,7 @@ -include: ../../analysis_options.yaml +# Use the analysis options settings from the top level of the repo (not +# the ones from above, which include the `public_member_api_docs` rule). + +include: ../../../analysis_options.yaml linter: rules: diff --git a/dev/devicelab/analysis_options.yaml b/dev/devicelab/analysis_options.yaml index 2e46286d627..acd91c6c38e 100644 --- a/dev/devicelab/analysis_options.yaml +++ b/dev/devicelab/analysis_options.yaml @@ -1,4 +1,4 @@ -include: ../analysis_options.yaml +include: ../../analysis_options.yaml linter: rules: diff --git a/dev/integration_tests/flutter_gallery/analysis_options.yaml b/dev/integration_tests/flutter_gallery/analysis_options.yaml index c4a47172d2b..8fe5f684cf8 100644 --- a/dev/integration_tests/flutter_gallery/analysis_options.yaml +++ b/dev/integration_tests/flutter_gallery/analysis_options.yaml @@ -1,4 +1,7 @@ -include: ../../analysis_options.yaml +# Take our settings from the repo's main analysis_options.yaml file, but add +# an exclude for the build directory. + +include: ../../../analysis_options.yaml analyzer: exclude: diff --git a/examples/api/lib/material/autocomplete/autocomplete.0.dart b/examples/api/lib/material/autocomplete/autocomplete.0.dart index 0fdcd98cf53..7f89258a3db 100644 --- a/examples/api/lib/material/autocomplete/autocomplete.0.dart +++ b/examples/api/lib/material/autocomplete/autocomplete.0.dart @@ -47,7 +47,7 @@ class AutocompleteBasicExample extends StatelessWidget { }); }, onSelected: (String selection) { - debugPrint('You just selected $selection'); + print('You just selected $selection'); }, ); } diff --git a/examples/api/lib/material/autocomplete/autocomplete.1.dart b/examples/api/lib/material/autocomplete/autocomplete.1.dart index d4da62e74d8..497e692d40d 100644 --- a/examples/api/lib/material/autocomplete/autocomplete.1.dart +++ b/examples/api/lib/material/autocomplete/autocomplete.1.dart @@ -79,7 +79,7 @@ class AutocompleteBasicUserExample extends StatelessWidget { }); }, onSelected: (User selection) { - debugPrint('You just selected ${_displayStringForOption(selection)}'); + print('You just selected ${_displayStringForOption(selection)}'); }, ); } diff --git a/examples/api/lib/material/card/card.1.dart b/examples/api/lib/material/card/card.1.dart index 3eb4457afd3..5a3038cd88a 100644 --- a/examples/api/lib/material/card/card.1.dart +++ b/examples/api/lib/material/card/card.1.dart @@ -35,7 +35,7 @@ class MyStatelessWidget extends StatelessWidget { child: InkWell( splashColor: Colors.blue.withAlpha(30), onTap: () { - debugPrint('Card tapped.'); + print('Card tapped.'); }, child: const SizedBox( width: 300, diff --git a/examples/api/lib/material/checkbox_list_tile/checkbox_list_tile.1.dart b/examples/api/lib/material/checkbox_list_tile/checkbox_list_tile.1.dart index 470d21fe39a..78319e8bf99 100644 --- a/examples/api/lib/material/checkbox_list_tile/checkbox_list_tile.1.dart +++ b/examples/api/lib/material/checkbox_list_tile/checkbox_list_tile.1.dart @@ -59,7 +59,7 @@ class LinkedLabelCheckbox extends StatelessWidget { ), recognizer: TapGestureRecognizer() ..onTap = () { - debugPrint('Label has been tapped.'); + print('Label has been tapped.'); }, ), ), diff --git a/examples/api/lib/material/floating_action_button_location/standard_fab_location.0.dart b/examples/api/lib/material/floating_action_button_location/standard_fab_location.0.dart index a7dd2548a12..db5fc0faf43 100644 --- a/examples/api/lib/material/floating_action_button_location/standard_fab_location.0.dart +++ b/examples/api/lib/material/floating_action_button_location/standard_fab_location.0.dart @@ -45,7 +45,7 @@ class MyStatelessWidget extends StatelessWidget { ), floatingActionButton: FloatingActionButton( onPressed: () { - debugPrint('FAB pressed.'); + print('FAB pressed.'); }, tooltip: 'Increment', child: const Icon(Icons.add), diff --git a/examples/api/lib/material/outlined_button/outlined_button.0.dart b/examples/api/lib/material/outlined_button/outlined_button.0.dart index 887c5769dad..c55d0edbdf6 100644 --- a/examples/api/lib/material/outlined_button/outlined_button.0.dart +++ b/examples/api/lib/material/outlined_button/outlined_button.0.dart @@ -34,7 +34,7 @@ class MyStatelessWidget extends StatelessWidget { Widget build(BuildContext context) { return OutlinedButton( onPressed: () { - debugPrint('Received click'); + print('Received click'); }, child: const Text('Click Me'), ); diff --git a/examples/api/lib/material/radio_list_tile/radio_list_tile.1.dart b/examples/api/lib/material/radio_list_tile/radio_list_tile.1.dart index d4fb40b668d..98cc2f4131d 100644 --- a/examples/api/lib/material/radio_list_tile/radio_list_tile.1.dart +++ b/examples/api/lib/material/radio_list_tile/radio_list_tile.1.dart @@ -64,7 +64,7 @@ class LinkedLabelRadio extends StatelessWidget { ), recognizer: TapGestureRecognizer() ..onTap = () { - debugPrint('Label has been tapped.'); + print('Label has been tapped.'); }, ), ), diff --git a/examples/api/lib/material/switch_list_tile/switch_list_tile.1.dart b/examples/api/lib/material/switch_list_tile/switch_list_tile.1.dart index ea24f2ae56a..c810ac8a4da 100644 --- a/examples/api/lib/material/switch_list_tile/switch_list_tile.1.dart +++ b/examples/api/lib/material/switch_list_tile/switch_list_tile.1.dart @@ -59,7 +59,7 @@ class LinkedLabelSwitch extends StatelessWidget { ), recognizer: TapGestureRecognizer() ..onTap = () { - debugPrint('Label has been tapped.'); + print('Label has been tapped.'); }, ), ), diff --git a/examples/api/lib/material/text_form_field/text_form_field.1.dart b/examples/api/lib/material/text_form_field/text_form_field.1.dart index 890179c0fb0..aa2c1d864ca 100644 --- a/examples/api/lib/material/text_form_field/text_form_field.1.dart +++ b/examples/api/lib/material/text_form_field/text_form_field.1.dart @@ -54,7 +54,7 @@ class _MyStatefulWidgetState extends State { constraints: BoxConstraints.tight(const Size(200, 50)), child: TextFormField( onSaved: (String? value) { - debugPrint('Value for field $index saved as "$value"'); + print('Value for field $index saved as "$value"'); }, ), ), diff --git a/examples/api/lib/widgets/actions/action_listener.0.dart b/examples/api/lib/widgets/actions/action_listener.0.dart index c481a9cec49..42fb6fe296b 100644 --- a/examples/api/lib/widgets/actions/action_listener.0.dart +++ b/examples/api/lib/widgets/actions/action_listener.0.dart @@ -92,13 +92,13 @@ class MyAction extends Action { @override void addActionListener(ActionListenerCallback listener) { super.addActionListener(listener); - debugPrint('Action Listener was added'); + print('Action Listener was added'); } @override void removeActionListener(ActionListenerCallback listener) { super.removeActionListener(listener); - debugPrint('Action Listener was removed'); + print('Action Listener was removed'); } @override diff --git a/examples/api/lib/widgets/actions/actions.0.dart b/examples/api/lib/widgets/actions/actions.0.dart index 3fb02a11028..c037053ab1a 100644 --- a/examples/api/lib/widgets/actions/actions.0.dart +++ b/examples/api/lib/widgets/actions/actions.0.dart @@ -34,7 +34,7 @@ class Model { int save() { if (isDirty.value) { - debugPrint('Saved Data: ${data.value}'); + print('Saved Data: ${data.value}'); isDirty.value = false; } return data.value; diff --git a/examples/api/lib/widgets/focus_manager/focus_node.0.dart b/examples/api/lib/widgets/focus_manager/focus_node.0.dart index cb63bfbe3a7..7c32781a738 100644 --- a/examples/api/lib/widgets/focus_manager/focus_node.0.dart +++ b/examples/api/lib/widgets/focus_manager/focus_node.0.dart @@ -57,21 +57,21 @@ class _ColorfulButtonState extends State { KeyEventResult _handleKeyPress(FocusNode node, RawKeyEvent event) { if (event is RawKeyDownEvent) { - debugPrint('Focus node ${node.debugLabel} got key event: ${event.logicalKey}'); + print('Focus node ${node.debugLabel} got key event: ${event.logicalKey}'); if (event.logicalKey == LogicalKeyboardKey.keyR) { - debugPrint('Changing color to red.'); + print('Changing color to red.'); setState(() { _color = Colors.red; }); return KeyEventResult.handled; } else if (event.logicalKey == LogicalKeyboardKey.keyG) { - debugPrint('Changing color to green.'); + print('Changing color to green.'); setState(() { _color = Colors.green; }); return KeyEventResult.handled; } else if (event.logicalKey == LogicalKeyboardKey.keyB) { - debugPrint('Changing color to blue.'); + print('Changing color to blue.'); setState(() { _color = Colors.blue; }); diff --git a/examples/api/lib/widgets/focus_scope/focus.0.dart b/examples/api/lib/widgets/focus_scope/focus.0.dart index 54525b708c5..adcef1ec88d 100644 --- a/examples/api/lib/widgets/focus_scope/focus.0.dart +++ b/examples/api/lib/widgets/focus_scope/focus.0.dart @@ -38,21 +38,21 @@ class _MyStatefulWidgetState extends State { KeyEventResult _handleKeyPress(FocusNode node, RawKeyEvent event) { if (event is RawKeyDownEvent) { - debugPrint('Focus node ${node.debugLabel} got key event: ${event.logicalKey}'); + print('Focus node ${node.debugLabel} got key event: ${event.logicalKey}'); if (event.logicalKey == LogicalKeyboardKey.keyR) { - debugPrint('Changing color to red.'); + print('Changing color to red.'); setState(() { _color = Colors.red; }); return KeyEventResult.handled; } else if (event.logicalKey == LogicalKeyboardKey.keyG) { - debugPrint('Changing color to green.'); + print('Changing color to green.'); setState(() { _color = Colors.green; }); return KeyEventResult.handled; } else if (event.logicalKey == LogicalKeyboardKey.keyB) { - debugPrint('Changing color to blue.'); + print('Changing color to blue.'); setState(() { _color = Colors.blue; }); diff --git a/examples/api/lib/widgets/focus_scope/focus_scope.0.dart b/examples/api/lib/widgets/focus_scope/focus_scope.0.dart index 5a5806e7999..e905a84e323 100644 --- a/examples/api/lib/widgets/focus_scope/focus_scope.0.dart +++ b/examples/api/lib/widgets/focus_scope/focus_scope.0.dart @@ -115,7 +115,7 @@ class _MyStatefulWidgetState extends State { // This button would be not visible, but still focusable from // the foreground pane without the FocusScope. ElevatedButton( - onPressed: () => debugPrint('You pressed the other button!'), + onPressed: () => print('You pressed the other button!'), child: const Text('ANOTHER BUTTON TO FOCUS'), ), DefaultTextStyle( diff --git a/examples/api/lib/widgets/focus_traversal/focus_traversal_group.0.dart b/examples/api/lib/widgets/focus_traversal/focus_traversal_group.0.dart index 7182b67ed5b..84e404f636d 100644 --- a/examples/api/lib/widgets/focus_traversal/focus_traversal_group.0.dart +++ b/examples/api/lib/widgets/focus_traversal/focus_traversal_group.0.dart @@ -68,7 +68,7 @@ class _OrderedButtonState extends State> { void _handleOnPressed() { focusNode.requestFocus(); - debugPrint('Button ${widget.name} pressed.'); + print('Button ${widget.name} pressed.'); debugDumpFocusTree(); } diff --git a/examples/api/lib/widgets/focus_traversal/ordered_traversal_policy.0.dart b/examples/api/lib/widgets/focus_traversal/ordered_traversal_policy.0.dart index aea86f97e4e..e7f11734556 100644 --- a/examples/api/lib/widgets/focus_traversal/ordered_traversal_policy.0.dart +++ b/examples/api/lib/widgets/focus_traversal/ordered_traversal_policy.0.dart @@ -40,7 +40,7 @@ class DemoButton extends StatelessWidget { final double order; void _handleOnPressed() { - debugPrint('Button $name pressed.'); + print('Button $name pressed.'); debugDumpFocusTree(); } diff --git a/examples/api/lib/widgets/interactive_viewer/interactive_viewer.builder.0.dart b/examples/api/lib/widgets/interactive_viewer/interactive_viewer.builder.0.dart index a85d51670cd..3efa90e348d 100644 --- a/examples/api/lib/widgets/interactive_viewer/interactive_viewer.builder.0.dart +++ b/examples/api/lib/widgets/interactive_viewer/interactive_viewer.builder.0.dart @@ -122,10 +122,10 @@ class _IVBuilderExampleState extends State<_IVBuilderExample> { cellWidth: _cellWidth, builder: (BuildContext context, int row, int column) { if (!_isCellVisible(row, column, viewport)) { - debugPrint('removing cell ($row, $column)'); + print('removing cell ($row, $column)'); return Container(height: _cellHeight); } - debugPrint('building cell ($row, $column)'); + print('building cell ($row, $column)'); return Container( height: _cellHeight, color: row % 2 + column % 2 == 1 diff --git a/examples/api/lib/widgets/notification_listener/notification.0.dart b/examples/api/lib/widgets/notification_listener/notification.0.dart index 75c9083dc36..c8103ebcd41 100644 --- a/examples/api/lib/widgets/notification_listener/notification.0.dart +++ b/examples/api/lib/widgets/notification_listener/notification.0.dart @@ -45,9 +45,9 @@ class MyStatelessWidget extends StatelessWidget { body: NotificationListener( onNotification: (ScrollNotification scrollNotification) { if (scrollNotification is ScrollStartNotification) { - debugPrint('Scrolling has started'); + print('Scrolling has started'); } else if (scrollNotification is ScrollEndNotification) { - debugPrint('Scrolling has ended'); + print('Scrolling has ended'); } // Return true to cancel the notification bubbling. return true; diff --git a/examples/image_list/lib/main.dart b/examples/image_list/lib/main.dart index 192891b144b..6dc43e31e59 100644 --- a/examples/image_list/lib/main.dart +++ b/examples/image_list/lib/main.dart @@ -98,7 +98,7 @@ Future main() async { final HttpServer httpServer = await HttpServer.bindSecure('localhost', 0, serverContext); final int port = httpServer.port; - debugPrint('Listening on port $port.'); + print('Listening on port $port.'); // Initializes bindings before using any platform channels. WidgetsFlutterBinding.ensureInitialized(); @@ -193,7 +193,7 @@ class _MyHomePageState extends State with TickerProviderStateMixin { ).toList(); final DateTime started = DateTime.now(); Future.wait(futures).then((_) { - debugPrint( + print( '===image_list=== all loaded in ${DateTime.now().difference(started).inMilliseconds}ms.', ); }); diff --git a/examples/layers/services/isolate.dart b/examples/layers/services/isolate.dart index 9aa3234c972..fbd32bddfd3 100644 --- a/examples/layers/services/isolate.dart +++ b/examples/layers/services/isolate.dart @@ -47,8 +47,8 @@ class Calculator { final int n = result.length; onResultListener('Decoded $n results'); } catch (e, stack) { - debugPrint('Invalid JSON file: $e'); - debugPrint('$stack'); + print('Invalid JSON file: $e'); + print(stack); } } diff --git a/packages/flutter/lib/src/foundation/print.dart b/packages/flutter/lib/src/foundation/print.dart index b12f4902cc3..5aef1d30764 100644 --- a/packages/flutter/lib/src/foundation/print.dart +++ b/packages/flutter/lib/src/foundation/print.dart @@ -2,10 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// This file implements debugPrint in terms of print, so avoiding -// calling "print" is sort of a non-starter here... -// ignore_for_file: avoid_print - import 'dart:async'; import 'dart:collection'; diff --git a/packages/flutter/test/services/text_input_utils.dart b/packages/flutter/test/services/text_input_utils.dart index e1e3ddf9b59..fd58e40548c 100644 --- a/packages/flutter/test/services/text_input_utils.dart +++ b/packages/flutter/test/services/text_input_utils.dart @@ -42,7 +42,6 @@ class FakeTextChannel implements MethodChannel { void validateOutgoingMethodCalls(List calls) { expect(outgoingCalls.length, calls.length); - final StringBuffer output = StringBuffer(); bool hasError = false; for (int i = 0; i < calls.length; i++) { final ByteData outgoingData = codec.encodeMethodCall(outgoingCalls[i]); @@ -51,7 +50,7 @@ class FakeTextChannel implements MethodChannel { final String expectedString = utf8.decode(expectedData.buffer.asUint8List()); if (outgoingString != expectedString) { - output.writeln( + print( 'Index $i did not match:\n' ' actual: $outgoingString\n' ' expected: $expectedString', @@ -60,7 +59,7 @@ class FakeTextChannel implements MethodChannel { } } if (hasError) { - fail('Calls did not match:\n$output'); + fail('Calls did not match.'); } } } diff --git a/packages/flutter/test/widgets/multichild_test.dart b/packages/flutter/test/widgets/multichild_test.dart index 8b4a581055e..f3c44b07245 100644 --- a/packages/flutter/test/widgets/multichild_test.dart +++ b/packages/flutter/test/widgets/multichild_test.dart @@ -26,7 +26,7 @@ void checkTree(WidgetTester tester, List expectedDecorations) { } expect(child, isNull); } catch (e) { - debugPrint(renderObject.toStringDeep()); + print(renderObject.toStringDeep()); rethrow; } } diff --git a/packages/flutter/test/widgets/parent_data_test.dart b/packages/flutter/test/widgets/parent_data_test.dart index 56eb8d9e7f3..e6fce60303c 100644 --- a/packages/flutter/test/widgets/parent_data_test.dart +++ b/packages/flutter/test/widgets/parent_data_test.dart @@ -41,7 +41,7 @@ void checkTree(WidgetTester tester, List expectedParentData) { } expect(child, isNull); } catch (e) { - debugPrint(renderObject.toStringDeep()); + print(renderObject.toStringDeep()); rethrow; } } diff --git a/packages/flutter/test_private/analysis_options.yaml b/packages/flutter/test_private/analysis_options.yaml deleted file mode 100644 index a3c97d35d00..00000000000 --- a/packages/flutter/test_private/analysis_options.yaml +++ /dev/null @@ -1,5 +0,0 @@ -include: ../analysis_options.yaml - -linter: - rules: - avoid_print: false # This is a CLI tool, so printing to the console is fine. diff --git a/packages/flutter_driver/lib/src/driver/vmservice_driver.dart b/packages/flutter_driver/lib/src/driver/vmservice_driver.dart index cbe460441fd..a5b39bccef4 100644 --- a/packages/flutter_driver/lib/src/driver/vmservice_driver.dart +++ b/packages/flutter_driver/lib/src/driver/vmservice_driver.dart @@ -50,7 +50,7 @@ class VMServiceFlutterDriver extends FlutterDriver { // TODO(awdavies): Use something other than print. On fuchsia // `stderr`/`stdout` appear to have issues working correctly. driverLog = (String source, String message) { - print('$source: $message'); // ignore: avoid_print + print('$source: $message'); }; fuchsiaModuleTarget ??= Platform.environment['FUCHSIA_MODULE_TARGET']; if (fuchsiaModuleTarget == null) { diff --git a/packages/flutter_driver/lib/src/driver/web_driver.dart b/packages/flutter_driver/lib/src/driver/web_driver.dart index e62ec2071ba..b9a67d610fe 100644 --- a/packages/flutter_driver/lib/src/driver/web_driver.dart +++ b/packages/flutter_driver/lib/src/driver/web_driver.dart @@ -222,7 +222,11 @@ class WebFlutterDriver extends FlutterDriver { class FlutterWebConnection { /// Creates a FlutterWebConnection with WebDriver /// and whether the WebDriver supports timeline action. - FlutterWebConnection(this._driver, this.supportsTimelineAction); + FlutterWebConnection(this._driver, this.supportsTimelineAction) { + _driver.logs.get(async_io.LogType.browser).listen((async_io.LogEntry entry) { + print('[${entry.level}]: ${entry.message}'); + }); + } final async_io.WebDriver _driver; diff --git a/packages/flutter_driver/test/common.dart b/packages/flutter_driver/test/common.dart index 85b6fb97143..0fb8ed3db78 100644 --- a/packages/flutter_driver/test/common.dart +++ b/packages/flutter_driver/test/common.dart @@ -20,7 +20,7 @@ void tryToDelete(Directory directory) { try { directory.deleteSync(recursive: true); } on FileSystemException catch (error) { - driverLog('test', 'Failed to delete ${directory.path}: $error'); + print('Failed to delete ${directory.path}: $error'); } } diff --git a/packages/flutter_goldens/lib/flutter_goldens.dart b/packages/flutter_goldens/lib/flutter_goldens.dart index 63049fb8004..97375513a30 100644 --- a/packages/flutter_goldens/lib/flutter_goldens.dart +++ b/packages/flutter_goldens/lib/flutter_goldens.dart @@ -385,7 +385,9 @@ class FlutterSkippingFileComparator extends FlutterGoldenFileComparator { @override Future compare(Uint8List imageBytes, Uri golden) async { - markTestSkipped('Skipping "$golden" test: $reason'); + print( + 'Skipping "$golden" test : $reason' + ); return true; } @@ -500,9 +502,8 @@ class FlutterLocalFileComparator extends FlutterGoldenFileComparator with LocalC testExpectation = await skiaClient.getExpectationForTest(testName); if (testExpectation == null || testExpectation.isEmpty) { - // There is no baseline for this test. - markTestSkipped( - 'No expectations provided by Skia Gold for test: $golden. ' + // There is no baseline for this test + print('No expectations provided by Skia Gold for test: $golden. ' 'This may be a new test. If this is an unexpected result, check ' 'https://flutter-gold.skia.org.\n' 'Validate image output found at $basedir' diff --git a/packages/flutter_goldens/test/flutter_goldens_test.dart b/packages/flutter_goldens/test/flutter_goldens_test.dart index e47bdb30bfa..b6a74423d3b 100644 --- a/packages/flutter_goldens/test/flutter_goldens_test.dart +++ b/packages/flutter_goldens/test/flutter_goldens_test.dart @@ -8,19 +8,18 @@ // Fails with "flutter test --test-randomize-ordering-seed=123" @Tags(['no-shuffle']) -// See also dev/automated_tests/flutter_test/flutter_gold_test.dart - import 'dart:async'; import 'dart:convert'; +import 'dart:core'; import 'dart:io' hide Directory; import 'dart:typed_data'; import 'dart:ui' show hashValues, hashList; import 'package:file/file.dart'; import 'package:file/memory.dart'; -import 'package:flutter/foundation.dart'; import 'package:flutter_goldens/flutter_goldens.dart'; import 'package:flutter_test/flutter_test.dart'; +import 'package:meta/meta.dart'; import 'package:platform/platform.dart'; import 'package:process/process.dart'; @@ -42,6 +41,17 @@ const List _kFailPngBytes = 120, 1, 99, 249, 207, 240, 255, 63, 0, 7, 18, 3, 2, 164, 147, 160, 197, 0, 0, 0, 0, 73, 69, 78, 68, 174, 66, 96, 130]; +Future testWithOutput(String name, Future Function() body, String expectedOutput) async { + test(name, () async { + final StringBuffer output = StringBuffer(); + void _recordPrint(Zone self, ZoneDelegate parent, Zone zone, String line) { + output.write(line); + } + await runZoned>(body, zoneSpecification: ZoneSpecification(print: _recordPrint)); + expect(output.toString(), expectedOutput); + }); +} + void main() { late MemoryFileSystem fs; late FakePlatform platform; @@ -559,6 +569,7 @@ void main() { const String hash = '55109a4bed52acc780530f7a9aeff6c0'; fakeSkiaClient.expectationForTestValues['flutter.golden_test.1'] = hash; + fakeSkiaClient.expectationForTestValues['flutter.new_golden_test.1'] = ''; fakeSkiaClient.imageBytesValues[hash] =_kTestPngBytes; fakeSkiaClient.cleanTestNameValues['library.flutter.golden_test.1.png'] = 'flutter.golden_test.1'; }); @@ -573,6 +584,32 @@ void main() { ); }); + testWithOutput('passes non-existent baseline for new test, null expectation', () async { + expect( + await comparator.compare( + Uint8List.fromList(_kFailPngBytes), + Uri.parse('flutter.new_golden_test.1'), + ), + isTrue, + ); + }, 'No expectations provided by Skia Gold for test: library.flutter.new_golden_test.1. ' + 'This may be a new test. If this is an unexpected result, check https://flutter-gold.skia.org.\n' + 'Validate image output found at flutter/test/library/' + ); + + testWithOutput('passes non-existent baseline for new test, empty expectation', () async { + expect( + await comparator.compare( + Uint8List.fromList(_kFailPngBytes), + Uri.parse('flutter.new_golden_test.2'), + ), + isTrue, + ); + }, 'No expectations provided by Skia Gold for test: library.flutter.new_golden_test.2. ' + 'This may be a new test. If this is an unexpected result, check https://flutter-gold.skia.org.\n' + 'Validate image output found at flutter/test/library/' + ); + test('compare properly awaits validation & output before failing.', () async { final Completer completer = Completer(); final Future result = comparator.compare( @@ -676,14 +713,14 @@ class FakeProcessManager extends Fake implements ProcessManager { workingDirectories.add(workingDirectory); final ProcessResult? result = processResults[RunInvocation(command.cast(), workingDirectory)]; if (result == null && fallbackProcessResult == null) { - printOnFailure('ProcessManager.run was called with $command ($workingDirectory) unexpectedly - $processResults.'); + // Throwing here might gobble up the exception message if a test fails. + print('ProcessManager.run was called with $command ($workingDirectory) unexpectedly - $processResults.'); fail('See above.'); } return result ?? fallbackProcessResult!; } } -// See also dev/automated_tests/flutter_test/flutter_gold_test.dart class FakeSkiaGoldClient extends Fake implements SkiaGoldClient { Map expectationForTestValues = {}; Object? getExpectationForTestThrowable; diff --git a/packages/flutter_goldens_client/lib/skia_client.dart b/packages/flutter_goldens_client/lib/skia_client.dart index 22fdc175e83..db03764e6a9 100644 --- a/packages/flutter_goldens_client/lib/skia_client.dart +++ b/packages/flutter_goldens_client/lib/skia_client.dart @@ -183,10 +183,9 @@ class SkiaGoldClient { if (result.exitCode != 0) { // We do not want to throw for non-zero exit codes here, as an intentional // change or new golden file test expect non-zero exit codes. Logging here - // is meant to help debugging in CI when an unexpected result occurs. - // See also: https://github.com/flutter/flutter/issues/91285 - print('goldctl imgtest add stdout: ${result.stdout}'); // ignore: avoid_print - print('goldctl imgtest add stderr: ${result.stderr}'); // ignore: avoid_print + // is meant to inform when an unexpected result occurs. + print('goldctl imgtest add stdout: ${result.stdout}'); + print('goldctl imgtest add stderr: ${result.stderr}'); } return true; @@ -302,10 +301,7 @@ class SkiaGoldClient { throw const FormatException('Skia gold expectations do not match expected format.'); expectation = jsonResponse['digest'] as String?; } on FormatException catch (error) { - // Ideally we'd use something like package:test's printOnError, but best reliabilty - // in getting logs on CI for now we're just using print. - // See also: https://github.com/flutter/flutter/issues/91285 - print( // ignore: avoid_print + print( 'Formatting error detected requesting expectations from Flutter Gold.\n' 'error: $error\n' 'url: $requestForExpectations\n' diff --git a/packages/flutter_test/lib/src/goldens.dart b/packages/flutter_test/lib/src/goldens.dart index 1a7716d4c0c..f88306f43c1 100644 --- a/packages/flutter_test/lib/src/goldens.dart +++ b/packages/flutter_test/lib/src/goldens.dart @@ -6,8 +6,6 @@ import 'dart:typed_data'; import 'dart:ui'; import 'package:path/path.dart' as path; -import 'package:test_api/test_api.dart'; // ignore: deprecated_member_use - import '_goldens_io.dart' if (dart.library.html) '_goldens_web.dart' as _goldens; /// Compares image pixels against a golden image file. @@ -270,7 +268,7 @@ class TrivialComparator implements GoldenFileComparator { @override Future compare(Uint8List imageBytes, Uri golden) { - markTestSkipped('Golden file comparison requested for "$golden"; skipping...'); + print('Golden file comparison requested for "$golden"; skipping...'); return Future.value(true); } @@ -290,7 +288,7 @@ class _TrivialWebGoldenComparator implements WebGoldenComparator { @override Future compare(double width, double height, Uri golden) { - markTestSkipped('Golden comparison requested for "$golden"; skipping...'); + print('Golden comparison requested for "$golden"; skipping...'); return Future.value(true); } diff --git a/packages/flutter_test/lib/src/test_compat.dart b/packages/flutter_test/lib/src/test_compat.dart index 60428a3c59a..a73998a3c54 100644 --- a/packages/flutter_test/lib/src/test_compat.dart +++ b/packages/flutter_test/lib/src/test_compat.dart @@ -96,7 +96,7 @@ Future _runLiveTest(Suite suiteConfig, LiveTest liveTest, _Reporter report Future _runSkippedTest(Suite suiteConfig, Test test, List parents, _Reporter reporter) async { final LocalTest skipped = LocalTest(test.name, test.metadata, () { }, trace: test.trace); if (skipped.metadata.skipReason != null) { - reporter.log('Skip: ${skipped.metadata.skipReason}'); + print('Skip: ${skipped.metadata.skipReason}'); } final LiveTest liveTest = skipped.load(suiteConfig); reporter._onTestStarted(liveTest); @@ -334,7 +334,7 @@ class _Reporter { if (message.type == MessageType.skip) { text = ' $_yellow$text$_noColor'; } - log(text); + print(text); })); } @@ -351,8 +351,8 @@ class _Reporter { return; } _progressLine(_description(liveTest), suffix: ' $_bold$_red[E]$_noColor'); - log(_indent(error.toString())); - log(_indent('$stackTrace')); + print(_indent(error.toString())); + print(_indent('$stackTrace')); } /// A callback called when the engine is finished running tests. @@ -421,7 +421,7 @@ class _Reporter { buffer.write(message); buffer.write(_noColor); - log(buffer.toString()); + print(buffer.toString()); } /// Returns a representation of [duration] as `MM:SS`. @@ -442,13 +442,6 @@ class _Reporter { } return name; } - - /// Print the message to the console. - void log(String message) { - // We centralize all the prints in this file through this one method so that - // in principle we can reroute the output easily should we need to. - print(message); // ignore: avoid_print - } } String _indent(String string, { int? size, String? first }) { diff --git a/packages/flutter_test/lib/src/widget_tester.dart b/packages/flutter_test/lib/src/widget_tester.dart index eb9e64417af..29638fa5335 100644 --- a/packages/flutter_test/lib/src/widget_tester.dart +++ b/packages/flutter_test/lib/src/widget_tester.dart @@ -416,7 +416,7 @@ Future benchmarkWidgets( assert(() { if (mayRunWithAsserts) return true; - debugPrint(kDebugWarning); + print(kDebugWarning); return true; }()); final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized() as TestWidgetsFlutterBinding; diff --git a/packages/flutter_tools/analysis_options.yaml b/packages/flutter_tools/analysis_options.yaml index d777166af5a..7b7e75c4397 100644 --- a/packages/flutter_tools/analysis_options.yaml +++ b/packages/flutter_tools/analysis_options.yaml @@ -1,11 +1,12 @@ -include: ../analysis_options.yaml +# Use the analysis options settings from the top level of the repo (not +# the ones from above, which include the `public_member_api_docs` rule). + +include: ../../analysis_options.yaml linter: rules: avoid_catches_without_on_clauses: true curly_braces_in_flow_control_structures: true - library_private_types_in_public_api: false # Tool does not have any public API. - no_runtimeType_toString: false # We use runtimeType for debugging in the tool. + library_private_types_in_public_api: false # Tool does not have any public API prefer_relative_imports: true - public_member_api_docs: false # Tool does not have any public API. unawaited_futures: true diff --git a/packages/flutter_tools/bin/analysis_options.yaml b/packages/flutter_tools/bin/analysis_options.yaml deleted file mode 100644 index 19391e33ff9..00000000000 --- a/packages/flutter_tools/bin/analysis_options.yaml +++ /dev/null @@ -1,5 +0,0 @@ -include: ../analysis_options.yaml - -linter: - rules: - avoid_print: false # These are CLI tools which print as a matter of course. diff --git a/packages/flutter_tools/lib/src/base/io.dart b/packages/flutter_tools/lib/src/base/io.dart index 05a60e0dd3f..1f3cebb27fc 100644 --- a/packages/flutter_tools/lib/src/base/io.dart +++ b/packages/flutter_tools/lib/src/base/io.dart @@ -25,12 +25,6 @@ /// about any additional exports that you add to this file, as doing so will /// increase the API surface that we have to test in Flutter tools, and the APIs /// in `dart:io` can sometimes be hard to use in tests. - -// We allow `print()` in this file as a fallback for writing to the terminal via -// regular stdout/stderr/stdio paths. Everything else in the flutter_tools -// library should route terminal I/O through the [Stdio] class defined below. -// ignore_for_file: avoid_print - import 'dart:async'; import 'dart:io' as io show diff --git a/packages/flutter_tools/lib/src/cache.dart b/packages/flutter_tools/lib/src/cache.dart index e6a39ca39c5..f91c9923ea1 100644 --- a/packages/flutter_tools/lib/src/cache.dart +++ b/packages/flutter_tools/lib/src/cache.dart @@ -247,7 +247,6 @@ class Cache { } } on Exception catch (error) { // There is currently no logger attached since this is computed at startup. - // ignore: avoid_print print(userMessages.runnerNoRoot('$error')); } return normalize('.'); diff --git a/packages/flutter_tools/lib/src/commands/daemon.dart b/packages/flutter_tools/lib/src/commands/daemon.dart index 3e99d24829a..f356bec2307 100644 --- a/packages/flutter_tools/lib/src/commands/daemon.dart +++ b/packages/flutter_tools/lib/src/commands/daemon.dart @@ -307,7 +307,6 @@ class DaemonDomain extends Domain { if (message.level == 'status') { // We use `print()` here instead of `stdout.writeln()` in order to // capture the print output for testing. - // ignore: avoid_print print(message.message); } else if (message.level == 'error') { globals.stdio.stderrWrite('${message.message}\n'); diff --git a/packages/flutter_tools/lib/src/macos/macos_device.dart b/packages/flutter_tools/lib/src/macos/macos_device.dart index 51b274d6557..dc746a522da 100644 --- a/packages/flutter_tools/lib/src/macos/macos_device.dart +++ b/packages/flutter_tools/lib/src/macos/macos_device.dart @@ -96,7 +96,7 @@ class MacOSDevice extends DesktopDevice { 'open', package.applicationBundle(buildMode), ]).then((ProcessResult result) { if (result.exitCode != 0) { - _logger.printError('Failed to foreground app; open returned ${result.exitCode}'); + print('Failed to foreground app; open returned ${result.exitCode}'); } }); } diff --git a/packages/flutter_tools/test/commands.shard/permeable/create_test.dart b/packages/flutter_tools/test/commands.shard/permeable/create_test.dart index f741e5607de..8d23794123d 100755 --- a/packages/flutter_tools/test/commands.shard/permeable/create_test.dart +++ b/packages/flutter_tools/test/commands.shard/permeable/create_test.dart @@ -2723,9 +2723,10 @@ Future _ensureFlutterToolsSnapshot() async { '../../bin/cache/dart-sdk/bin/dart', snapshotArgs, ); - printOnFailure('Results of generating snapshot:'); - printOnFailure(snapshotResult.stdout.toString()); - printOnFailure(snapshotResult.stderr.toString()); + if (snapshotResult.exitCode != 0) { + print(snapshotResult.stdout); + print(snapshotResult.stderr); + } expect(snapshotResult.exitCode, 0); } @@ -2767,9 +2768,10 @@ Future _analyzeProject(String workingDir, { List expectedFailures workingDirectory: workingDir, ); if (expectedFailures.isEmpty) { - printOnFailure('Results of running analyzer:'); - printOnFailure(exec.stdout.toString()); - printOnFailure(exec.stderr.toString()); + if (exec.exitCode != 0) { + print(exec.stdout); + print(exec.stderr); + } expect(exec.exitCode, 0); return; } @@ -2823,9 +2825,10 @@ Future _runFlutterTest(Directory workingDir, { String target }) async { args, workingDirectory: workingDir.path, ); - printOnFailure('Output of running flutter test:'); - printOnFailure(exec.stdout.toString()); - printOnFailure(exec.stderr.toString()); + if (exec.exitCode != 0) { + print(exec.stdout); + print(exec.stderr); + } expect(exec.exitCode, 0); } diff --git a/packages/flutter_tools/test/general.shard/runner/runner_test.dart b/packages/flutter_tools/test/general.shard/runner/runner_test.dart index f460fe6a339..2e07984b83c 100644 --- a/packages/flutter_tools/test/general.shard/runner/runner_test.dart +++ b/packages/flutter_tools/test/general.shard/runner/runner_test.dart @@ -179,6 +179,7 @@ void main() { expect(logContents, contains('String: an exception % --')); expect(logContents, contains('CrashingFlutterCommand.runCommand')); expect(logContents, contains('[✓] Flutter')); + print(globals.crashReporter.runtimeType); final CrashDetails sentDetails = (globals.crashReporter as WaitingCrashReporter)._details; expect(sentDetails.command, 'flutter crash'); diff --git a/packages/flutter_tools/test/integration.shard/analyze_once_test.dart b/packages/flutter_tools/test/integration.shard/analyze_once_test.dart index 95bd0f4d59d..0a0e85cfdc9 100644 --- a/packages/flutter_tools/test/integration.shard/analyze_once_test.dart +++ b/packages/flutter_tools/test/integration.shard/analyze_once_test.dart @@ -28,9 +28,8 @@ void main() { '--no-color', ...arguments, ], workingDirectory: projectPath); - printOnFailure('Output of flutter ${arguments.join(" ")}'); - printOnFailure(result.stdout.toString()); - printOnFailure(result.stderr.toString()); + print(result.stdout); + print(result.stderr); expect(result.exitCode, exitCode, reason: 'Expected to exit with non-zero exit code.'); assertContains(result.stdout.toString(), statusTextContains); assertContains(result.stdout.toString(), errorTextContains); diff --git a/packages/flutter_tools/test/integration.shard/analyze_size_test.dart b/packages/flutter_tools/test/integration.shard/analyze_size_test.dart index 1fe91a542af..42620d1e130 100644 --- a/packages/flutter_tools/test/integration.shard/analyze_size_test.dart +++ b/packages/flutter_tools/test/integration.shard/analyze_size_test.dart @@ -31,9 +31,8 @@ void main() { '--target-platform=android-arm64' ], workingDirectory: workingDirectory); - printOnFailure('Output of flutter build apk:'); - printOnFailure(result.stdout.toString()); - printOnFailure(result.stderr.toString()); + print(result.stdout); + print(result.stderr); expect(result.stdout.toString(), contains('app-release.apk (total compressed)')); final String line = result.stdout.toString() @@ -68,9 +67,8 @@ void main() { '--no-codesign', ], workingDirectory: workingDirectory); - printOnFailure('Output of flutter build ios:'); - printOnFailure(result.stdout.toString()); - printOnFailure(result.stderr.toString()); + print(result.stdout); + print(result.stderr); expect(result.stdout.toString(), contains('Dart AOT symbols accounted decompressed size')); final String line = result.stdout.toString() @@ -104,9 +102,8 @@ void main() { '--enable-macos-desktop', ], workingDirectory: workingDirectory); - printOnFailure('Output of flutter config:'); - printOnFailure(configResult.stdout.toString()); - printOnFailure(configResult.stderr.toString()); + print(configResult.stdout); + print(configResult.stderr); final ProcessResult result = await processManager.run([ flutterBin, @@ -116,9 +113,8 @@ void main() { '--code-size-directory=${codeSizeDir.path}', ], workingDirectory: workingDirectory); - printOnFailure('Output of flutter build macos:'); - printOnFailure(result.stdout.toString()); - printOnFailure(result.stderr.toString()); + print(result.stdout); + print(result.stderr); expect(result.stdout.toString(), contains('Dart AOT symbols accounted decompressed size')); final String line = result.stdout.toString() @@ -151,9 +147,8 @@ void main() { '--debug', ], workingDirectory: fileSystem.path.join(getFlutterRoot(), 'examples', 'hello_world')); - printOnFailure('Output of flutter build apk:'); - printOnFailure(result.stdout.toString()); - printOnFailure(result.stderr.toString()); + print(result.stdout); + print(result.stderr); expect(result.stderr.toString(), contains('"--analyze-size" can only be used on release builds')); expect(result.exitCode, 1); diff --git a/packages/flutter_tools/test/integration.shard/background_isolate_test.dart b/packages/flutter_tools/test/integration.shard/background_isolate_test.dart index bc1cb9a67f9..8285d418fe0 100644 --- a/packages/flutter_tools/test/integration.shard/background_isolate_test.dart +++ b/packages/flutter_tools/test/integration.shard/background_isolate_test.dart @@ -34,7 +34,7 @@ void main() { final Completer sawBackgroundMessage = Completer.sync(); final Completer sawNewBackgroundMessage = Completer.sync(); final StreamSubscription subscription = flutter.stdout.listen((String line) { - printOnFailure('[LOG]:"$line"'); + print('[LOG]:"$line"'); if (line.contains('Main thread') && !sawForegroundMessage.isCompleted) { sawForegroundMessage.complete(); } @@ -68,7 +68,7 @@ void main() { final Completer sawBackgroundMessage = Completer.sync(); final Completer sawNewBackgroundMessage = Completer.sync(); final StreamSubscription subscription = flutter.stdout.listen((String line) { - printOnFailure('[LOG]:"$line"'); + print('[LOG]:"$line"'); if (line.contains('Isolate thread') && !sawBackgroundMessage.isCompleted) { sawBackgroundMessage.complete(); } diff --git a/packages/flutter_tools/test/integration.shard/build_ios_config_only_test.dart b/packages/flutter_tools/test/integration.shard/build_ios_config_only_test.dart index f5adc08a028..61957cf538b 100644 --- a/packages/flutter_tools/test/integration.shard/build_ios_config_only_test.dart +++ b/packages/flutter_tools/test/integration.shard/build_ios_config_only_test.dart @@ -33,9 +33,8 @@ void main() { '--no-codesign', ], workingDirectory: workingDirectory); - printOnFailure('Output of flutter build ios:'); - printOnFailure(result.stdout.toString()); - printOnFailure(result.stderr.toString()); + print(result.stdout); + print(result.stderr); expect(result.exitCode, 0); diff --git a/packages/flutter_tools/test/integration.shard/cache_test.dart b/packages/flutter_tools/test/integration.shard/cache_test.dart index 8f155d6c59a..c45ece1b4ba 100644 --- a/packages/flutter_tools/test/integration.shard/cache_test.dart +++ b/packages/flutter_tools/test/integration.shard/cache_test.dart @@ -64,7 +64,11 @@ Future main(List args) async { await cache.lock(); process.kill(io.ProcessSignal.sigkill); } finally { - tryToDelete(tempDir); + try { + tempDir.deleteSync(recursive: true); + } on FileSystemException { + // Ignore filesystem exceptions when trying to delete tempdir. + } Cache.flutterRoot = oldRoot; } expect(logger.statusText, isEmpty); diff --git a/packages/flutter_tools/test/integration.shard/deprecated_gradle_settings_test.dart b/packages/flutter_tools/test/integration.shard/deprecated_gradle_settings_test.dart index 142812120dd..c2c2ae4a687 100644 --- a/packages/flutter_tools/test/integration.shard/deprecated_gradle_settings_test.dart +++ b/packages/flutter_tools/test/integration.shard/deprecated_gradle_settings_test.dart @@ -26,10 +26,8 @@ void main() { '--target-platform', 'android-arm', '--verbose', ], workingDirectory: woringDirectory); - - printOnFailure('Output of flutter build apk:'); - printOnFailure(result.stdout.toString()); - printOnFailure(result.stderr.toString()); + print(result.stdout); + print(result.stderr); expect(result.exitCode, 0); diff --git a/packages/flutter_tools/test/integration.shard/downgrade_upgrade_integration_test.dart b/packages/flutter_tools/test/integration.shard/downgrade_upgrade_integration_test.dart index 0e0f91b39fa..ea7d48eeb1f 100644 --- a/packages/flutter_tools/test/integration.shard/downgrade_upgrade_integration_test.dart +++ b/packages/flutter_tools/test/integration.shard/downgrade_upgrade_integration_test.dart @@ -38,7 +38,11 @@ void main() { }); tearDown(() { - tryToDelete(parentDirectory); + try { + parentDirectory.deleteSync(recursive: true); + } on FileSystemException { + print('Failed to delete test directory'); + } }); testWithoutContext('Can upgrade and downgrade a Flutter checkout', () async { @@ -52,7 +56,7 @@ void main() { 'git', 'config', '--system', 'core.longpaths', 'true', ]); - printOnFailure('Step 1 - clone the $_kBranch of flutter into the test directory'); + print('Step 1 - clone the $_kBranch of flutter into the test directory'); exitCode = await processUtils.stream([ 'git', 'clone', @@ -60,7 +64,7 @@ void main() { ], workingDirectory: parentDirectory.path, trace: true); expect(exitCode, 0); - printOnFailure('Step 2 - switch to the $_kBranch'); + print('Step 2 - switch to the $_kBranch'); exitCode = await processUtils.stream([ 'git', 'checkout', @@ -71,7 +75,7 @@ void main() { ], workingDirectory: testDirectory.path, trace: true); expect(exitCode, 0); - printOnFailure('Step 3 - revert back to $_kInitialVersion'); + print('Step 3 - revert back to $_kInitialVersion'); exitCode = await processUtils.stream([ 'git', 'reset', @@ -80,7 +84,7 @@ void main() { ], workingDirectory: testDirectory.path, trace: true); expect(exitCode, 0); - printOnFailure('Step 4 - upgrade to the newest $_kBranch'); + print('Step 4 - upgrade to the newest $_kBranch'); // This should update the persistent tool state with the sha for HEAD exitCode = await processUtils.stream([ flutterBin, @@ -90,7 +94,7 @@ void main() { ], workingDirectory: testDirectory.path, trace: true); expect(exitCode, 0); - printOnFailure('Step 5 - verify that the version is different'); + print('Step 5 - verify that the version is different'); final RunResult versionResult = await processUtils.run([ 'git', 'describe', @@ -100,9 +104,10 @@ void main() { '--tags', ], workingDirectory: testDirectory.path); expect(versionResult.stdout, isNot(contains(_kInitialVersion))); - printOnFailure('current version is ${versionResult.stdout.trim()}\ninitial was $_kInitialVersion'); + print('current version is ${versionResult.stdout.trim()}\ninitial was $_kInitialVersion'); - printOnFailure('Step 6 - downgrade back to the initial version'); + print('Step 6 - downgrade back to the initial version'); + // Step 6. Downgrade back to initial version. exitCode = await processUtils.stream([ flutterBin, 'downgrade', @@ -111,7 +116,8 @@ void main() { ], workingDirectory: testDirectory.path, trace: true); expect(exitCode, 0); - printOnFailure('Step 7 - verify downgraded version matches original version'); + print('Step 7 - verify downgraded version matches original version'); + // Step 7. Verify downgraded version matches original version. final RunResult oldVersionResult = await processUtils.run([ 'git', 'describe', @@ -121,6 +127,6 @@ void main() { '--tags', ], workingDirectory: testDirectory.path); expect(oldVersionResult.stdout, contains(_kInitialVersion)); - printOnFailure('current version is ${oldVersionResult.stdout.trim()}\ninitial was $_kInitialVersion'); + print('current version is ${oldVersionResult.stdout.trim()}\ninitial was $_kInitialVersion'); }); } diff --git a/packages/flutter_tools/test/integration.shard/exit_code_test.dart b/packages/flutter_tools/test/integration.shard/exit_code_test.dart index e6b3e6e4139..891326bbecf 100644 --- a/packages/flutter_tools/test/integration.shard/exit_code_test.dart +++ b/packages/flutter_tools/test/integration.shard/exit_code_test.dart @@ -36,9 +36,8 @@ void main() { fileSystem.path.join(tempDir.path, 'main.dart'), ]); - printOnFailure('Output of dart main.dart:'); - printOnFailure(result.stdout.toString()); - printOnFailure(result.stderr.toString()); + print(result.stdout); + print(result.stderr); expect(result.exitCode, 0); }); @@ -56,9 +55,8 @@ void main() { fileSystem.path.join(tempDir.path, 'main.dart'), ]); - printOnFailure('Output of dart main.dart:'); - printOnFailure(result.stdout.toString()); - printOnFailure(result.stderr.toString()); + print(result.stdout); + print(result.stderr); expect(result.exitCode, 1); }); } diff --git a/packages/flutter_tools/test/integration.shard/flutter_build_null_unsafe_test.dart b/packages/flutter_tools/test/integration.shard/flutter_build_null_unsafe_test.dart index 70cc4c1c8ae..483d8eba964 100644 --- a/packages/flutter_tools/test/integration.shard/flutter_build_null_unsafe_test.dart +++ b/packages/flutter_tools/test/integration.shard/flutter_build_null_unsafe_test.dart @@ -67,6 +67,7 @@ String unsafeString = null; for (final String targetPlatform in targetPlatforms) { testWithoutContext('flutter build $targetPlatform --no-sound-null-safety', () { + print(tempDir); final ProcessResult result = processManager.runSync([ flutterBin, ...getLocalEngineArguments(), diff --git a/packages/flutter_tools/test/integration.shard/generated_plugin_registrant_test.dart b/packages/flutter_tools/test/integration.shard/generated_plugin_registrant_test.dart index 7332f77c0cc..df491ea3123 100644 --- a/packages/flutter_tools/test/integration.shard/generated_plugin_registrant_test.dart +++ b/packages/flutter_tools/test/integration.shard/generated_plugin_registrant_test.dart @@ -138,9 +138,10 @@ Future _ensureFlutterToolsSnapshot() async { '../../bin/cache/dart-sdk/bin/dart', snapshotArgs, ); - printOnFailure('Output of dart ${snapshotArgs.join(" ")}:'); - printOnFailure(snapshotResult.stdout.toString()); - printOnFailure(snapshotResult.stderr.toString()); + if (snapshotResult.exitCode != 0) { + print(snapshotResult.stdout); + print(snapshotResult.stderr); + } expect(snapshotResult.exitCode, 0); } @@ -236,8 +237,9 @@ Future _analyzeProject(Directory workingDir) async { args, workingDirectory: workingDir.path, ); - printOnFailure('Output of flutter analyze:'); - printOnFailure(exec.stdout.toString()); - printOnFailure(exec.stderr.toString()); + if (exec.exitCode != 0) { + print(exec.stdout); + print(exec.stderr); + } expect(exec.exitCode, 0); } diff --git a/packages/flutter_tools/test/integration.shard/hot_reload_test.dart b/packages/flutter_tools/test/integration.shard/hot_reload_test.dart index 389297e3544..86eb9e0a587 100644 --- a/packages/flutter_tools/test/integration.shard/hot_reload_test.dart +++ b/packages/flutter_tools/test/integration.shard/hot_reload_test.dart @@ -108,14 +108,8 @@ void main() { await flutter.resume(); // we start paused so we can set up our TICK 1 listener before the app starts unawaited(sawTick1.future.timeout( const Duration(seconds: 5), - onTimeout: () { - // This print is useful for people debugging this test. Normally we would avoid printing in - // a test but this is an exception because it's useful ambient information. - // ignore: avoid_print - print('The test app is taking longer than expected to print its synchronization line...'); - }, + onTimeout: () { print('The test app is taking longer than expected to print its synchronization line...'); }, )); - printOnFailure('waiting for synchronization line...'); await sawTick1.future; // after this, app is in steady state await flutter.addBreakpoint( project.scheduledBreakpointUri, @@ -132,19 +126,19 @@ void main() { ); bool reloaded = false; final Future reloadFuture = flutter.hotReload().then((void value) { reloaded = true; }); - printOnFailure('waiting for pause...'); + print('waiting for pause...'); isolate = await flutter.waitForPause(); expect(isolate.pauseEvent.kind, equals(EventKind.kPauseBreakpoint)); - printOnFailure('waiting for debugger message...'); + print('waiting for debugger message...'); await sawDebuggerPausedMessage.future; expect(reloaded, isFalse); - printOnFailure('waiting for resume...'); + print('waiting for resume...'); await flutter.resume(); - printOnFailure('waiting for reload future...'); + print('waiting for reload future...'); await reloadFuture; expect(reloaded, isTrue); reloaded = false; - printOnFailure('subscription cancel...'); + print('subscription cancel...'); await subscription.cancel(); }); @@ -154,7 +148,7 @@ void main() { final Completer sawDebuggerPausedMessage2 = Completer(); final StreamSubscription subscription = flutter.stdout.listen( (String line) { - printOnFailure('[LOG]:"$line"'); + print('[LOG]:"$line"'); if (line.contains('(((TICK 1)))')) { expect(sawTick1.isCompleted, isFalse); sawTick1.complete(); diff --git a/packages/flutter_tools/test/integration.shard/hot_reload_with_asset_test.dart b/packages/flutter_tools/test/integration.shard/hot_reload_with_asset_test.dart index 550c6f25e9b..35308e8f682 100644 --- a/packages/flutter_tools/test/integration.shard/hot_reload_with_asset_test.dart +++ b/packages/flutter_tools/test/integration.shard/hot_reload_with_asset_test.dart @@ -47,7 +47,7 @@ void main() { onSecondLoad.complete(); } }); - flutter.stdout.listen(printOnFailure); + flutter.stdout.listen(print); await flutter.run(); await onFirstLoad.future; @@ -74,7 +74,7 @@ void main() { onSecondLoad.complete(); } }); - flutter.stdout.listen(printOnFailure); + flutter.stdout.listen(print); await flutter.run(); await onFirstLoad.future; diff --git a/packages/flutter_tools/test/integration.shard/ios_content_validation_test.dart b/packages/flutter_tools/test/integration.shard/ios_content_validation_test.dart index 1d3315683d3..0481fb67404 100644 --- a/packages/flutter_tools/test/integration.shard/ios_content_validation_test.dart +++ b/packages/flutter_tools/test/integration.shard/ios_content_validation_test.dart @@ -29,7 +29,7 @@ void main() { 'flutter', ); - processManager.runSync([ + final ProcessResult createResult = processManager.runSync([ flutterBin, ...getLocalEngineArguments(), 'create', @@ -39,6 +39,7 @@ void main() { 'objc', 'hello', ], workingDirectory: tempDir.path); + print(createResult.stdout); projectRoot = tempDir.childDirectory('hello').path; }); @@ -58,7 +59,7 @@ void main() { File outputAppFrameworkBinary; setUpAll(() { - processManager.runSync([ + final ProcessResult buildResult = processManager.runSync([ flutterBin, ...getLocalEngineArguments(), 'build', @@ -69,6 +70,7 @@ void main() { '--obfuscate', '--split-debug-info=foo debug info/', ], workingDirectory: projectRoot); + print(buildResult.stdout); buildPath = fileSystem.directory(fileSystem.path.join( projectRoot, @@ -123,6 +125,7 @@ void main() { infoPlistPath, ], ); + print(bonjourServices.stdout); final bool bonjourServicesFound = (bonjourServices.stdout as String).contains('_dartobservatory._tcp'); expect(bonjourServicesFound, buildMode == BuildMode.debug); @@ -137,6 +140,7 @@ void main() { infoPlistPath, ], ); + print(localNetworkUsage.stdout); final bool localNetworkUsageFound = localNetworkUsage.exitCode == 0; expect(localNetworkUsageFound, buildMode == BuildMode.debug); }); @@ -151,6 +155,7 @@ void main() { 'arm64', ], ); + print(symbols.stdout); final bool aotSymbolsFound = (symbols.stdout as String).contains('_kDartVmSnapshot'); expect(aotSymbolsFound, buildMode != BuildMode.debug); }); @@ -192,9 +197,7 @@ void main() { // Skip bitcode stripping since we just checked that above. }, ); - printOnFailure('Output of xcode_backend.sh:'); - printOnFailure(xcodeBackendResult.stdout.toString()); - printOnFailure(xcodeBackendResult.stderr.toString()); + print(xcodeBackendResult.stdout); expect(xcodeBackendResult.exitCode, 0); expect(outputFlutterFrameworkBinary.existsSync(), isTrue); @@ -208,6 +211,7 @@ void main() { 'hello', outputAppFrameworkBinary.path, ]); + print(grepResult.stdout); expect(grepResult.stdout, isNot(contains('matches'))); }); }); @@ -229,6 +233,7 @@ void main() { 'FLUTTER_XCODE_ONLY_ACTIVE_ARCH': 'NO', }, ); + print(buildSimulator.stdout); // This test case would fail if arm64 or x86_64 simulators could not build. expect(buildSimulator.exitCode, 0); @@ -246,6 +251,7 @@ void main() { final ProcessResult archs = processManager.runSync( ['file', simulatorAppFrameworkBinary.path], ); + print(archs.stdout); expect(archs.stdout, contains('Mach-O 64-bit dynamically linked shared library x86_64')); expect(archs.stdout, contains('Mach-O 64-bit dynamically linked shared library arm64')); }); diff --git a/packages/flutter_tools/test/integration.shard/macos_content_validation_test.dart b/packages/flutter_tools/test/integration.shard/macos_content_validation_test.dart index 11a4c7132fc..f0478145622 100644 --- a/packages/flutter_tools/test/integration.shard/macos_content_validation_test.dart +++ b/packages/flutter_tools/test/integration.shard/macos_content_validation_test.dart @@ -53,9 +53,8 @@ void main() { ]; final ProcessResult result = processManager.runSync(buildCommand, workingDirectory: workingDirectory); - printOnFailure('Output of flutter build macos:'); - printOnFailure(result.stdout.toString()); - printOnFailure(result.stderr.toString()); + print(result.stdout); + print(result.stderr); expect(result.exitCode, 0); expect(result.stdout, contains('Running pod install')); @@ -135,9 +134,8 @@ void main() { // Build again without cleaning. final ProcessResult secondBuild = processManager.runSync(buildCommand, workingDirectory: workingDirectory); - printOnFailure('Output of second build:'); - printOnFailure(secondBuild.stdout.toString()); - printOnFailure(secondBuild.stderr.toString()); + print(secondBuild.stdout); + print(secondBuild.stderr); expect(secondBuild.exitCode, 0); expect(secondBuild.stdout, isNot(contains('Running pod install'))); diff --git a/packages/flutter_tools/test/integration.shard/observatory_port_test.dart b/packages/flutter_tools/test/integration.shard/observatory_port_test.dart index 0912deb59d9..9968488967c 100644 --- a/packages/flutter_tools/test/integration.shard/observatory_port_test.dart +++ b/packages/flutter_tools/test/integration.shard/observatory_port_test.dart @@ -27,7 +27,7 @@ Future waitForObservatoryMessage(Process process, int port) async { process.stdout .transform(utf8.decoder) .listen((String line) { - printOnFailure(line); + print(line); if (line.contains('An Observatory debugger and profiler on Flutter test device is available at')) { if (line.contains('http://127.0.0.1:$port')) { completer.complete(); @@ -38,7 +38,7 @@ Future waitForObservatoryMessage(Process process, int port) async { }); process.stderr .transform(utf8.decoder) - .listen(printOnFailure); + .listen(print); return completer.future; } diff --git a/packages/flutter_tools/test/integration.shard/overall_experience_test.dart b/packages/flutter_tools/test/integration.shard/overall_experience_test.dart index 37cfe86a7c2..c2c015437c6 100644 --- a/packages/flutter_tools/test/integration.shard/overall_experience_test.dart +++ b/packages/flutter_tools/test/integration.shard/overall_experience_test.dart @@ -43,13 +43,6 @@ const ProcessManager processManager = LocalProcessManager(); final String flutterRoot = getFlutterRoot(); final String flutterBin = fileSystem.path.join(flutterRoot, 'bin', 'flutter'); -void debugPrint(String message) { - // This is called to intentionally print debugging output when a test is - // either taking too long or has failed. - // ignore: avoid_print - print(message); -} - typedef LineHandler = String/*?*/ Function(String line); abstract class Transition { @@ -143,7 +136,7 @@ class LogLine { String toString() => '$stamp $channel: $message'; void printClearly() { - debugPrint('$stamp $channel: ${clarify(message)}'); + print('$stamp $channel: ${clarify(message)}'); } static String clarify(String line) { @@ -204,9 +197,9 @@ Future runFlutter( int nextTransition = 0; void describeStatus() { if (transitions.isNotEmpty) { - debugPrint('Expected state transitions:'); + print('Expected state transitions:'); for (int index = 0; index < transitions.length; index += 1) { - debugPrint( + print( '${index.toString().padLeft(5)} ' '${index < nextTransition ? 'ALREADY MATCHED ' : index == nextTransition ? 'NOW WAITING FOR>' : @@ -214,9 +207,9 @@ Future runFlutter( } } if (logs.isEmpty) { - debugPrint('So far nothing has been logged${ debug ? "" : "; use debug:true to print all output" }.'); + print('So far nothing has been logged${ debug ? "" : "; use debug:true to print all output" }.'); } else { - debugPrint('Log${ debug ? "" : " (only contains logged lines; use debug:true to print all output)" }:'); + print('Log${ debug ? "" : " (only contains logged lines; use debug:true to print all output)" }:'); for (final LogLine log in logs) { log.printClearly(); } @@ -228,12 +221,12 @@ Future runFlutter( if (!streamingLogs) { streamingLogs = true; if (!debug) { - debugPrint('Test is taking a long time (${clock.elapsed.inSeconds} seconds so far).'); + print('Test is taking a long time (${clock.elapsed.inSeconds} seconds so far).'); } describeStatus(); - debugPrint('(streaming all logs from this point on...)'); + print('(streaming all logs from this point on...)'); } else { - debugPrint('(taking a long time...)'); + print('(taking a long time...)'); } } String stamp() => '[${(clock.elapsed.inMilliseconds / 1000.0).toStringAsFixed(1).padLeft(5, " ")}s]'; @@ -247,7 +240,7 @@ Future runFlutter( } if (nextTransition < transitions.length && transitions[nextTransition].matches(line)) { if (streamingLogs) { - debugPrint('(matched ${transitions[nextTransition]})'); + print('(matched ${transitions[nextTransition]})'); } if (transitions[nextTransition].logging != null) { if (!logging && transitions[nextTransition].logging/*!*/) { @@ -256,9 +249,9 @@ Future runFlutter( logging = transitions[nextTransition].logging/*!*/; if (streamingLogs) { if (logging) { - debugPrint('(enabled logging)'); + print('(enabled logging)'); } else { - debugPrint('(disabled logging)'); + print('(disabled logging)'); } } } @@ -293,8 +286,8 @@ Future runFlutter( process.stdout.transform(utf8.decoder).transform(const LineSplitter()).listen(processStdout); process.stderr.transform(utf8.decoder).transform(const LineSplitter()).listen(processStderr); unawaited(process.exitCode.timeout(expectedMaxDuration, onTimeout: () { // This is a failure timeout, must not be short. - debugPrint('${stamp()} (process is not quitting, trying to send a "q" just in case that helps)'); - debugPrint('(a functional test should never reach this point)'); + print('${stamp()} (process is not quitting, trying to send a "q" just in case that helps)'); + print('(a functional test should never reach this point)'); final LogLine inLog = LogLine('stdin', stamp(), 'q'); logs.add(inLog); if (streamingLogs) { @@ -305,24 +298,24 @@ Future runFlutter( }).catchError((Object error) { /* ignore errors here, they will be reported on the next line */ })); final int exitCode = await process.exitCode; if (streamingLogs) { - debugPrint('${stamp()} (process terminated with exit code $exitCode)'); + print('${stamp()} (process terminated with exit code $exitCode)'); } timeout?.cancel(); if (nextTransition < transitions.length) { - debugPrint('The subprocess terminated before all the expected transitions had been matched.'); + print('The subprocess terminated before all the expected transitions had been matched.'); if (logs.any((LogLine line) => line.couldBeCrash)) { - debugPrint('The subprocess may in fact have crashed. Check the stderr logs below.'); + print('The subprocess may in fact have crashed. Check the stderr logs below.'); } - debugPrint('The transition that we were hoping to see next but that we never saw was:'); - debugPrint('${nextTransition.toString().padLeft(5)} NOW WAITING FOR> ${transitions[nextTransition]}'); + print('The transition that we were hoping to see next but that we never saw was:'); + print('${nextTransition.toString().padLeft(5)} NOW WAITING FOR> ${transitions[nextTransition]}'); if (!streamingLogs) { describeStatus(); - debugPrint('(process terminated with exit code $exitCode)'); + print('(process terminated with exit code $exitCode)'); } throw TestFailure('Missed some expected transitions.'); } if (streamingLogs) { - debugPrint('${stamp()} (completed execution successfully!)'); + print('${stamp()} (completed execution successfully!)'); } return ProcessTestResult(exitCode, logs); } diff --git a/packages/flutter_tools/test/integration.shard/test_driver.dart b/packages/flutter_tools/test/integration.shard/test_driver.dart index c9a0e98eb60..00d00b744b5 100644 --- a/packages/flutter_tools/test/integration.shard/test_driver.dart +++ b/packages/flutter_tools/test/integration.shard/test_driver.dart @@ -79,10 +79,6 @@ abstract class FlutterTestDriver { lastTime = time; } if (_printDebugOutputToStdOut) { - // This is the one place in this file that can call print. It is gated by - // _printDebugOutputToStdOut which should not be set to true in CI; it is - // intended only for use in local debugging. - // ignore: avoid_print print('$time$_logPrefix$line'); } } diff --git a/packages/flutter_tools/test/integration.shard/test_test.dart b/packages/flutter_tools/test/integration.shard/test_test.dart index 67dcef1af46..bb2aa3751f8 100644 --- a/packages/flutter_tools/test/integration.shard/test_test.dart +++ b/packages/flutter_tools/test/integration.shard/test_test.dart @@ -215,10 +215,6 @@ void main() { } expect(result.exitCode, 0); }); - - testWithoutContext('flutter gold skips tests where the expectations are missing', () async { - return _testFile('flutter_gold', automatedTestsDirectory, flutterTestDirectory, exitCode: isZero); - }); } Future _testFile( diff --git a/packages/flutter_tools/test/integration.shard/timeline_test.dart b/packages/flutter_tools/test/integration.shard/timeline_test.dart index 9939b242d0e..d06952b55d7 100644 --- a/packages/flutter_tools/test/integration.shard/timeline_test.dart +++ b/packages/flutter_tools/test/integration.shard/timeline_test.dart @@ -40,8 +40,6 @@ void main() { // Regression test for https://github.com/flutter/flutter/issues/79498 testWithoutContext('Can connect to the timeline without getting ANR from the application', () async { final Timer timer = Timer(const Duration(minutes: 5), () { - // This message is intended to show up in CI logs. - // ignore: avoid_print print( 'Warning: test isolate is still active after 5 minutes. This is likely an ' 'app-not-responding error and not a flake. See https://github.com/flutter/flutter/issues/79498 ' diff --git a/packages/flutter_tools/test/integration.shard/variable_expansion_windows.dart b/packages/flutter_tools/test/integration.shard/variable_expansion_windows.dart index 0e6923f9634..179d7429038 100644 --- a/packages/flutter_tools/test/integration.shard/variable_expansion_windows.dart +++ b/packages/flutter_tools/test/integration.shard/variable_expansion_windows.dart @@ -4,6 +4,5 @@ // Not a test file, invoked by `variable_expansion_windows_test.dart`. void main(List args) { - // This print is used for communicating with the test host. - print('args: $args'); // ignore: avoid_print + print('args: $args'); } diff --git a/packages/flutter_tools/test/src/common.dart b/packages/flutter_tools/test/src/common.dart index feb0ad49542..79c9192f398 100644 --- a/packages/flutter_tools/test/src/common.dart +++ b/packages/flutter_tools/test/src/common.dart @@ -27,9 +27,6 @@ void tryToDelete(Directory directory) { directory.deleteSync(recursive: true); } } on FileSystemException catch (error) { - // We print this so that it's visible in the logs, to get an idea of how - // common this problem is, and if any patterns are ever noticed by anyone. - // ignore: avoid_print print('Failed to delete ${directory.path}: $error'); } } diff --git a/packages/flutter_tools/test/src/context.dart b/packages/flutter_tools/test/src/context.dart index 68ece0dd63b..38abdae9d24 100644 --- a/packages/flutter_tools/test/src/context.dart +++ b/packages/flutter_tools/test/src/context.dart @@ -127,7 +127,7 @@ void testUsingContext( }, body: () { final String flutterRoot = getFlutterRoot(); - return runZonedGuarded>(() { + return runZoned>(() { try { return context.run( // Apply the overrides to the test context in the zone since their @@ -148,10 +148,9 @@ void testUsingContext( _printBufferedErrors(context); rethrow; } - }, (Object error, StackTrace stackTrace) { - // When things fail, it's ok to print to the console! - print(error); // ignore: avoid_print - print(stackTrace); // ignore: avoid_print + }, onError: (Object error, StackTrace stackTrace) { // ignore: deprecated_member_use + print(error); + print(stackTrace); _printBufferedErrors(context); throw error; }); @@ -177,9 +176,7 @@ void _printBufferedErrors(AppContext testContext) { if (testContext.get() is BufferLogger) { final BufferLogger bufferLogger = testContext.get() as BufferLogger; if (bufferLogger.errorText.isNotEmpty) { - // This is where the logger outputting errors is implemented, so it has - // to use `print`. - print(bufferLogger.errorText); // ignore: avoid_print + print(bufferLogger.errorText); } bufferLogger.clear(); } diff --git a/packages/flutter_tools/test/web.shard/hot_reload_web_test.dart b/packages/flutter_tools/test/web.shard/hot_reload_web_test.dart index 57732e3515e..6a69626b9f1 100644 --- a/packages/flutter_tools/test/web.shard/hot_reload_web_test.dart +++ b/packages/flutter_tools/test/web.shard/hot_reload_web_test.dart @@ -38,6 +38,7 @@ void main() { testWithoutContext('newly added code executes during hot restart', () async { final Completer completer = Completer(); final StreamSubscription subscription = flutter.stdout.listen((String line) { + print(line); if (line.contains('(((((RELOAD WORKED)))))')) { completer.complete(); } @@ -55,6 +56,7 @@ void main() { testWithoutContext('newly added code executes during hot restart - canvaskit', () async { final Completer completer = Completer(); final StreamSubscription subscription = flutter.stdout.listen((String line) { + print(line); if (line.contains('(((((RELOAD WORKED)))))')) { completer.complete(); } diff --git a/packages/flutter_tools/tool/analysis_options.yaml b/packages/flutter_tools/tool/analysis_options.yaml deleted file mode 100644 index 19391e33ff9..00000000000 --- a/packages/flutter_tools/tool/analysis_options.yaml +++ /dev/null @@ -1,5 +0,0 @@ -include: ../analysis_options.yaml - -linter: - rules: - avoid_print: false # These are CLI tools which print as a matter of course. diff --git a/packages/fuchsia_remote_debug_protocol/lib/src/common/logging.dart b/packages/fuchsia_remote_debug_protocol/lib/src/common/logging.dart index b2250a745d6..4dd4eaee82a 100644 --- a/packages/fuchsia_remote_debug_protocol/lib/src/common/logging.dart +++ b/packages/fuchsia_remote_debug_protocol/lib/src/common/logging.dart @@ -51,7 +51,6 @@ typedef LoggingFunction = void Function(LogMessage log); /// /// Exits with status code 1 if the `log` is [LoggingLevel.severe]. void defaultLoggingFunction(LogMessage log) { - // ignore: avoid_print print('[${log.levelName}]::${log.tag}--${log.time}: ${log.message}'); if (log.level == LoggingLevel.severe) { exit(1); diff --git a/packages/integration_test/lib/integration_test.dart b/packages/integration_test/lib/integration_test.dart index ea69c02843f..83489150fc8 100644 --- a/packages/integration_test/lib/integration_test.dart +++ b/packages/integration_test/lib/integration_test.dart @@ -64,7 +64,7 @@ class IntegrationTestWidgetsFlutterBinding extends LiveTestWidgetsFlutterBinding }, ); } on MissingPluginException { - debugPrint(r''' + print(r''' Warning: integration_test plugin was not detected. If you're running the tests with `flutter drive`, please make sure your tests @@ -391,7 +391,7 @@ https://flutter.dev/docs/testing/integration-tests#testing-on-firebase-test-lab count++; await Future.delayed(const Duration(seconds: 2)); if (count > 20) { - debugPrint('delayForFrameTimings is taking longer than expected...'); + print('delayForFrameTimings is taking longer than expected...'); } } } diff --git a/packages/integration_test/lib/integration_test_driver.dart b/packages/integration_test/lib/integration_test_driver.dart index b3e654c2674..149eec43142 100644 --- a/packages/integration_test/lib/integration_test_driver.dart +++ b/packages/integration_test/lib/integration_test_driver.dart @@ -2,9 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// This is a CLI library; we use prints as part of the interface. -// ignore_for_file: avoid_print - import 'dart:async'; import 'dart:convert'; import 'dart:io'; diff --git a/packages/integration_test/lib/integration_test_driver_extended.dart b/packages/integration_test/lib/integration_test_driver_extended.dart index 3ed64734792..9131858cce6 100644 --- a/packages/integration_test/lib/integration_test_driver_extended.dart +++ b/packages/integration_test/lib/integration_test_driver_extended.dart @@ -2,9 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// This is a CLI library; we use prints as part of the interface. -// ignore_for_file: avoid_print - import 'dart:async'; import 'dart:io'; diff --git a/packages/integration_test/test/binding_test.dart b/packages/integration_test/test/binding_test.dart index a77ab58deaf..c6ceb544d1b 100644 --- a/packages/integration_test/test/binding_test.dart +++ b/packages/integration_test/test/binding_test.dart @@ -104,6 +104,7 @@ Future main() async { testWidgets('Test traceAction', (WidgetTester tester) async { await integrationBinding.enableTimeline(vmService: fakeVM); await integrationBinding.traceAction(() async {}); + print(integrationBinding.reportData); expect(integrationBinding.reportData, isNotNull); expect(integrationBinding.reportData!.containsKey('timeline'), true); expect( diff --git a/packages/integration_test/test/data/fail_test_script.dart b/packages/integration_test/test/data/fail_test_script.dart index 9dda0cb6c5e..c2c5f6302e6 100644 --- a/packages/integration_test/test/data/fail_test_script.dart +++ b/packages/integration_test/test/data/fail_test_script.dart @@ -10,8 +10,6 @@ import 'package:integration_test/integration_test.dart'; Future main() async { final IntegrationTestWidgetsFlutterBinding binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized() as IntegrationTestWidgetsFlutterBinding; binding.allTestsPassed.future.then((_) { - // We use this print to communicate with ../binding_fail_test.dart - // ignore: avoid_print print('IntegrationTestWidgetsFlutterBinding test results: ${jsonEncode(binding.results)}'); }); diff --git a/packages/integration_test/test/data/fail_then_pass_test_script.dart b/packages/integration_test/test/data/fail_then_pass_test_script.dart index c27f20659fa..df97bc474f8 100644 --- a/packages/integration_test/test/data/fail_then_pass_test_script.dart +++ b/packages/integration_test/test/data/fail_then_pass_test_script.dart @@ -10,8 +10,6 @@ import 'package:integration_test/integration_test.dart'; Future main() async { final IntegrationTestWidgetsFlutterBinding binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized() as IntegrationTestWidgetsFlutterBinding; binding.allTestsPassed.future.then((_) { - // We use this print to communicate with ../binding_fail_test.dart - // ignore: avoid_print print('IntegrationTestWidgetsFlutterBinding test results: ${jsonEncode(binding.results)}'); }); diff --git a/packages/integration_test/test/data/pass_test_script.dart b/packages/integration_test/test/data/pass_test_script.dart index e40b865f567..3ab5040cc72 100644 --- a/packages/integration_test/test/data/pass_test_script.dart +++ b/packages/integration_test/test/data/pass_test_script.dart @@ -10,8 +10,6 @@ import 'package:integration_test/integration_test.dart'; Future main() async { final IntegrationTestWidgetsFlutterBinding binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized() as IntegrationTestWidgetsFlutterBinding; binding.allTestsPassed.future.then((_) { - // We use this print to communicate with ../binding_fail_test.dart - // ignore: avoid_print print('IntegrationTestWidgetsFlutterBinding test results: ${jsonEncode(binding.results)}'); }); diff --git a/packages/integration_test/test/data/pass_then_fail_test_script.dart b/packages/integration_test/test/data/pass_then_fail_test_script.dart index 92400baadb6..c87bc00f577 100644 --- a/packages/integration_test/test/data/pass_then_fail_test_script.dart +++ b/packages/integration_test/test/data/pass_then_fail_test_script.dart @@ -10,8 +10,6 @@ import 'package:integration_test/integration_test.dart'; Future main() async { final IntegrationTestWidgetsFlutterBinding binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized() as IntegrationTestWidgetsFlutterBinding; binding.allTestsPassed.future.then((_) { - // We use this print to communicate with ../binding_fail_test.dart - // ignore: avoid_print print('IntegrationTestWidgetsFlutterBinding test results: ${jsonEncode(binding.results)}'); });