From 8b973f01c47d13ccd4e4fcab44bdcc9f8b02130a Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Mon, 26 Oct 2020 15:46:51 -0700 Subject: [PATCH] [flutter_tools] add package_config.json to analyze_once_test.dart (#69059) * [flutter_tools] add package_config.json to analyze_once_test.dart --- .../permeable/analyze_once_test.dart | 34 +++++++++++++++---- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/packages/flutter_tools/test/commands.shard/permeable/analyze_once_test.dart b/packages/flutter_tools/test/commands.shard/permeable/analyze_once_test.dart index f3b7bc6b22..d1274626ab 100644 --- a/packages/flutter_tools/test/commands.shard/permeable/analyze_once_test.dart +++ b/packages/flutter_tools/test/commands.shard/permeable/analyze_once_test.dart @@ -65,7 +65,7 @@ void main() { logger.clear(); } - void _createDotPackages(String projectPath) { + void _createDotPackages(String projectPath, [bool nullSafe = false]) { final StringBuffer flutterRootUri = StringBuffer('file://'); final String canonicalizedFlutterRootPath = fileSystem.path.canonicalize(Cache.flutterRoot); if (platform.isWindows) { @@ -76,12 +76,32 @@ void main() { flutterRootUri.write(canonicalizedFlutterRootPath); } final String dotPackagesSrc = ''' -# Generated -flutter:$flutterRootUri/packages/flutter/lib/ -sky_engine:$flutterRootUri/bin/cache/pkg/sky_engine/lib/ -flutter_project:lib/ +{ + "configVersion": 2, + "packages": [ + { + "name": "flutter", + "rootUri": "$flutterRootUri/packages/flutter", + "packageUri": "lib/", + "languageVersion": "2.10" + }, + { + "name": "sky_engine", + "rootUri": "$flutterRootUri/bin/cache/pkg/sky_engine", + "packageUri": "lib/", + "languageVersion": "2.10" + }, + { + "name": "flutter_project", + "rootUri": "../", + "packageUri": "lib/", + "languageVersion": "${nullSafe ? "2.10" : "2.7"}" + } + ] +} '''; - fileSystem.file(fileSystem.path.join(projectPath, '.packages')) + + fileSystem.file(fileSystem.path.join(projectPath, '.dart_tool', 'package_config.json')) ..createSync(recursive: true) ..writeAsStringSync(dotPackagesSrc); } @@ -330,7 +350,7 @@ StringBuffer bar = StringBuffer('baz'); int? bar; '''; final Directory tempDir = fileSystem.systemTempDirectory.createTempSync('flutter_analyze_once_test_null_safety.'); - _createDotPackages(tempDir.path); + _createDotPackages(tempDir.path, true); tempDir.childFile('main.dart').writeAsStringSync(contents); try {