From 321abcbe4f70c6f858c19bfb6f260a703cabf840 Mon Sep 17 00:00:00 2001 From: pdblasi-google <109253501+pdblasi-google@users.noreply.github.com> Date: Tue, 27 Jun 2023 11:01:06 -0700 Subject: [PATCH] Adds `dart_fix` support to `integration_test` (#129579) * Adds fix for `IntegrationTestWidgetsFlutterBinding.runTest(timeout)` to support first round of deprecations for `flutter_test` Resolves #124346 --- dev/bots/test.dart | 1 + packages/flutter_test/lib/src/binding.dart | 6 --- .../integration_test/analysis_options.yaml | 5 +++ .../integration_test/lib/fix_data/README.md | 45 +++++++++++++++++++ ...egration_test_widgets_flutter_binding.yaml | 33 ++++++++++++++ .../lib/fix_data/template.yaml | 25 +++++++++++ .../integration_test/test_fixes/.dartignore | 0 .../test_fixes/analysis_options.yaml | 1 + ...egration_test_widgets_flutter_binding.dart | 15 +++++++ ...n_test_widgets_flutter_binding.dart.expect | 13 ++++++ 10 files changed, 138 insertions(+), 6 deletions(-) create mode 100644 packages/integration_test/analysis_options.yaml create mode 100644 packages/integration_test/lib/fix_data/README.md create mode 100644 packages/integration_test/lib/fix_data/fix_integration_test/fix_binding/fix_integration_test_widgets_flutter_binding.yaml create mode 100644 packages/integration_test/lib/fix_data/template.yaml create mode 100644 packages/integration_test/test_fixes/.dartignore create mode 100644 packages/integration_test/test_fixes/analysis_options.yaml create mode 100644 packages/integration_test/test_fixes/integration_test/binding/integration_test_widgets_flutter_binding.dart create mode 100644 packages/integration_test/test_fixes/integration_test/binding/integration_test_widgets_flutter_binding.dart.expect diff --git a/dev/bots/test.dart b/dev/bots/test.dart index 6a911772c2..c994041f78 100644 --- a/dev/bots/test.dart +++ b/dev/bots/test.dart @@ -971,6 +971,7 @@ Future _runFrameworkTests() async { await runTracingTests(); await runFixTests('flutter'); await runFixTests('flutter_test'); + await runFixTests('integration_test'); await runPrivateTests(); } diff --git a/packages/flutter_test/lib/src/binding.dart b/packages/flutter_test/lib/src/binding.dart index a8d16b15f4..8075382793 100644 --- a/packages/flutter_test/lib/src/binding.dart +++ b/packages/flutter_test/lib/src/binding.dart @@ -783,8 +783,6 @@ abstract class TestWidgetsFlutterBinding extends BindingBase 'This parameter has no effect. Use the `timeout` parameter on `testWidgets` instead. ' 'This feature was deprecated after v2.6.0-1.0.pre.' ) - // TODO(pdblasi-google): Do not remove until https://github.com/flutter/flutter/issues/124346 - // is complete, as this removal will cascade into `integration_test` Duration? timeout, }); @@ -1458,8 +1456,6 @@ class AutomatedTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding { 'This parameter has no effect. Use the `timeout` parameter on `testWidgets` instead. ' 'This feature was deprecated after v2.6.0-1.0.pre.' ) - // TODO(pdblasi-google): Do not remove until https://github.com/flutter/flutter/issues/124346 - // is complete, as this removal will cascade into `integration_test` Duration? timeout, }) { assert(!inTest); @@ -2006,8 +2002,6 @@ class LiveTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding { 'This parameter has no effect. Use the `timeout` parameter on `testWidgets` instead. ' 'This feature was deprecated after v2.6.0-1.0.pre.' ) - // TODO(pdblasi-google): Do not remove until https://github.com/flutter/flutter/issues/124346 - // is complete, as this removal will cascade into `integration_test` Duration? timeout, }) { assert(!inTest); diff --git a/packages/integration_test/analysis_options.yaml b/packages/integration_test/analysis_options.yaml new file mode 100644 index 0000000000..e61f982d45 --- /dev/null +++ b/packages/integration_test/analysis_options.yaml @@ -0,0 +1,5 @@ +include: ../analysis_options.yaml + +analyzer: + exclude: + - "test_fixes/**" diff --git a/packages/integration_test/lib/fix_data/README.md b/packages/integration_test/lib/fix_data/README.md new file mode 100644 index 0000000000..748818fc61 --- /dev/null +++ b/packages/integration_test/lib/fix_data/README.md @@ -0,0 +1,45 @@ +## Directory contents + +The `.yaml` files in these directories are used to +define the [`dart fix` framework](https://dart.dev/tools/dart-fix) refactorings +used by `integration_test`. + +The number of fix rules defined in a file should not exceed 50 for better +maintainability. Searching for `title:` in a given `.yaml` file will account +for the number of fixes. Splitting out fix rules should be done by class. + +When adding a new `.yaml` file, make a copy of `template.yaml`. Each file should +be for a single class and named `fix_.yaml`. To make sure each file is +grouped with related classes, a `fix_` folder will contain all of the +fix files for the individual classes. + +See the flutter/packages/integration_test/test_fixes directory for the tests +that validate these fix rules. + +To run these tests locally, execute this command in the +flutter/packages/integration_test/test_fixes directory. +```sh +dart fix --compare-to-golden +``` + +For more documentation about Data Driven Fixes, see +https://dart.dev/go/data-driven-fixes#test-folder. + +To learn more about how fixes are authored in package:integration_test, see +https://github.com/flutter/flutter/wiki/Data-driven-Fixes + +## When making structural changes to this directory + +The tests in this directory are also invoked from external +repositories. Specifically, the CI system for the dart-lang/sdk repo +runs these tests in order to ensure that changes to the dart fix file +format do not break Flutter. + +See [tools/bots/flutter/analyze_flutter_flutter.sh](https://github.com/dart-lang/sdk/blob/main/tools/bots/flutter/analyze_flutter_flutter.sh) +for where the flutter fix tests are invoked for the dart repo. + +See [dev/bots/test.dart](https://github.com/flutter/flutter/blob/master/dev/bots/test.dart) +for where the flutter fix tests are invoked for the flutter/flutter repo. + +When possible, please coordinate changes to this directory that might affect the +`analyze_flutter_flutter.sh` script. diff --git a/packages/integration_test/lib/fix_data/fix_integration_test/fix_binding/fix_integration_test_widgets_flutter_binding.yaml b/packages/integration_test/lib/fix_data/fix_integration_test/fix_binding/fix_integration_test_widgets_flutter_binding.yaml new file mode 100644 index 0000000000..26092699f2 --- /dev/null +++ b/packages/integration_test/lib/fix_data/fix_integration_test/fix_binding/fix_integration_test_widgets_flutter_binding.yaml @@ -0,0 +1,33 @@ +# 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. + +# For details regarding the *Flutter Fix* feature, see +# https://flutter.dev/docs/development/tools/flutter-fix + +# Please add new fixes to the top of the file, separated by one blank line +# from other fixes. In a comment, include a link to the PR where the change +# requiring the fix was made. + +# Every fix must be tested. See the +# flutter/packages/integration_test/test_fixes/README.md file for instructions +# on testing these data driven fixes. + +# For documentation about this file format, see +# https://dart.dev/go/data-driven-fixes. + +# * Fixes in this file are for IntegrationTestWidgetsFlutterBinding from the +# integration_test/integration_test.dart file. * + +version: 1 +transforms: + # Changes made in https://github.com/flutter/flutter/pull/89952 + - title: "Remove timeout" + date: 2023-06-26 + element: + uris: [ 'integration_test.dart' ] + method: 'runTest' + inClass: 'IntegrationTestWidgetsFlutterBinding' + changes: + - kind: 'removeParameter' + name: 'timeout' diff --git a/packages/integration_test/lib/fix_data/template.yaml b/packages/integration_test/lib/fix_data/template.yaml new file mode 100644 index 0000000000..27c5d14a98 --- /dev/null +++ b/packages/integration_test/lib/fix_data/template.yaml @@ -0,0 +1,25 @@ +# 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. + +# For details regarding the *Flutter Fix* feature, see +# https://flutter.dev/docs/development/tools/flutter-fix + +# Please add new fixes to the top of the file, separated by one blank line +# from other fixes. In a comment, include a link to the PR where the change +# requiring the fix was made. + +# Every fix must be tested. See the +# flutter/packages/integration_test/lib/fix_data/README.md file for instructions +# on testing these data driven fixes. + +# For documentation about this file format, see +# https://dart.dev/go/data-driven-fixes. + +# * Fixes in this file are [for CLASS] from the file. * + +# Uncomment version & transforms, and follow with fixes. +# version: 1 +# transforms: + +# Before adding a new fix: read instructions at the top of this file. diff --git a/packages/integration_test/test_fixes/.dartignore b/packages/integration_test/test_fixes/.dartignore new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/integration_test/test_fixes/analysis_options.yaml b/packages/integration_test/test_fixes/analysis_options.yaml new file mode 100644 index 0000000000..7cca7b1d5c --- /dev/null +++ b/packages/integration_test/test_fixes/analysis_options.yaml @@ -0,0 +1 @@ +# This ensures that parent analysis options do not accidentally break the fix tests. diff --git a/packages/integration_test/test_fixes/integration_test/binding/integration_test_widgets_flutter_binding.dart b/packages/integration_test/test_fixes/integration_test/binding/integration_test_widgets_flutter_binding.dart new file mode 100644 index 0000000000..2360ceccd7 --- /dev/null +++ b/packages/integration_test/test_fixes/integration_test/binding/integration_test_widgets_flutter_binding.dart @@ -0,0 +1,15 @@ +// 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. + +import 'package:integration_test/integration_test.dart'; + +void main() { + final binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized(); + binding.runTest( + () async { }, + () { }, + // Changes made in https://github.com/flutter/flutter/pull/89952 + timeout: Duration(minutes: 30), + ); +} diff --git a/packages/integration_test/test_fixes/integration_test/binding/integration_test_widgets_flutter_binding.dart.expect b/packages/integration_test/test_fixes/integration_test/binding/integration_test_widgets_flutter_binding.dart.expect new file mode 100644 index 0000000000..8abee159a5 --- /dev/null +++ b/packages/integration_test/test_fixes/integration_test/binding/integration_test_widgets_flutter_binding.dart.expect @@ -0,0 +1,13 @@ +// 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. + +import 'package:integration_test/integration_test.dart'; + +void main() { + final binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized(); + binding.runTest( + () async { }, + () { }, + ); +}