Unverified Commit 8b973f01 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[flutter_tools] add package_config.json to analyze_once_test.dart (#69059)

* [flutter_tools] add package_config.json to analyze_once_test.dart
parent 70aa1227
......@@ -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 {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment