Unverified Commit a40ee8a3 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[flutter_tools] migrate .packages to package_config, partial (#70200)

parent 5b19328f
...@@ -14,7 +14,6 @@ import 'package:flutter_tools/src/base/io.dart'; ...@@ -14,7 +14,6 @@ import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/build_info.dart'; import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/context_runner.dart'; import 'package:flutter_tools/src/context_runner.dart';
import 'package:flutter_tools/src/dart/package_map.dart';
import 'package:flutter_tools/src/artifacts.dart'; import 'package:flutter_tools/src/artifacts.dart';
import 'package:flutter_tools/src/globals.dart' as globals; import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:flutter_tools/src/project.dart'; import 'package:flutter_tools/src/project.dart';
...@@ -108,13 +107,11 @@ Future<void> run(List<String> args) async { ...@@ -108,13 +107,11 @@ Future<void> run(List<String> args) async {
// TODO(tvolkert): Remove once flutter_tester no longer looks for this. // TODO(tvolkert): Remove once flutter_tester no longer looks for this.
globals.fs.link(sdkRootDest.childFile('platform.dill').path).createSync('platform_strong.dill'); globals.fs.link(sdkRootDest.childFile('platform.dill').path).createSync('platform_strong.dill');
globalPackagesPath =
globals.fs.path.normalize(globals.fs.path.absolute(argResults[_kOptionPackages] as String));
Directory testDirectory; Directory testDirectory;
CoverageCollector collector; CoverageCollector collector;
if (argResults['coverage'] as bool) { if (argResults['coverage'] as bool) {
collector = CoverageCollector( collector = CoverageCollector(
packagesPath: globals.fs.path.normalize(globals.fs.path.absolute(argResults[_kOptionPackages] as String)),
libraryPredicate: (String libraryName) { libraryPredicate: (String libraryName) {
// If we have a specified coverage directory then accept all libraries. // If we have a specified coverage directory then accept all libraries.
if (coverageDirectory != null) { if (coverageDirectory != null) {
...@@ -147,7 +144,12 @@ Future<void> run(List<String> args) async { ...@@ -147,7 +144,12 @@ Future<void> run(List<String> args) async {
watcher: collector, watcher: collector,
ipv6: false, ipv6: false,
enableObservatory: collector != null, enableObservatory: collector != null,
buildInfo: BuildInfo.debug, buildInfo: BuildInfo(
BuildMode.debug,
'',
treeShakeIcons: false,
packagesPath: globals.fs.path.normalize(globals.fs.path.absolute(argResults[_kOptionPackages] as String),
)),
precompiledDillFiles: tests, precompiledDillFiles: tests,
concurrency: math.max(1, globals.platform.numberOfProcessors - 2), concurrency: math.max(1, globals.platform.numberOfProcessors - 2),
icudtlPath: globals.fs.path.absolute(argResults[_kOptionIcudtl] as String), icudtlPath: globals.fs.path.absolute(argResults[_kOptionIcudtl] as String),
......
...@@ -32,7 +32,7 @@ class BuildInfo { ...@@ -32,7 +32,7 @@ class BuildInfo {
this.dartExperiments = const <String>[], this.dartExperiments = const <String>[],
@required this.treeShakeIcons, @required this.treeShakeIcons,
this.performanceMeasurementFile, this.performanceMeasurementFile,
this.packagesPath = '.packages', this.packagesPath = '.packages', // TODO(jonahwilliams): make this required and remove the default.
this.nullSafetyMode = NullSafetyMode.autodetect, this.nullSafetyMode = NullSafetyMode.autodetect,
this.codeSizeDirectory, this.codeSizeDirectory,
this.androidGradleDaemon = true, this.androidGradleDaemon = true,
......
...@@ -81,9 +81,7 @@ class BundleBuilder { ...@@ -81,9 +81,7 @@ class BundleBuilder {
String manifestPath = defaultManifestPath, String manifestPath = defaultManifestPath,
String applicationKernelFilePath, String applicationKernelFilePath,
String depfilePath, String depfilePath,
String privateKeyPath = defaultPrivateKeyPath,
String assetDirPath, String assetDirPath,
String packagesPath,
bool precompiledSnapshot = false, bool precompiledSnapshot = false,
bool reportLicensedPackages = false, bool reportLicensedPackages = false,
bool trackWidgetCreation = false, bool trackWidgetCreation = false,
...@@ -96,7 +94,6 @@ class BundleBuilder { ...@@ -96,7 +94,6 @@ class BundleBuilder {
mainPath ??= defaultMainPath; mainPath ??= defaultMainPath;
depfilePath ??= defaultDepfilePath; depfilePath ??= defaultDepfilePath;
assetDirPath ??= getAssetBuildDirectory(); assetDirPath ??= getAssetBuildDirectory();
packagesPath ??= globals.fs.path.absolute('.packages');
final FlutterProject flutterProject = FlutterProject.current(); final FlutterProject flutterProject = FlutterProject.current();
await buildWithAssemble( await buildWithAssemble(
buildMode: buildInfo.mode, buildMode: buildInfo.mode,
......
...@@ -741,7 +741,7 @@ class PubDependencies extends ArtifactSet { ...@@ -741,7 +741,7 @@ class PubDependencies extends ArtifactSet {
FileSystem fileSystem, FileSystem fileSystem,
) async { ) async {
final File toolPackageConfig = fileSystem.file( final File toolPackageConfig = fileSystem.file(
fileSystem.path.join(_flutterRoot(), 'packages', 'flutter_tools', kPackagesFileName), fileSystem.path.join(_flutterRoot(), 'packages', 'flutter_tools', '.dart_tool', 'package_config.json'),
); );
if (!toolPackageConfig.existsSync()) { if (!toolPackageConfig.existsSync()) {
return false; return false;
......
...@@ -121,7 +121,6 @@ class BuildBundleCommand extends BuildSubCommand { ...@@ -121,7 +121,6 @@ class BuildBundleCommand extends BuildSubCommand {
mainPath: targetFile, mainPath: targetFile,
manifestPath: stringArg('manifest'), manifestPath: stringArg('manifest'),
depfilePath: stringArg('depfile'), depfilePath: stringArg('depfile'),
privateKeyPath: stringArg('private-key'),
assetDirPath: stringArg('asset-dir'), assetDirPath: stringArg('asset-dir'),
precompiledSnapshot: boolArg('precompiled'), precompiledSnapshot: boolArg('precompiled'),
reportLicensedPackages: boolArg('report-licensed-packages'), reportLicensedPackages: boolArg('report-licensed-packages'),
......
...@@ -171,6 +171,7 @@ class TestCommand extends FlutterCommand { ...@@ -171,6 +171,7 @@ class TestCommand extends FlutterCommand {
final List<String> plainNames = stringsArg('plain-name'); final List<String> plainNames = stringsArg('plain-name');
final String tags = stringArg('tags'); final String tags = stringArg('tags');
final String excludeTags = stringArg('exclude-tags'); final String excludeTags = stringArg('exclude-tags');
final BuildInfo buildInfo = getBuildInfo(forcedBuildMode: BuildMode.debug);
if (buildTestAssets && flutterProject.manifest.assets.isNotEmpty) { if (buildTestAssets && flutterProject.manifest.assets.isNotEmpty) {
await _buildTestAsset(); await _buildTestAsset();
...@@ -225,6 +226,8 @@ class TestCommand extends FlutterCommand { ...@@ -225,6 +226,8 @@ class TestCommand extends FlutterCommand {
collector = CoverageCollector( collector = CoverageCollector(
verbose: !machine, verbose: !machine,
libraryPredicate: (String libraryName) => libraryName.contains(projectName), libraryPredicate: (String libraryName) => libraryName.contains(projectName),
// TODO(jonahwilliams): file bug for incorrect URI handling on windws
packagesPath: globals.fs.path.absolute('.packages'),
); );
} }
...@@ -236,7 +239,6 @@ class TestCommand extends FlutterCommand { ...@@ -236,7 +239,6 @@ class TestCommand extends FlutterCommand {
} }
final bool disableServiceAuthCodes = boolArg('disable-service-auth-codes'); final bool disableServiceAuthCodes = boolArg('disable-service-auth-codes');
final BuildInfo buildInfo = getBuildInfo(forcedBuildMode: BuildMode.debug);
final int result = await testRunner.runTests( final int result = await testRunner.runTests(
testWrapper, testWrapper,
......
...@@ -11,23 +11,10 @@ import '../base/common.dart'; ...@@ -11,23 +11,10 @@ import '../base/common.dart';
import '../base/file_system.dart'; import '../base/file_system.dart';
import '../base/logger.dart'; import '../base/logger.dart';
const String kPackagesFileName = '.packages';
// No touching!
String get globalPackagesPath => _globalPackagesPath ?? kPackagesFileName;
set globalPackagesPath(String value) {
_globalPackagesPath = value;
}
bool get isUsingCustomPackagesPath => _globalPackagesPath != null;
String _globalPackagesPath;
/// Load the package configuration from [file] or throws a [ToolExit] /// Load the package configuration from [file] or throws a [ToolExit]
/// if the operation would fail. /// if the operation would fail.
/// ///
/// If [nonFatal] is true, in the event of an error an empty package /// If [throwOnError] is false, in the event of an error an empty package
/// config is returned. /// config is returned.
Future<PackageConfig> loadPackageConfigWithLogging(File file, { Future<PackageConfig> loadPackageConfigWithLogging(File file, {
@required Logger logger, @required Logger logger,
......
...@@ -1092,7 +1092,7 @@ Future<Directory> _loadDwdsDirectory( ...@@ -1092,7 +1092,7 @@ Future<Directory> _loadDwdsDirectory(
final String toolPackagePath = final String toolPackagePath =
fileSystem.path.join(Cache.flutterRoot, 'packages', 'flutter_tools'); fileSystem.path.join(Cache.flutterRoot, 'packages', 'flutter_tools');
final String packageFilePath = final String packageFilePath =
fileSystem.path.join(toolPackagePath, kPackagesFileName); fileSystem.path.join(toolPackagePath, '.dart_tool', 'package_config.json');
final PackageConfig packageConfig = await loadPackageConfigWithLogging( final PackageConfig packageConfig = await loadPackageConfigWithLogging(
fileSystem.file(packageFilePath), fileSystem.file(packageFilePath),
logger: logger, logger: logger,
......
...@@ -369,9 +369,8 @@ class FlutterDevice { ...@@ -369,9 +369,8 @@ class FlutterDevice {
Future<Uri> setupDevFS( Future<Uri> setupDevFS(
String fsName, String fsName,
Directory rootDirectory, { Directory rootDirectory,
String packagesFilePath, ) {
}) {
// One devFS per device. Shared by all running instances. // One devFS per device. Shared by all running instances.
devFS = DevFS( devFS = DevFS(
vmService, vmService,
......
...@@ -366,7 +366,6 @@ class HotRunner extends ResidentRunner { ...@@ -366,7 +366,6 @@ class HotRunner extends ResidentRunner {
await device.setupDevFS( await device.setupDevFS(
fsName, fsName,
globals.fs.directory(projectRootPath), globals.fs.directory(projectRootPath),
packagesFilePath: packagesFilePath,
), ),
]; ];
} }
......
...@@ -21,7 +21,6 @@ import '../build_system/targets/icon_tree_shaker.dart' show kIconTreeShakerEnabl ...@@ -21,7 +21,6 @@ import '../build_system/targets/icon_tree_shaker.dart' show kIconTreeShakerEnabl
import '../bundle.dart' as bundle; import '../bundle.dart' as bundle;
import '../cache.dart'; import '../cache.dart';
import '../dart/generate_synthetic_packages.dart'; import '../dart/generate_synthetic_packages.dart';
import '../dart/package_map.dart';
import '../dart/pub.dart'; import '../dart/pub.dart';
import '../device.dart'; import '../device.dart';
import '../features.dart'; import '../features.dart';
...@@ -882,7 +881,8 @@ abstract class FlutterCommand extends Command<void> { ...@@ -882,7 +881,8 @@ abstract class FlutterCommand extends Command<void> {
bundleSkSLPath: bundleSkSLPath, bundleSkSLPath: bundleSkSLPath,
dartExperiments: experiments, dartExperiments: experiments,
performanceMeasurementFile: performanceMeasurementFile, performanceMeasurementFile: performanceMeasurementFile,
packagesPath: globalResults['packages'] as String ?? '.packages', packagesPath: globalResults['packages'] as String
?? globals.fs.path.absolute('.dart_tool', 'package_config.json'),
nullSafetyMode: nullSafetyMode, nullSafetyMode: nullSafetyMode,
codeSizeDirectory: codeSizeDirectory, codeSizeDirectory: codeSizeDirectory,
androidGradleDaemon: androidGradleDaemon, androidGradleDaemon: androidGradleDaemon,
...@@ -1174,7 +1174,7 @@ abstract class FlutterCommand extends Command<void> { ...@@ -1174,7 +1174,7 @@ abstract class FlutterCommand extends Command<void> {
@protected @protected
@mustCallSuper @mustCallSuper
Future<void> validateCommand() async { Future<void> validateCommand() async {
if (_requiresPubspecYaml && !isUsingCustomPackagesPath) { if (_requiresPubspecYaml && !globalResults.wasParsed('packages')) {
// Don't expect a pubspec.yaml file if the user passed in an explicit .packages file path. // Don't expect a pubspec.yaml file if the user passed in an explicit .packages file path.
// If there is no pubspec in the current directory, look in the parent // If there is no pubspec in the current directory, look in the parent
......
...@@ -16,7 +16,6 @@ import '../base/user_messages.dart'; ...@@ -16,7 +16,6 @@ import '../base/user_messages.dart';
import '../base/utils.dart'; import '../base/utils.dart';
import '../cache.dart'; import '../cache.dart';
import '../convert.dart'; import '../convert.dart';
import '../dart/package_map.dart';
import '../globals.dart' as globals; import '../globals.dart' as globals;
import '../tester/flutter_tester.dart'; import '../tester/flutter_tester.dart';
...@@ -82,19 +81,9 @@ class FlutterCommandRunner extends CommandRunner<void> { ...@@ -82,19 +81,9 @@ class FlutterCommandRunner extends CommandRunner<void> {
argParser.addFlag('suppress-analytics', argParser.addFlag('suppress-analytics',
negatable: false, negatable: false,
help: 'Suppress analytics reporting when this command runs.'); help: 'Suppress analytics reporting when this command runs.');
String packagesHelp;
bool showPackagesCommand;
if (globals.fs.isFileSync(kPackagesFileName)) {
packagesHelp = '(defaults to "$kPackagesFileName")';
showPackagesCommand = verboseHelp;
} else {
packagesHelp = '(required, since the current directory does not contain a "$kPackagesFileName" file)';
showPackagesCommand = true;
}
argParser.addOption('packages', argParser.addOption('packages',
hide: !showPackagesCommand, hide: !verboseHelp,
help: 'Path to your ".packages" file.\n$packagesHelp'); help: 'Path to your "package_config.json" file.');
if (verboseHelp) { if (verboseHelp) {
argParser.addSeparator('Local build selection options (not normally required):'); argParser.addSeparator('Local build selection options (not normally required):');
} }
...@@ -219,7 +208,8 @@ class FlutterCommandRunner extends CommandRunner<void> { ...@@ -219,7 +208,8 @@ class FlutterCommandRunner extends CommandRunner<void> {
// Set up the tooling configuration. // Set up the tooling configuration.
final EngineBuildPaths engineBuildPaths = await globals.localEngineLocator.findEnginePath( final EngineBuildPaths engineBuildPaths = await globals.localEngineLocator.findEnginePath(
topLevelResults['local-engine-src-path'] as String, topLevelResults['local-engine-src-path'] as String,
topLevelResults['local-engine'] as String topLevelResults['local-engine'] as String,
topLevelResults['packages'] as String,
); );
if (engineBuildPaths != null) { if (engineBuildPaths != null) {
contextOverrides.addAll(<Type, dynamic>{ contextOverrides.addAll(<Type, dynamic>{
...@@ -254,10 +244,6 @@ class FlutterCommandRunner extends CommandRunner<void> { ...@@ -254,10 +244,6 @@ class FlutterCommandRunner extends CommandRunner<void> {
await globals.flutterVersion.checkFlutterVersionFreshness(); await globals.flutterVersion.checkFlutterVersionFreshness();
} }
if (topLevelResults.wasParsed('packages')) {
globalPackagesPath = globals.fs.path.normalize(globals.fs.path.absolute(topLevelResults['packages'] as String));
}
// See if the user specified a specific device. // See if the user specified a specific device.
globals.deviceManager.specifiedDeviceId = topLevelResults['device-id'] as String; globals.deviceManager.specifiedDeviceId = topLevelResults['device-id'] as String;
......
...@@ -47,13 +47,16 @@ class LocalEngineLocator { ...@@ -47,13 +47,16 @@ class LocalEngineLocator {
final UserMessages _userMessages; final UserMessages _userMessages;
/// Returns the engine build path of a local engine if one is located, otherwise `null`. /// Returns the engine build path of a local engine if one is located, otherwise `null`.
Future<EngineBuildPaths> findEnginePath(String engineSourcePath, String localEngine) async { Future<EngineBuildPaths> findEnginePath(String engineSourcePath, String localEngine, String packagePath) async {
engineSourcePath ??= _platform.environment[kFlutterEngineEnvironmentVariableName]; engineSourcePath ??= _platform.environment[kFlutterEngineEnvironmentVariableName];
if (engineSourcePath == null && localEngine != null) { if (engineSourcePath == null && localEngine != null) {
try { try {
final PackageConfig packageConfig = await loadPackageConfigWithLogging( final PackageConfig packageConfig = await loadPackageConfigWithLogging(
_fileSystem.file(globalPackagesPath), _fileSystem.file(
// TODO(jonahwilliams): update to package_config
packagePath ?? _fileSystem.path.join('.packages'),
),
logger: _logger, logger: _logger,
throwOnError: false, throwOnError: false,
); );
......
...@@ -281,7 +281,7 @@ Directory _templateDirectoryInPackage(String name, FileSystem fileSystem) { ...@@ -281,7 +281,7 @@ Directory _templateDirectoryInPackage(String name, FileSystem fileSystem) {
Future<Directory> _templateImageDirectory(String name, FileSystem fileSystem, Logger logger) async { Future<Directory> _templateImageDirectory(String name, FileSystem fileSystem, Logger logger) async {
final String toolPackagePath = fileSystem.path.join( final String toolPackagePath = fileSystem.path.join(
Cache.flutterRoot, 'packages', 'flutter_tools'); Cache.flutterRoot, 'packages', 'flutter_tools');
final String packageFilePath = fileSystem.path.join(toolPackagePath, kPackagesFileName); final String packageFilePath = fileSystem.path.join(toolPackagePath, '.dart_tool', 'package_config.json');
final PackageConfig packageConfig = await loadPackageConfigWithLogging( final PackageConfig packageConfig = await loadPackageConfigWithLogging(
fileSystem.file(packageFilePath), fileSystem.file(packageFilePath),
logger: logger, logger: logger,
......
...@@ -3,13 +3,13 @@ ...@@ -3,13 +3,13 @@
// found in the LICENSE file. // found in the LICENSE file.
import 'package:coverage/coverage.dart' as coverage; import 'package:coverage/coverage.dart' as coverage;
import 'package:meta/meta.dart';
import 'package:vm_service/vm_service.dart' as vm_service; import 'package:vm_service/vm_service.dart' as vm_service;
import '../base/file_system.dart'; import '../base/file_system.dart';
import '../base/io.dart'; import '../base/io.dart';
import '../base/process.dart'; import '../base/process.dart';
import '../base/utils.dart'; import '../base/utils.dart';
import '../dart/package_map.dart';
import '../globals.dart' as globals; import '../globals.dart' as globals;
import '../vmservice.dart'; import '../vmservice.dart';
...@@ -17,9 +17,10 @@ import 'watcher.dart'; ...@@ -17,9 +17,10 @@ import 'watcher.dart';
/// A class that's used to collect coverage data during tests. /// A class that's used to collect coverage data during tests.
class CoverageCollector extends TestWatcher { class CoverageCollector extends TestWatcher {
CoverageCollector({this.libraryPredicate, this.verbose = true}); CoverageCollector({this.libraryPredicate, this.verbose = true, @required this.packagesPath});
final bool verbose; final bool verbose;
final String packagesPath;
Map<String, Map<int, int>> _globalHitmap; Map<String, Map<int, int>> _globalHitmap;
bool Function(String) libraryPredicate; bool Function(String) libraryPredicate;
...@@ -66,7 +67,7 @@ class CoverageCollector extends TestWatcher { ...@@ -66,7 +67,7 @@ class CoverageCollector extends TestWatcher {
_logMessage('($observatoryUri): collected coverage data; merging...'); _logMessage('($observatoryUri): collected coverage data; merging...');
_addHitmap(await coverage.createHitmap( _addHitmap(await coverage.createHitmap(
data['coverage'] as List<Map<String, dynamic>>, data['coverage'] as List<Map<String, dynamic>>,
packagesPath: globalPackagesPath, packagesPath: packagesPath,
checkIgnoredLines: true, checkIgnoredLines: true,
)); ));
_logMessage('($observatoryUri): done merging coverage data into global coverage map.'); _logMessage('($observatoryUri): done merging coverage data into global coverage map.');
...@@ -102,7 +103,7 @@ class CoverageCollector extends TestWatcher { ...@@ -102,7 +103,7 @@ class CoverageCollector extends TestWatcher {
_logMessage('pid $pid ($observatoryUri): collected coverage data; merging...'); _logMessage('pid $pid ($observatoryUri): collected coverage data; merging...');
_addHitmap(await coverage.createHitmap( _addHitmap(await coverage.createHitmap(
data['coverage'] as List<Map<String, dynamic>>, data['coverage'] as List<Map<String, dynamic>>,
packagesPath: globalPackagesPath, packagesPath: packagesPath,
checkIgnoredLines: true, checkIgnoredLines: true,
)); ));
_logMessage('pid $pid ($observatoryUri): done merging coverage data into global coverage map.'); _logMessage('pid $pid ($observatoryUri): done merging coverage data into global coverage map.');
...@@ -116,12 +117,13 @@ class CoverageCollector extends TestWatcher { ...@@ -116,12 +117,13 @@ class CoverageCollector extends TestWatcher {
Future<String> finalizeCoverage({ Future<String> finalizeCoverage({
coverage.Formatter formatter, coverage.Formatter formatter,
Directory coverageDirectory, Directory coverageDirectory,
String packagesPath,
}) async { }) async {
if (_globalHitmap == null) { if (_globalHitmap == null) {
return null; return null;
} }
if (formatter == null) { if (formatter == null) {
final coverage.Resolver resolver = coverage.Resolver(packagesPath: globalPackagesPath); final coverage.Resolver resolver = coverage.Resolver(packagesPath: packagesPath);
final String packagePath = globals.fs.currentDirectory.path; final String packagePath = globals.fs.currentDirectory.path;
final List<String> reportOn = coverageDirectory == null final List<String> reportOn = coverageDirectory == null
? <String>[globals.fs.path.join(packagePath, 'lib')] ? <String>[globals.fs.path.join(packagePath, 'lib')]
......
...@@ -377,7 +377,7 @@ class FlutterPlatform extends PlatformPlugin { ...@@ -377,7 +377,7 @@ class FlutterPlatform extends PlatformPlugin {
int ourTestCount, int ourTestCount,
) async { ) async {
_packageConfig ??= await loadPackageConfigWithLogging( _packageConfig ??= await loadPackageConfigWithLogging(
globals.fs.file(globalPackagesPath), globals.fs.file(buildInfo.packagesPath),
logger: globals.logger, logger: globals.logger,
); );
globals.printTrace('test $ourTestCount: starting test $testPath'); globals.printTrace('test $ourTestCount: starting test $testPath');
...@@ -446,7 +446,7 @@ class FlutterPlatform extends PlatformPlugin { ...@@ -446,7 +446,7 @@ class FlutterPlatform extends PlatformPlugin {
final Process process = await _startProcess( final Process process = await _startProcess(
shellPath, shellPath,
mainDart, mainDart,
packages: globalPackagesPath, packages: buildInfo.packagesPath,
enableObservatory: enableObservatory, enableObservatory: enableObservatory,
startPaused: startPaused, startPaused: startPaused,
disableServiceAuthCodes: disableServiceAuthCodes, disableServiceAuthCodes: disableServiceAuthCodes,
......
...@@ -90,7 +90,7 @@ class FlutterWebPlatform extends PlatformPlugin { ...@@ -90,7 +90,7 @@ class FlutterWebPlatform extends PlatformPlugin {
} }
final Future<PackageConfig> _packagesFuture = loadPackageConfigWithLogging( final Future<PackageConfig> _packagesFuture = loadPackageConfigWithLogging(
globals.fs.file(globalPackagesPath), globals.fs.file(globals.fs.path.join('.dart_tool', 'package_config.json')),
logger: globals.logger, logger: globals.logger,
); );
...@@ -864,7 +864,7 @@ class TestGoldenComparator { ...@@ -864,7 +864,7 @@ class TestGoldenComparator {
shellPath, shellPath,
'--disable-observatory', '--disable-observatory',
'--non-interactive', '--non-interactive',
'--packages=$globalPackagesPath', '--packages=${globals.fs.path.join('.dart_tool', 'package_config.json')}',
output, output,
]; ];
......
...@@ -9,7 +9,6 @@ import '../base/common.dart'; ...@@ -9,7 +9,6 @@ import '../base/common.dart';
import '../base/file_system.dart'; import '../base/file_system.dart';
import '../base/io.dart'; import '../base/io.dart';
import '../build_info.dart'; import '../build_info.dart';
import '../dart/package_map.dart';
import '../globals.dart' as globals; import '../globals.dart' as globals;
import '../project.dart'; import '../project.dart';
import '../web/compile.dart'; import '../web/compile.dart';
...@@ -178,11 +177,6 @@ class _FlutterTestRunnerImpl implements FlutterTestRunner { ...@@ -178,11 +177,6 @@ class _FlutterTestRunnerImpl implements FlutterTestRunner {
buildInfo: buildInfo, buildInfo: buildInfo,
); );
// Make the global packages path absolute.
// (Makes sure it still works after we change the current directory.)
globalPackagesPath =
globals.fs.path.normalize(globals.fs.path.absolute(globalPackagesPath));
// Call package:test's main method in the appropriate directory. // Call package:test's main method in the appropriate directory.
final Directory saved = globals.fs.currentDirectory; final Directory saved = globals.fs.currentDirectory;
try { try {
......
...@@ -107,7 +107,7 @@ class TestCompiler { ...@@ -107,7 +107,7 @@ class TestCompiler {
initializeFromDill: testFilePath, initializeFromDill: testFilePath,
unsafePackageSerialization: false, unsafePackageSerialization: false,
dartDefines: buildInfo.dartDefines, dartDefines: buildInfo.dartDefines,
packagesPath: globalPackagesPath, packagesPath: buildInfo.packagesPath,
extraFrontEndOptions: buildInfo.extraFrontEndOptions, extraFrontEndOptions: buildInfo.extraFrontEndOptions,
platform: globals.platform, platform: globals.platform,
testCompilation: true, testCompilation: true,
...@@ -129,7 +129,7 @@ class TestCompiler { ...@@ -129,7 +129,7 @@ class TestCompiler {
} }
if (_packageConfig == null) { if (_packageConfig == null) {
_packageConfig ??= await loadPackageConfigWithLogging( _packageConfig ??= await loadPackageConfigWithLogging(
globals.fs.file(globalPackagesPath), globals.fs.file(buildInfo.packagesPath),
logger: globals.logger, logger: globals.logger,
); );
// Compilation will fail if there is no flutter_test dependency, since // Compilation will fail if there is no flutter_test dependency, since
......
...@@ -6,6 +6,7 @@ import 'package:args/command_runner.dart'; ...@@ -6,6 +6,7 @@ import 'package:args/command_runner.dart';
import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/commands/create.dart'; import 'package:flutter_tools/src/commands/create.dart';
import 'package:flutter_tools/src/convert.dart';
import 'package:flutter_tools/src/doctor.dart'; import 'package:flutter_tools/src/doctor.dart';
import 'package:flutter_tools/src/reporting/reporting.dart'; import 'package:flutter_tools/src/reporting/reporting.dart';
import 'package:flutter_tools/src/globals.dart' as globals; import 'package:flutter_tools/src/globals.dart' as globals;
...@@ -39,14 +40,24 @@ void main() { ...@@ -39,14 +40,24 @@ void main() {
} }
// Set up enough of the packages to satisfy the templating code. // Set up enough of the packages to satisfy the templating code.
final File packagesFile = globals.fs.file( final File packagesFile = globals.fs.file(
globals.fs.path.join('flutter', 'packages', 'flutter_tools', '.packages')); globals.fs.path.join('flutter', 'packages', 'flutter_tools', '.dart_tool', 'package_config.json'));
final File flutterManifest = globals.fs.file( final File flutterManifest = globals.fs.file(
globals.fs.path.join('flutter', 'packages', 'flutter_tools', 'templates', 'template_manifest.json')) globals.fs.path.join('flutter', 'packages', 'flutter_tools', 'templates', 'template_manifest.json'))
..createSync(recursive: true); ..createSync(recursive: true);
final Directory templateImagesDirectory = globals.fs.directory('flutter_template_images'); final Directory templateImagesDirectory = globals.fs.directory('flutter_template_images');
templateImagesDirectory.createSync(recursive: true); templateImagesDirectory.createSync(recursive: true);
packagesFile.createSync(recursive: true); packagesFile.createSync(recursive: true);
packagesFile.writeAsStringSync('flutter_template_images:file:///${templateImagesDirectory.uri}'); packagesFile.writeAsStringSync(json.encode(<String, Object>{
'configVersion': 2,
'packages': <Object>[
<String, Object>{
'name': 'flutter_template_images',
'languageVersion': '2.8',
'rootUri': templateImagesDirectory.uri.toString(),
'packageUri': 'lib/',
},
],
}));
flutterManifest.writeAsStringSync('{"files":[]}'); flutterManifest.writeAsStringSync('{"files":[]}');
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
DoctorValidatorsProvider: () => FakeDoctorValidatorsProvider(), DoctorValidatorsProvider: () => FakeDoctorValidatorsProvider(),
......
...@@ -38,9 +38,7 @@ void main() { ...@@ -38,9 +38,7 @@ void main() {
manifestPath: anyNamed('manifestPath'), manifestPath: anyNamed('manifestPath'),
applicationKernelFilePath: anyNamed('applicationKernelFilePath'), applicationKernelFilePath: anyNamed('applicationKernelFilePath'),
depfilePath: anyNamed('depfilePath'), depfilePath: anyNamed('depfilePath'),
privateKeyPath: anyNamed('privateKeyPath'),
assetDirPath: anyNamed('assetDirPath'), assetDirPath: anyNamed('assetDirPath'),
packagesPath: anyNamed('packagesPath'),
precompiledSnapshot: anyNamed('precompiledSnapshot'), precompiledSnapshot: anyNamed('precompiledSnapshot'),
reportLicensedPackages: anyNamed('reportLicensedPackages'), reportLicensedPackages: anyNamed('reportLicensedPackages'),
trackWidgetCreation: anyNamed('trackWidgetCreation'), trackWidgetCreation: anyNamed('trackWidgetCreation'),
......
...@@ -2701,7 +2701,7 @@ plugin1=${plugin1.path} ...@@ -2701,7 +2701,7 @@ plugin1=${plugin1.path}
legacySettingsDotGradleFiles.readAsStringSync().split(';EOF').map<String>((String body) => body.trim()), legacySettingsDotGradleFiles.readAsStringSync().split(';EOF').map<String>((String body) => body.trim()),
contains(templateSettingsDotGradle.readAsStringSync().trim()), contains(templateSettingsDotGradle.readAsStringSync().trim()),
); );
}); }, skip: true); // TODO(jonahwilliams): This is an integration test and should be moved to the integration shard.
} }
/// Generates a fake app bundle at the location [directoryName]/[fileName]. /// Generates a fake app bundle at the location [directoryName]/[fileName].
......
...@@ -23,7 +23,10 @@ void main() { ...@@ -23,7 +23,10 @@ void main() {
setUp(() { setUp(() {
fileSystem = MemoryFileSystem.test(); fileSystem = MemoryFileSystem.test();
fileSystem.file('.packages').writeAsStringSync('\n'); fileSystem
.file('.dart_tool/package_config.json')
..createSync(recursive: true)
..writeAsStringSync('{"configVersion":2,"packages":[]}');
}); });
group('FlutterPlatform', () { group('FlutterPlatform', () {
...@@ -82,7 +85,7 @@ void main() { ...@@ -82,7 +85,7 @@ void main() {
'--enable-dart-profiling', '--enable-dart-profiling',
'--non-interactive', '--non-interactive',
'--use-test-fonts', '--use-test-fonts',
'--packages=.packages', '--packages=.dart_tool/package_config.json',
'example.dill' 'example.dill'
], ],
stdout: 'success', stdout: 'success',
...@@ -237,7 +240,7 @@ class MockHttpServer extends Mock implements HttpServer {} ...@@ -237,7 +240,7 @@ class MockHttpServer extends Mock implements HttpServer {}
// Uses a mock HttpServer. We don't want to bind random ports in our CI hosts. // Uses a mock HttpServer. We don't want to bind random ports in our CI hosts.
class TestFlutterPlatform extends FlutterPlatform { class TestFlutterPlatform extends FlutterPlatform {
TestFlutterPlatform() : super( TestFlutterPlatform() : super(
buildInfo: BuildInfo.debug, buildInfo: const BuildInfo(BuildMode.debug, '', treeShakeIcons: false, packagesPath: '.dart_tool/package_config.json'),
shellPath: '/', shellPath: '/',
precompiledDillPath: 'example.dill', precompiledDillPath: 'example.dill',
host: InternetAddress.loopbackIPv6, host: InternetAddress.loopbackIPv6,
...@@ -259,7 +262,7 @@ class TestFlutterPlatform extends FlutterPlatform { ...@@ -259,7 +262,7 @@ class TestFlutterPlatform extends FlutterPlatform {
// Uses a mock HttpServer. We don't want to bind random ports in our CI hosts. // Uses a mock HttpServer. We don't want to bind random ports in our CI hosts.
class TestObservatoryFlutterPlatform extends FlutterPlatform { class TestObservatoryFlutterPlatform extends FlutterPlatform {
TestObservatoryFlutterPlatform() : super( TestObservatoryFlutterPlatform() : super(
buildInfo: BuildInfo.debug, buildInfo: const BuildInfo(BuildMode.debug, '', treeShakeIcons: false, packagesPath: '.dart_tool/package_config.json'),
shellPath: '/', shellPath: '/',
precompiledDillPath: 'example.dill', precompiledDillPath: 'example.dill',
host: InternetAddress.loopbackIPv6, host: InternetAddress.loopbackIPv6,
......
...@@ -699,7 +699,10 @@ apply plugin: 'kotlin-android' ...@@ -699,7 +699,10 @@ apply plugin: 'kotlin-android'
Future<FlutterProject> someProject() async { Future<FlutterProject> someProject() async {
final Directory directory = globals.fs.directory('some_project'); final Directory directory = globals.fs.directory('some_project');
directory.childFile('.packages').createSync(recursive: true); directory.childDirectory('.dart_tool')
.childFile('package_config.json')
..createSync(recursive: true)
..writeAsStringSync('{"configVersion":2,"packages":[]}');
directory.childDirectory('ios').createSync(recursive: true); directory.childDirectory('ios').createSync(recursive: true);
final Directory androidDirectory = directory final Directory androidDirectory = directory
.childDirectory('android') .childDirectory('android')
...@@ -750,7 +753,11 @@ flutter: ...@@ -750,7 +753,11 @@ flutter:
Future<FlutterProject> aModuleProject() async { Future<FlutterProject> aModuleProject() async {
final Directory directory = globals.fs.directory('module_project'); final Directory directory = globals.fs.directory('module_project');
directory.childFile('.packages').createSync(recursive: true); directory
.childDirectory('.dart_tool')
.childFile('package_config.json')
..createSync(recursive: true)
..writeAsStringSync('{"configVersion":2,"packages":[]}');
directory.childFile('pubspec.yaml').writeAsStringSync(''' directory.childFile('pubspec.yaml').writeAsStringSync('''
name: my_module name: my_module
flutter: flutter:
...@@ -768,7 +775,11 @@ void _testInMemory(String description, Future<void> testMethod()) { ...@@ -768,7 +775,11 @@ void _testInMemory(String description, Future<void> testMethod()) {
final FileSystem testFileSystem = MemoryFileSystem( final FileSystem testFileSystem = MemoryFileSystem(
style: globals.platform.isWindows ? FileSystemStyle.windows : FileSystemStyle.posix, style: globals.platform.isWindows ? FileSystemStyle.windows : FileSystemStyle.posix,
); );
testFileSystem.file('.packages').writeAsStringSync('\n'); testFileSystem
.directory('.dart_tool')
.childFile('package_config.json')
..createSync(recursive: true)
..writeAsStringSync('{"configVersion":2,"packages":[]}');
// Transfer needed parts of the Flutter installation folder // Transfer needed parts of the Flutter installation folder
// to the in-memory file system used during testing. // to the in-memory file system used during testing.
transfer(Cache( transfer(Cache(
...@@ -789,11 +800,22 @@ void _testInMemory(String description, Future<void> testMethod()) { ...@@ -789,11 +800,22 @@ void _testInMemory(String description, Future<void> testMethod()) {
final File packagesFile = testFileSystem.directory(Cache.flutterRoot) final File packagesFile = testFileSystem.directory(Cache.flutterRoot)
.childDirectory('packages') .childDirectory('packages')
.childDirectory('flutter_tools') .childDirectory('flutter_tools')
.childFile('.packages'); .childDirectory('.dart_tool')
.childFile('package_config.json');
final Directory dummyTemplateImagesDirectory = testFileSystem.directory(Cache.flutterRoot).parent; final Directory dummyTemplateImagesDirectory = testFileSystem.directory(Cache.flutterRoot).parent;
dummyTemplateImagesDirectory.createSync(recursive: true); dummyTemplateImagesDirectory.createSync(recursive: true);
packagesFile.createSync(recursive: true); packagesFile.createSync(recursive: true);
packagesFile.writeAsStringSync('flutter_template_images:${dummyTemplateImagesDirectory.uri}'); packagesFile.writeAsStringSync(json.encode(<String, Object>{
'configVersion': 2,
'packages': <Object>[
<String, Object>{
'name': 'flutter_template_images',
'rootUri': dummyTemplateImagesDirectory.uri.toString(),
'packageUri': 'lib/',
'languageVersion': '2.6'
},
],
}));
final FlutterProjectFactory flutterProjectFactory = FlutterProjectFactory( final FlutterProjectFactory flutterProjectFactory = FlutterProjectFactory(
fileSystem: testFileSystem, fileSystem: testFileSystem,
......
...@@ -194,7 +194,7 @@ void main() { ...@@ -194,7 +194,7 @@ void main() {
compileExpression: anyNamed('compileExpression'), compileExpression: anyNamed('compileExpression'),
getSkSLMethod: anyNamed('getSkSLMethod'), getSkSLMethod: anyNamed('getSkSLMethod'),
)).thenAnswer((Invocation invocation) async { }); )).thenAnswer((Invocation invocation) async { });
when(mockFlutterDevice.setupDevFS(any, any, packagesFilePath: anyNamed('packagesFilePath'))) when(mockFlutterDevice.setupDevFS(any, any))
.thenAnswer((Invocation invocation) async { .thenAnswer((Invocation invocation) async {
return testUri; return testUri;
}); });
......
...@@ -43,7 +43,7 @@ void main() { ...@@ -43,7 +43,7 @@ void main() {
); );
expect( expect(
await localEngineLocator.findEnginePath(null, 'ios_debug'), await localEngineLocator.findEnginePath(null, 'ios_debug', null),
matchesEngineBuildPaths( matchesEngineBuildPaths(
hostEngine: '/arbitrary/engine/src/out/host_debug', hostEngine: '/arbitrary/engine/src/out/host_debug',
targetEngine: '/arbitrary/engine/src/out/ios_debug', targetEngine: '/arbitrary/engine/src/out/ios_debug',
...@@ -57,7 +57,7 @@ void main() { ...@@ -57,7 +57,7 @@ void main() {
.writeAsStringSync('sky_engine:file:///symlink/src/out/ios_debug/gen/dart-pkg/sky_engine/lib/'); .writeAsStringSync('sky_engine:file:///symlink/src/out/ios_debug/gen/dart-pkg/sky_engine/lib/');
expect( expect(
await localEngineLocator.findEnginePath(null, 'ios_debug'), await localEngineLocator.findEnginePath(null, 'ios_debug', null),
matchesEngineBuildPaths( matchesEngineBuildPaths(
hostEngine: '/symlink/src/out/host_debug', hostEngine: '/symlink/src/out/host_debug',
targetEngine: '/symlink/src/out/ios_debug', targetEngine: '/symlink/src/out/ios_debug',
...@@ -81,7 +81,7 @@ void main() { ...@@ -81,7 +81,7 @@ void main() {
); );
expect( expect(
await localEngineLocator.findEnginePath('$kArbitraryEngineRoot/src', 'ios_debug'), await localEngineLocator.findEnginePath('$kArbitraryEngineRoot/src', 'ios_debug', null),
matchesEngineBuildPaths( matchesEngineBuildPaths(
hostEngine: '/arbitrary/engine/src/out/host_debug', hostEngine: '/arbitrary/engine/src/out/host_debug',
targetEngine: '/arbitrary/engine/src/out/ios_debug', targetEngine: '/arbitrary/engine/src/out/ios_debug',
...@@ -112,7 +112,7 @@ void main() { ...@@ -112,7 +112,7 @@ void main() {
); );
expect( expect(
await localEngineLocator.findEnginePath(null, 'ios_debug'), await localEngineLocator.findEnginePath(null, 'ios_debug', null),
matchesEngineBuildPaths( matchesEngineBuildPaths(
hostEngine: 'flutter/engine/src/out/host_debug', hostEngine: 'flutter/engine/src/out/host_debug',
targetEngine: 'flutter/engine/src/out/ios_debug', targetEngine: 'flutter/engine/src/out/ios_debug',
......
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