From 9062f80146fab9239104f7b2671ba5b7b2333b4d Mon Sep 17 00:00:00 2001 From: Sam Rawlins Date: Wed, 14 Jan 2026 11:03:09 -0800 Subject: [PATCH] analyzer_testing: Deprecate the flutter_test mock; only used in two DAS tests. Work towards https://github.com/dart-lang/sdk/issues/61597 Change-Id: I32caa38bff42ad9117829cca9be8b892da228a9e Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/472960 Commit-Queue: Samuel Rawlins Reviewed-by: Brian Wilkerson --- .../test/support/configuration_files.dart | 20 +++++++++++++++++-- pkg/analyzer_testing/CHANGELOG.md | 2 ++ pkg/analyzer_testing/api.txt | 2 +- .../lib/mock_packages/mock_packages.dart | 4 ++++ 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/pkg/analysis_server/test/support/configuration_files.dart b/pkg/analysis_server/test/support/configuration_files.dart index 086b865c3e4..e26cfc3c715 100644 --- a/pkg/analysis_server/test/support/configuration_files.dart +++ b/pkg/analysis_server/test/support/configuration_files.dart @@ -78,8 +78,24 @@ mixin ConfigurationFilesMixin on MockPackagesMixin { } if (addFlutterTestPackageDep) { - var libFolder = addFlutterTest(); - config.add(name: 'flutter_test', rootPath: libFolder.parent.path); + var flutterTestRootPath = '/packages/flutter_test'; + + var flutterTestRoot = resourceProvider.getFolder(flutterTestRootPath); + var libFolder = flutterTestRoot.getChildAssumingFolder('lib')..create(); + libFolder.getChildAssumingFile('flutter_test.dart').writeAsStringSync(r''' +void test(Object description, dynamic Function() body) {} + +void group(Object description, void Function() body) {} + +void main() { + // Because this file is called 'flutter_test.dart' and is inside the 'test' + // folder, it will be considered a test suite. To avoid it failing the bots + // with "Invoked Dart programs must have a 'main' function defined", provide + // an empty main function. +} + +'''); + config.add(name: 'flutter_test', rootPath: flutterTestRootPath); } if (addVectorMathPackageDep) { diff --git a/pkg/analyzer_testing/CHANGELOG.md b/pkg/analyzer_testing/CHANGELOG.md index 048df618837..0805a29699f 100644 --- a/pkg/analyzer_testing/CHANGELOG.md +++ b/pkg/analyzer_testing/CHANGELOG.md @@ -1,5 +1,7 @@ ## 0.1.9-dev - Deprecate `MockPackagesMixin.addUI`; This is replaced by `addSkyEngine`. +- Deprecate `MockPackagesMixin.addFlutterTest`. A mock `flutter_test` package + can still be written with `PubPackageResolutionTest.newPackage`. ## 0.1.8 diff --git a/pkg/analyzer_testing/api.txt b/pkg/analyzer_testing/api.txt index 4b7f23d7d37..ea6c3afa67d 100644 --- a/pkg/analyzer_testing/api.txt +++ b/pkg/analyzer_testing/api.txt @@ -29,7 +29,7 @@ package:analyzer_testing/mock_packages/mock_packages.dart: addFfi (method: Folder Function()) addFixnum (method: Folder Function()) addFlutter (method: Folder Function()) - addFlutterTest (method: Folder Function()) + addFlutterTest (method: Folder Function(), deprecated) addJs (method: Folder Function(), deprecated) addKernel (method: Folder Function(), deprecated) addMeta (method: Folder Function()) diff --git a/pkg/analyzer_testing/lib/mock_packages/mock_packages.dart b/pkg/analyzer_testing/lib/mock_packages/mock_packages.dart index c7a8c09653f..40e3098510f 100644 --- a/pkg/analyzer_testing/lib/mock_packages/mock_packages.dart +++ b/pkg/analyzer_testing/lib/mock_packages/mock_packages.dart @@ -141,6 +141,10 @@ mixin MockPackagesMixin { return packageFolder.getChildAssumingFolder('lib'); } + @Deprecated( + 'The mock flutter_test package is deprecated; use ' + '`PubPackageResolutionTest.newPackage` to make a custom mock', + ) Folder addFlutterTest() { var packageFolder = _addFiles('flutter_test'); return packageFolder.getChildAssumingFolder('lib');