Unverified Commit 82a6f9bf authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[flutter_tools] remove most use of global packages path (#60231)

The global packages path could cause tests to fail when it would be overriden to unexpected (in test setup) values. Remove most usage and make it a configuration on buildInfo, along with most other build information. Cleanup the asset builder to require the .packages path and the resident runners to no longer require it, since they already have the information in build_info.

It needs to stick around for the fuchsia deps we do not control.

Filled #60232 for remaining work.
parent 9322c808
...@@ -790,6 +790,7 @@ Future<void> buildPluginsAsAar( ...@@ -790,6 +790,7 @@ Future<void> buildPluginsAsAar(
BuildMode.release, // Plugins are built as release. BuildMode.release, // Plugins are built as release.
null, // Plugins don't define flavors. null, // Plugins don't define flavors.
treeShakeIcons: androidBuildInfo.buildInfo.treeShakeIcons, treeShakeIcons: androidBuildInfo.buildInfo.treeShakeIcons,
packagesPath: androidBuildInfo.buildInfo.packagesPath,
), ),
), ),
target: '', target: '',
......
...@@ -51,7 +51,7 @@ abstract class AssetBundle { ...@@ -51,7 +51,7 @@ abstract class AssetBundle {
Future<int> build({ Future<int> build({
String manifestPath = defaultManifestPath, String manifestPath = defaultManifestPath,
String assetDirPath, String assetDirPath,
String packagesPath, @required String packagesPath,
bool includeDefaultFonts = true, bool includeDefaultFonts = true,
bool reportLicensedPackages = false, bool reportLicensedPackages = false,
}); });
...@@ -122,12 +122,11 @@ class ManifestAssetBundle implements AssetBundle { ...@@ -122,12 +122,11 @@ class ManifestAssetBundle implements AssetBundle {
Future<int> build({ Future<int> build({
String manifestPath = defaultManifestPath, String manifestPath = defaultManifestPath,
String assetDirPath, String assetDirPath,
String packagesPath, @required String packagesPath,
bool includeDefaultFonts = true, bool includeDefaultFonts = true,
bool reportLicensedPackages = false, bool reportLicensedPackages = false,
}) async { }) async {
assetDirPath ??= getAssetBuildDirectory(); assetDirPath ??= getAssetBuildDirectory();
packagesPath ??= globals.fs.path.absolute(globalPackagesPath);
FlutterManifest flutterManifest; FlutterManifest flutterManifest;
try { try {
flutterManifest = FlutterManifest.createFromPath( flutterManifest = FlutterManifest.createFromPath(
......
...@@ -29,6 +29,7 @@ class BuildInfo { ...@@ -29,6 +29,7 @@ class BuildInfo {
this.dartExperiments = const <String>[], this.dartExperiments = const <String>[],
@required this.treeShakeIcons, @required this.treeShakeIcons,
this.performanceMeasurementFile, this.performanceMeasurementFile,
this.packagesPath = '.packages',
}); });
final BuildMode mode; final BuildMode mode;
...@@ -44,6 +45,12 @@ class BuildInfo { ...@@ -44,6 +45,12 @@ class BuildInfo {
/// Mode-Flavor (e.g. Release-Paid). /// Mode-Flavor (e.g. Release-Paid).
final String flavor; final String flavor;
/// The path to the .packages file to use for compilation.
///
/// This is used by package:package_config to locate the actual package_config.json
/// file. If not provded, defaults to `.packages`.
final String packagesPath;
final List<String> fileSystemRoots; final List<String> fileSystemRoots;
final String fileSystemScheme; final String fileSystemScheme;
...@@ -156,6 +163,8 @@ class BuildInfo { ...@@ -156,6 +163,8 @@ class BuildInfo {
'PERFORMANCE_MEASUREMENT_FILE': performanceMeasurementFile, 'PERFORMANCE_MEASUREMENT_FILE': performanceMeasurementFile,
if (bundleSkSLPath != null) if (bundleSkSLPath != null)
'BUNDLE_SKSL_PATH': bundleSkSLPath, 'BUNDLE_SKSL_PATH': bundleSkSLPath,
if (packagesPath != null)
'PACKAGE_CONFIG': packagesPath,
}; };
} }
} }
......
...@@ -140,7 +140,7 @@ class WebAssetServer implements AssetReader { ...@@ -140,7 +140,7 @@ class WebAssetServer implements AssetReader {
int port, int port,
UrlTunneller urlTunneller, UrlTunneller urlTunneller,
bool useSseForDebugProxy, bool useSseForDebugProxy,
BuildMode buildMode, BuildInfo buildInfo,
bool enableDwds, bool enableDwds,
Uri entrypoint, Uri entrypoint,
ExpressionCompiler expressionCompiler, { ExpressionCompiler expressionCompiler, {
...@@ -156,7 +156,7 @@ class WebAssetServer implements AssetReader { ...@@ -156,7 +156,7 @@ class WebAssetServer implements AssetReader {
} }
final HttpServer httpServer = await HttpServer.bind(address, port); final HttpServer httpServer = await HttpServer.bind(address, port);
final PackageConfig packageConfig = await loadPackageConfigWithLogging( final PackageConfig packageConfig = await loadPackageConfigWithLogging(
globals.fs.file(globalPackagesPath), globals.fs.file(buildInfo.packagesPath),
logger: globals.logger, logger: globals.logger,
); );
final Map<String, String> digests = <String, String>{}; final Map<String, String> digests = <String, String>{};
...@@ -173,7 +173,7 @@ class WebAssetServer implements AssetReader { ...@@ -173,7 +173,7 @@ class WebAssetServer implements AssetReader {
} }
// In release builds deploy a simpler proxy server. // In release builds deploy a simpler proxy server.
if (buildMode != BuildMode.debug) { if (buildInfo.mode != BuildMode.debug) {
final ReleaseAssetServer releaseAssetServer = ReleaseAssetServer( final ReleaseAssetServer releaseAssetServer = ReleaseAssetServer(
entrypoint, entrypoint,
fileSystem: globals.fs, fileSystem: globals.fs,
...@@ -589,7 +589,7 @@ class WebDevFS implements DevFS { ...@@ -589,7 +589,7 @@ class WebDevFS implements DevFS {
@required this.packagesFilePath, @required this.packagesFilePath,
@required this.urlTunneller, @required this.urlTunneller,
@required this.useSseForDebugProxy, @required this.useSseForDebugProxy,
@required this.buildMode, @required this.buildInfo,
@required this.enableDwds, @required this.enableDwds,
@required this.entrypoint, @required this.entrypoint,
@required this.expressionCompiler, @required this.expressionCompiler,
...@@ -603,7 +603,7 @@ class WebDevFS implements DevFS { ...@@ -603,7 +603,7 @@ class WebDevFS implements DevFS {
final String packagesFilePath; final String packagesFilePath;
final UrlTunneller urlTunneller; final UrlTunneller urlTunneller;
final bool useSseForDebugProxy; final bool useSseForDebugProxy;
final BuildMode buildMode; final BuildInfo buildInfo;
final bool enableDwds; final bool enableDwds;
final bool testMode; final bool testMode;
final ExpressionCompiler expressionCompiler; final ExpressionCompiler expressionCompiler;
...@@ -670,7 +670,7 @@ class WebDevFS implements DevFS { ...@@ -670,7 +670,7 @@ class WebDevFS implements DevFS {
port, port,
urlTunneller, urlTunneller,
useSseForDebugProxy, useSseForDebugProxy,
buildMode, buildInfo,
enableDwds, enableDwds,
entrypoint, entrypoint,
expressionCompiler, expressionCompiler,
......
...@@ -66,7 +66,7 @@ class DwdsWebRunnerFactory extends WebRunnerFactory { ...@@ -66,7 +66,7 @@ class DwdsWebRunnerFactory extends WebRunnerFactory {
} }
} }
const String kExitMessage = 'Failed to establish connection with the application ' const String kExitMessage = 'Failed to establish connection with the application '
'instance in Chrome.\nThis can happen if the websocket connection used by the ' 'instance in Chrome.\nThis can happen if the websocket connection used by the '
'web tooling is unable to correctly establish a connection, for example due to a firewall.'; 'web tooling is unable to correctly establish a connection, for example due to a firewall.';
...@@ -447,7 +447,7 @@ class _ResidentWebRunner extends ResidentWebRunner { ...@@ -447,7 +447,7 @@ class _ResidentWebRunner extends ResidentWebRunner {
packagesFilePath: packagesFilePath, packagesFilePath: packagesFilePath,
urlTunneller: urlTunneller, urlTunneller: urlTunneller,
useSseForDebugProxy: debuggingOptions.webUseSseForDebugProxy, useSseForDebugProxy: debuggingOptions.webUseSseForDebugProxy,
buildMode: debuggingOptions.buildInfo.mode, buildInfo: debuggingOptions.buildInfo,
enableDwds: _enableDwds, enableDwds: _enableDwds,
entrypoint: globals.fs.file(target).uri, entrypoint: globals.fs.file(target).uri,
expressionCompiler: expressionCompiler, expressionCompiler: expressionCompiler,
...@@ -639,7 +639,7 @@ class _ResidentWebRunner extends ResidentWebRunner { ...@@ -639,7 +639,7 @@ class _ResidentWebRunner extends ResidentWebRunner {
final bool rebuildBundle = assetBundle.needsBuild(); final bool rebuildBundle = assetBundle.needsBuild();
if (rebuildBundle) { if (rebuildBundle) {
globals.printTrace('Updating assets'); globals.printTrace('Updating assets');
final int result = await assetBundle.build(); final int result = await assetBundle.build(packagesPath: debuggingOptions.buildInfo.packagesPath);
if (result != 0) { if (result != 0) {
return UpdateFSReport(success: false); return UpdateFSReport(success: false);
} }
......
...@@ -58,8 +58,10 @@ class WebEntrypointTarget extends Target { ...@@ -58,8 +58,10 @@ class WebEntrypointTarget extends Target {
final bool shouldInitializePlatform = environment.defines[kInitializePlatform] == 'true'; final bool shouldInitializePlatform = environment.defines[kInitializePlatform] == 'true';
final bool hasPlugins = environment.defines[kHasWebPlugins] == 'true'; final bool hasPlugins = environment.defines[kHasWebPlugins] == 'true';
final Uri importUri = environment.fileSystem.file(targetFile).absolute.uri; final Uri importUri = environment.fileSystem.file(targetFile).absolute.uri;
// TODO(jonahwilliams): support configuration of this file.
const String packageFile = '.packages';
final PackageConfig packageConfig = await loadPackageConfigWithLogging( final PackageConfig packageConfig = await loadPackageConfigWithLogging(
environment.projectDir.childFile('.packages'), environment.fileSystem.file(packageFile),
logger: environment.logger, logger: environment.logger,
); );
...@@ -156,7 +158,8 @@ class Dart2JSTarget extends Target { ...@@ -156,7 +158,8 @@ class Dart2JSTarget extends Target {
final BuildMode buildMode = getBuildModeForName(environment.defines[kBuildMode]); final BuildMode buildMode = getBuildModeForName(environment.defines[kBuildMode]);
final String specPath = globals.fs.path.join( final String specPath = globals.fs.path.join(
globals.artifacts.getArtifactPath(Artifact.flutterWebSdk), 'libraries.json'); globals.artifacts.getArtifactPath(Artifact.flutterWebSdk), 'libraries.json');
final String packageFile = globalPackagesPath; // TODO(jonahwilliams): support configuration of this file.
const String packageFile = '.packages';
final File outputKernel = environment.buildDir.childFile('app.dill'); final File outputKernel = environment.buildDir.childFile('app.dill');
final File outputFile = environment.buildDir.childFile('main.dart.js'); final File outputFile = environment.buildDir.childFile('main.dart.js');
final List<String> dartDefines = decodeDartDefines(environment.defines, kDartDefines); final List<String> dartDefines = decodeDartDefines(environment.defines, kDartDefines);
......
...@@ -20,7 +20,6 @@ import 'build_system/targets/common.dart'; ...@@ -20,7 +20,6 @@ import 'build_system/targets/common.dart';
import 'build_system/targets/icon_tree_shaker.dart'; import 'build_system/targets/icon_tree_shaker.dart';
import 'cache.dart'; import 'cache.dart';
import 'convert.dart'; import 'convert.dart';
import 'dart/package_map.dart';
import 'devfs.dart'; import 'devfs.dart';
import 'globals.dart' as globals; import 'globals.dart' as globals;
import 'project.dart'; import 'project.dart';
...@@ -95,7 +94,7 @@ class BundleBuilder { ...@@ -95,7 +94,7 @@ class BundleBuilder {
mainPath ??= defaultMainPath; mainPath ??= defaultMainPath;
depfilePath ??= defaultDepfilePath; depfilePath ??= defaultDepfilePath;
assetDirPath ??= getAssetBuildDirectory(); assetDirPath ??= getAssetBuildDirectory();
packagesPath ??= globals.fs.path.absolute(globalPackagesPath); 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,
...@@ -192,12 +191,12 @@ Future<void> buildWithAssemble({ ...@@ -192,12 +191,12 @@ Future<void> buildWithAssemble({
Future<AssetBundle> buildAssets({ Future<AssetBundle> buildAssets({
String manifestPath, String manifestPath,
String assetDirPath, String assetDirPath,
String packagesPath, @required String packagesPath,
bool includeDefaultFonts = true, bool includeDefaultFonts = true,
bool reportLicensedPackages = false, bool reportLicensedPackages = false,
}) async { }) async {
assetDirPath ??= getAssetBuildDirectory(); assetDirPath ??= getAssetBuildDirectory();
packagesPath ??= globals.fs.path.absolute(globalPackagesPath); packagesPath ??= globals.fs.path.absolute(packagesPath);
// Build the asset bundle. // Build the asset bundle.
final AssetBundle assetBundle = AssetBundleFactory.instance.createBundle(); final AssetBundle assetBundle = AssetBundleFactory.instance.createBundle();
......
...@@ -415,7 +415,6 @@ class HotRunnerFactory { ...@@ -415,7 +415,6 @@ class HotRunnerFactory {
applicationBinary: applicationBinary, applicationBinary: applicationBinary,
hostIsIde: hostIsIde, hostIsIde: hostIsIde,
projectRootPath: projectRootPath, projectRootPath: projectRootPath,
packagesFilePath: packagesFilePath,
dillOutputPath: dillOutputPath, dillOutputPath: dillOutputPath,
stayResident: stayResident, stayResident: stayResident,
ipv6: ipv6, ipv6: ipv6,
......
...@@ -486,7 +486,6 @@ class AppDomain extends Domain { ...@@ -486,7 +486,6 @@ class AppDomain extends Domain {
debuggingOptions: options, debuggingOptions: options,
applicationBinary: applicationBinary, applicationBinary: applicationBinary,
projectRootPath: projectRootPath, projectRootPath: projectRootPath,
packagesFilePath: packagesFilePath,
dillOutputPath: dillOutputPath, dillOutputPath: dillOutputPath,
ipv6: ipv6, ipv6: ipv6,
hostIsIde: true, hostIsIde: true,
......
...@@ -536,7 +536,6 @@ class RunCommand extends RunCommandBase { ...@@ -536,7 +536,6 @@ class RunCommand extends RunCommandBase {
? null ? null
: globals.fs.file(applicationBinaryPath), : globals.fs.file(applicationBinaryPath),
projectRootPath: stringArg('project-root'), projectRootPath: stringArg('project-root'),
packagesFilePath: globalResults['packages'] as String,
dillOutputPath: stringArg('output-dill'), dillOutputPath: stringArg('output-dill'),
stayResident: stayResident, stayResident: stayResident,
ipv6: ipv6, ipv6: ipv6,
......
...@@ -296,7 +296,7 @@ class TestCommand extends FlutterCommand { ...@@ -296,7 +296,7 @@ class TestCommand extends FlutterCommand {
Future<void> _buildTestAsset() async { Future<void> _buildTestAsset() async {
final AssetBundle assetBundle = AssetBundleFactory.instance.createBundle(); final AssetBundle assetBundle = AssetBundleFactory.instance.createBundle();
final int build = await assetBundle.build(); final int build = await assetBundle.build(packagesPath: '.packages');
if (build != 0) { if (build != 0) {
throwToolExit('Error: Failed to build asset bundle'); throwToolExit('Error: Failed to build asset bundle');
} }
......
...@@ -13,6 +13,7 @@ import '../base/logger.dart'; ...@@ -13,6 +13,7 @@ import '../base/logger.dart';
const String kPackagesFileName = '.packages'; const String kPackagesFileName = '.packages';
// No touching!
String get globalPackagesPath => _globalPackagesPath ?? kPackagesFileName; String get globalPackagesPath => _globalPackagesPath ?? kPackagesFileName;
set globalPackagesPath(String value) { set globalPackagesPath(String value) {
...@@ -55,7 +56,7 @@ Future<PackageConfig> loadPackageConfigWithLogging(File file, { ...@@ -55,7 +56,7 @@ Future<PackageConfig> loadPackageConfigWithLogging(File file, {
message += '\nDid you run this command from the same directory as your pubspec.yaml file?'; message += '\nDid you run this command from the same directory as your pubspec.yaml file?';
} }
logger.printError(message); logger.printError(message);
throwToolExit(null); throwToolExit(file.path);
} }
); );
} }
...@@ -321,7 +321,7 @@ Future<List<Plugin>> findPlugins(FlutterProject project) async { ...@@ -321,7 +321,7 @@ Future<List<Plugin>> findPlugins(FlutterProject project) async {
final List<Plugin> plugins = <Plugin>[]; final List<Plugin> plugins = <Plugin>[];
final String packagesFile = globals.fs.path.join( final String packagesFile = globals.fs.path.join(
project.directory.path, project.directory.path,
globalPackagesPath, '.packages',
); );
final PackageConfig packageConfig = await loadPackageConfigWithLogging( final PackageConfig packageConfig = await loadPackageConfigWithLogging(
globals.fs.file(packagesFile), globals.fs.file(packagesFile),
......
...@@ -26,7 +26,6 @@ import 'bundle.dart'; ...@@ -26,7 +26,6 @@ import 'bundle.dart';
import 'cache.dart'; import 'cache.dart';
import 'codegen.dart'; import 'codegen.dart';
import 'compile.dart'; import 'compile.dart';
import 'dart/package_map.dart';
import 'devfs.dart'; import 'devfs.dart';
import 'device.dart'; import 'device.dart';
import 'features.dart'; import 'features.dart';
...@@ -60,7 +59,7 @@ class FlutterDevice { ...@@ -60,7 +59,7 @@ class FlutterDevice {
fileSystemScheme: fileSystemScheme, fileSystemScheme: fileSystemScheme,
targetModel: targetModel, targetModel: targetModel,
dartDefines: buildInfo.dartDefines, dartDefines: buildInfo.dartDefines,
packagesPath: globalPackagesPath, packagesPath: buildInfo.packagesPath,
extraFrontEndOptions: buildInfo.extraFrontEndOptions, extraFrontEndOptions: buildInfo.extraFrontEndOptions,
artifacts: globals.artifacts, artifacts: globals.artifacts,
processManager: globals.processManager, processManager: globals.processManager,
...@@ -113,7 +112,7 @@ class FlutterDevice { ...@@ -113,7 +112,7 @@ class FlutterDevice {
dartDefines: buildInfo.dartDefines, dartDefines: buildInfo.dartDefines,
librariesSpec: globals.fs.file(globals.artifacts librariesSpec: globals.fs.file(globals.artifacts
.getArtifactPath(Artifact.flutterWebLibrariesJson)).uri.toString(), .getArtifactPath(Artifact.flutterWebLibrariesJson)).uri.toString(),
packagesPath: globalPackagesPath, packagesPath: buildInfo.packagesPath,
artifacts: globals.artifacts, artifacts: globals.artifacts,
processManager: globals.processManager, processManager: globals.processManager,
logger: globals.logger, logger: globals.logger,
...@@ -136,7 +135,7 @@ class FlutterDevice { ...@@ -136,7 +135,7 @@ class FlutterDevice {
trackWidgetCreation: buildInfo.trackWidgetCreation, trackWidgetCreation: buildInfo.trackWidgetCreation,
dartDefines: buildInfo.dartDefines, dartDefines: buildInfo.dartDefines,
), ),
packagesPath: globalPackagesPath, packagesPath: buildInfo.packagesPath,
artifacts: globals.artifacts, artifacts: globals.artifacts,
processManager: globals.processManager, processManager: globals.processManager,
logger: globals.logger, logger: globals.logger,
...@@ -683,16 +682,15 @@ abstract class ResidentRunner { ...@@ -683,16 +682,15 @@ abstract class ResidentRunner {
ResidentRunner( ResidentRunner(
this.flutterDevices, { this.flutterDevices, {
this.target, this.target,
this.debuggingOptions, @required this.debuggingOptions,
String projectRootPath, String projectRootPath,
String packagesFilePath,
this.ipv6, this.ipv6,
this.stayResident = true, this.stayResident = true,
this.hotMode = true, this.hotMode = true,
String dillOutputPath, String dillOutputPath,
}) : mainPath = findMainDartFile(target), }) : mainPath = findMainDartFile(target),
packagesFilePath = debuggingOptions.buildInfo.packagesPath,
projectRootPath = projectRootPath ?? globals.fs.currentDirectory.path, projectRootPath = projectRootPath ?? globals.fs.currentDirectory.path,
packagesFilePath = packagesFilePath ?? globals.fs.path.absolute(globalPackagesPath),
_dillOutputPath = dillOutputPath, _dillOutputPath = dillOutputPath,
artifactDirectory = dillOutputPath == null artifactDirectory = dillOutputPath == null
? globals.fs.systemTempDirectory.createTempSync('flutter_tool.') ? globals.fs.systemTempDirectory.createTempSync('flutter_tool.')
......
...@@ -13,12 +13,11 @@ import 'resident_runner.dart'; ...@@ -13,12 +13,11 @@ import 'resident_runner.dart';
import 'tracing.dart'; import 'tracing.dart';
import 'vmservice.dart'; import 'vmservice.dart';
// TODO(mklim): Test this, flutter/flutter#23031.
class ColdRunner extends ResidentRunner { class ColdRunner extends ResidentRunner {
ColdRunner( ColdRunner(
List<FlutterDevice> devices, { List<FlutterDevice> devices, {
String target, String target,
DebuggingOptions debuggingOptions, @required DebuggingOptions debuggingOptions,
this.traceStartup = false, this.traceStartup = false,
this.awaitFirstFrameWhenTracing = true, this.awaitFirstFrameWhenTracing = true,
this.applicationBinary, this.applicationBinary,
......
...@@ -67,12 +67,11 @@ class HotRunner extends ResidentRunner { ...@@ -67,12 +67,11 @@ class HotRunner extends ResidentRunner {
HotRunner( HotRunner(
List<FlutterDevice> devices, { List<FlutterDevice> devices, {
String target, String target,
DebuggingOptions debuggingOptions, @required DebuggingOptions debuggingOptions,
this.benchmarkMode = false, this.benchmarkMode = false,
this.applicationBinary, this.applicationBinary,
this.hostIsIde = false, this.hostIsIde = false,
String projectRootPath, String projectRootPath,
String packagesFilePath,
String dillOutputPath, String dillOutputPath,
bool stayResident = true, bool stayResident = true,
bool ipv6 = false, bool ipv6 = false,
...@@ -80,7 +79,6 @@ class HotRunner extends ResidentRunner { ...@@ -80,7 +79,6 @@ class HotRunner extends ResidentRunner {
target: target, target: target,
debuggingOptions: debuggingOptions, debuggingOptions: debuggingOptions,
projectRootPath: projectRootPath, projectRootPath: projectRootPath,
packagesFilePath: packagesFilePath,
stayResident: stayResident, stayResident: stayResident,
hotMode: true, hotMode: true,
dillOutputPath: dillOutputPath, dillOutputPath: dillOutputPath,
...@@ -157,7 +155,7 @@ class HotRunner extends ResidentRunner { ...@@ -157,7 +155,7 @@ class HotRunner extends ResidentRunner {
final UpdateFSReport results = UpdateFSReport(success: true); final UpdateFSReport results = UpdateFSReport(success: true);
final List<Uri> invalidated = <Uri>[Uri.parse(libraryId)]; final List<Uri> invalidated = <Uri>[Uri.parse(libraryId)];
final PackageConfig packageConfig = await loadPackageConfigWithLogging( final PackageConfig packageConfig = await loadPackageConfigWithLogging(
globals.fs.file(globalPackagesPath), globals.fs.file(debuggingOptions.buildInfo.packagesPath),
logger: globals.logger, logger: globals.logger,
); );
for (final FlutterDevice device in flutterDevices) { for (final FlutterDevice device in flutterDevices) {
...@@ -343,7 +341,7 @@ class HotRunner extends ResidentRunner { ...@@ -343,7 +341,7 @@ class HotRunner extends ResidentRunner {
final List<Future<bool>> startupTasks = <Future<bool>>[]; final List<Future<bool>> startupTasks = <Future<bool>>[];
final PackageConfig packageConfig = await loadPackageConfigWithLogging( final PackageConfig packageConfig = await loadPackageConfigWithLogging(
globals.fs.file(globalPackagesPath), globals.fs.file(debuggingOptions.buildInfo.packagesPath),
logger: globals.logger, logger: globals.logger,
); );
for (final FlutterDevice device in flutterDevices) { for (final FlutterDevice device in flutterDevices) {
...@@ -407,7 +405,7 @@ class HotRunner extends ResidentRunner { ...@@ -407,7 +405,7 @@ class HotRunner extends ResidentRunner {
final bool rebuildBundle = assetBundle.needsBuild(); final bool rebuildBundle = assetBundle.needsBuild();
if (rebuildBundle) { if (rebuildBundle) {
globals.printTrace('Updating assets'); globals.printTrace('Updating assets');
final int result = await assetBundle.build(); final int result = await assetBundle.build(packagesPath: '.packages');
if (result != 0) { if (result != 0) {
return UpdateFSReport(success: false); return UpdateFSReport(success: false);
} }
...@@ -1289,7 +1287,7 @@ class ProjectFileInvalidator { ...@@ -1289,7 +1287,7 @@ class ProjectFileInvalidator {
Future<PackageConfig> _createPackageConfig(String packagesPath) { Future<PackageConfig> _createPackageConfig(String packagesPath) {
return loadPackageConfigWithLogging( return loadPackageConfigWithLogging(
_fileSystem.file(globalPackagesPath), _fileSystem.file(packagesPath),
logger: _logger, logger: _logger,
); );
} }
......
...@@ -685,6 +685,7 @@ abstract class FlutterCommand extends Command<void> { ...@@ -685,6 +685,7 @@ abstract class FlutterCommand extends Command<void> {
bundleSkSLPath: bundleSkSLPath, bundleSkSLPath: bundleSkSLPath,
dartExperiments: experiments, dartExperiments: experiments,
performanceMeasurementFile: performanceMeasurementFile, performanceMeasurementFile: performanceMeasurementFile,
packagesPath: globalResults['packages'] as String ?? '.packages'
); );
} }
......
...@@ -14,7 +14,6 @@ import '../base/io.dart'; ...@@ -14,7 +14,6 @@ import '../base/io.dart';
import '../build_info.dart'; import '../build_info.dart';
import '../bundle.dart'; import '../bundle.dart';
import '../convert.dart'; import '../convert.dart';
import '../dart/package_map.dart';
import '../device.dart'; import '../device.dart';
import '../globals.dart' as globals; import '../globals.dart' as globals;
import '../project.dart'; import '../project.dart';
...@@ -138,7 +137,7 @@ class FlutterTesterDevice extends Device { ...@@ -138,7 +137,7 @@ class FlutterTesterDevice extends Device {
'--run-forever', '--run-forever',
'--non-interactive', '--non-interactive',
'--enable-dart-profiling', '--enable-dart-profiling',
'--packages=$globalPackagesPath', '--packages=${debuggingOptions.buildInfo.packagesPath}',
]; ];
if (debuggingOptions.debuggingEnabled) { if (debuggingOptions.debuggingEnabled) {
if (debuggingOptions.startPaused) { if (debuggingOptions.startPaused) {
......
...@@ -782,7 +782,6 @@ class TestHotRunnerFactory extends HotRunnerFactory { ...@@ -782,7 +782,6 @@ class TestHotRunnerFactory extends HotRunnerFactory {
applicationBinary: applicationBinary, applicationBinary: applicationBinary,
hostIsIde: hostIsIde, hostIsIde: hostIsIde,
projectRootPath: projectRootPath, projectRootPath: projectRootPath,
packagesFilePath: packagesFilePath,
dillOutputPath: dillOutputPath, dillOutputPath: dillOutputPath,
stayResident: stayResident, stayResident: stayResident,
ipv6: ipv6, ipv6: ipv6,
......
...@@ -68,7 +68,7 @@ $fontsSection ...@@ -68,7 +68,7 @@ $fontsSection
String expectedAssetManifest, String expectedAssetManifest,
) async { ) async {
final AssetBundle bundle = AssetBundleFactory.instance.createBundle(); final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
await bundle.build(manifestPath: 'pubspec.yaml'); await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages');
for (final String packageName in packages) { for (final String packageName in packages) {
for (final String packageFont in packageFonts) { for (final String packageFont in packageFonts) {
...@@ -122,7 +122,7 @@ $fontsSection ...@@ -122,7 +122,7 @@ $fontsSection
writePubspecFile('p/p/pubspec.yaml', 'test_package'); writePubspecFile('p/p/pubspec.yaml', 'test_package');
final AssetBundle bundle = AssetBundleFactory.instance.createBundle(); final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
await bundle.build(manifestPath: 'pubspec.yaml'); await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages');
expect(bundle.entries.length, 3); // LICENSE, AssetManifest, FontManifest expect(bundle.entries.length, 3); // LICENSE, AssetManifest, FontManifest
expect(bundle.entries.containsKey('FontManifest.json'), isTrue); expect(bundle.entries.containsKey('FontManifest.json'), isTrue);
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
......
...@@ -74,7 +74,7 @@ $assetsSection ...@@ -74,7 +74,7 @@ $assetsSection
bool expectExists = true, bool expectExists = true,
}) async { }) async {
final AssetBundle bundle = AssetBundleFactory.instance.createBundle(); final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
await bundle.build(manifestPath: 'pubspec.yaml'); await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages');
for (final String packageName in packages) { for (final String packageName in packages) {
for (final String asset in assets) { for (final String asset in assets) {
...@@ -129,7 +129,7 @@ $assetsSection ...@@ -129,7 +129,7 @@ $assetsSection
writePubspecFile('p/p/pubspec.yaml', 'test_package'); writePubspecFile('p/p/pubspec.yaml', 'test_package');
final AssetBundle bundle = AssetBundleFactory.instance.createBundle(); final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
await bundle.build(manifestPath: 'pubspec.yaml'); await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages');
expect(bundle.entries.length, 3); // LICENSE, AssetManifest, FontManifest expect(bundle.entries.length, 3); // LICENSE, AssetManifest, FontManifest
const String expectedAssetManifest = '{}'; const String expectedAssetManifest = '{}';
expect( expect(
...@@ -157,7 +157,7 @@ $assetsSection ...@@ -157,7 +157,7 @@ $assetsSection
writeAssets('p/p/', assets); writeAssets('p/p/', assets);
final AssetBundle bundle = AssetBundleFactory.instance.createBundle(); final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
await bundle.build(manifestPath: 'pubspec.yaml'); await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages');
expect(bundle.entries.length, 3); // LICENSE, AssetManifest, FontManifest expect(bundle.entries.length, 3); // LICENSE, AssetManifest, FontManifest
const String expectedAssetManifest = '{}'; const String expectedAssetManifest = '{}';
expect( expect(
...@@ -589,7 +589,7 @@ $assetsSection ...@@ -589,7 +589,7 @@ $assetsSection
writeAssets('p/p/', assetsOnDisk); writeAssets('p/p/', assetsOnDisk);
final AssetBundle bundle = AssetBundleFactory.instance.createBundle(); final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
await bundle.build(manifestPath: 'pubspec.yaml'); await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages');
expect(bundle.entries['AssetManifest.json'], isNull, expect(bundle.entries['AssetManifest.json'], isNull,
reason: 'Invalid pubspec.yaml should not generate AssetManifest.json' ); reason: 'Invalid pubspec.yaml should not generate AssetManifest.json' );
......
...@@ -37,7 +37,7 @@ void main() { ...@@ -37,7 +37,7 @@ void main() {
testUsingContext('nonempty', () async { testUsingContext('nonempty', () async {
final AssetBundle ab = AssetBundleFactory.instance.createBundle(); final AssetBundle ab = AssetBundleFactory.instance.createBundle();
expect(await ab.build(), 0); expect(await ab.build(packagesPath: '.packages'), 0);
expect(ab.entries.length, greaterThan(0)); expect(ab.entries.length, greaterThan(0));
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
FileSystem: () => testFileSystem, FileSystem: () => testFileSystem,
...@@ -50,7 +50,7 @@ void main() { ...@@ -50,7 +50,7 @@ void main() {
..writeAsStringSync(''); ..writeAsStringSync('');
final AssetBundle bundle = AssetBundleFactory.instance.createBundle(); final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
await bundle.build(manifestPath: 'pubspec.yaml'); await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages');
expect(bundle.entries.length, 1); expect(bundle.entries.length, 1);
const String expectedAssetManifest = '{}'; const String expectedAssetManifest = '{}';
expect( expect(
...@@ -74,7 +74,7 @@ flutter: ...@@ -74,7 +74,7 @@ flutter:
- assets/foo/ - assets/foo/
'''); ''');
final AssetBundle bundle = AssetBundleFactory.instance.createBundle(); final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
await bundle.build(manifestPath: 'pubspec.yaml'); await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages');
// Expected assets: // Expected assets:
// - asset manifest // - asset manifest
// - font manifest // - font manifest
...@@ -89,7 +89,7 @@ flutter: ...@@ -89,7 +89,7 @@ flutter:
..setLastModifiedSync(packageFile.lastModifiedSync().add(const Duration(hours: 1))); ..setLastModifiedSync(packageFile.lastModifiedSync().add(const Duration(hours: 1)));
expect(bundle.needsBuild(manifestPath: 'pubspec.yaml'), true); expect(bundle.needsBuild(manifestPath: 'pubspec.yaml'), true);
await bundle.build(manifestPath: 'pubspec.yaml'); await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages');
// Expected assets: // Expected assets:
// - asset manifest // - asset manifest
// - font manifest // - font manifest
...@@ -114,7 +114,7 @@ flutter: ...@@ -114,7 +114,7 @@ flutter:
'''); ''');
globals.fs.file('.packages').createSync(); globals.fs.file('.packages').createSync();
final AssetBundle bundle = AssetBundleFactory.instance.createBundle(); final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
await bundle.build(manifestPath: 'pubspec.yaml'); await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages');
// Expected assets: // Expected assets:
// - asset manifest // - asset manifest
// - font manifest // - font manifest
...@@ -140,7 +140,7 @@ name: example''') ...@@ -140,7 +140,7 @@ name: example''')
// asset manifest and not updated. This is due to the devfs not // asset manifest and not updated. This is due to the devfs not
// supporting file deletion. // supporting file deletion.
expect(bundle.needsBuild(manifestPath: 'pubspec.yaml'), true); expect(bundle.needsBuild(manifestPath: 'pubspec.yaml'), true);
await bundle.build(manifestPath: 'pubspec.yaml'); await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages');
// Expected assets: // Expected assets:
// - asset manifest // - asset manifest
// - font manifest // - font manifest
...@@ -168,7 +168,7 @@ flutter: ...@@ -168,7 +168,7 @@ flutter:
'''); ''');
globals.fs.file('.packages').createSync(); globals.fs.file('.packages').createSync();
final AssetBundle bundle = AssetBundleFactory.instance.createBundle(); final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
await bundle.build(manifestPath: 'pubspec.yaml'); await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages');
// Expected assets: // Expected assets:
// - asset manifest // - asset manifest
// - font manifest // - font manifest
...@@ -205,7 +205,7 @@ assets: ...@@ -205,7 +205,7 @@ assets:
- assets/foo/bar.txt - assets/foo/bar.txt
'''); ''');
final AssetBundle bundle = AssetBundleFactory.instance.createBundle(); final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
await bundle.build(manifestPath: 'pubspec.yaml'); await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages');
final DevFSStringContent assetManifest = bundle.entries['AssetManifest.json'] final DevFSStringContent assetManifest = bundle.entries['AssetManifest.json']
as DevFSStringContent; as DevFSStringContent;
...@@ -214,7 +214,7 @@ assets: ...@@ -214,7 +214,7 @@ assets:
final DevFSStringContent license = bundle.entries['NOTICES'] final DevFSStringContent license = bundle.entries['NOTICES']
as DevFSStringContent; as DevFSStringContent;
await bundle.build(manifestPath: 'pubspec.yaml'); await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages');
expect(assetManifest, bundle.entries['AssetManifest.json']); expect(assetManifest, bundle.entries['AssetManifest.json']);
expect(fontManifest, bundle.entries['FontManifest.json']); expect(fontManifest, bundle.entries['FontManifest.json']);
...@@ -238,7 +238,7 @@ flutter: ...@@ -238,7 +238,7 @@ flutter:
'''); ''');
final AssetBundle bundle = AssetBundleFactory.instance.createBundle(); final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
expect(await bundle.build(manifestPath: 'pubspec.yaml'), 0); expect(await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages'), 0);
expect(bundle.additionalDependencies.single.path, contains('DOES_NOT_EXIST_RERUN_FOR_WILDCARD')); expect(bundle.additionalDependencies.single.path, contains('DOES_NOT_EXIST_RERUN_FOR_WILDCARD'));
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
FileSystem: () => MemoryFileSystem.test(), FileSystem: () => MemoryFileSystem.test(),
...@@ -259,7 +259,7 @@ flutter: ...@@ -259,7 +259,7 @@ flutter:
'''); ''');
final AssetBundle bundle = AssetBundleFactory.instance.createBundle(); final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
expect(await bundle.build(manifestPath: 'pubspec.yaml'), 0); expect(await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages'), 0);
expect(bundle.additionalDependencies, isEmpty); expect(bundle.additionalDependencies, isEmpty);
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
FileSystem: () => MemoryFileSystem.test(), FileSystem: () => MemoryFileSystem.test(),
...@@ -293,7 +293,7 @@ flutter: ...@@ -293,7 +293,7 @@ flutter:
final AssetBundle bundle = AssetBundleFactory.instance.createBundle(); final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
globals.fs.file('foo/bar/fizz.txt').createSync(recursive: true); globals.fs.file('foo/bar/fizz.txt').createSync(recursive: true);
expect(await bundle.build(manifestPath: 'pubspec.yaml'), 0); expect(await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages'), 0);
expect(bundle.additionalDependencies, isEmpty); expect(bundle.additionalDependencies, isEmpty);
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
FileSystem: () => MemoryFileSystem.test(), FileSystem: () => MemoryFileSystem.test(),
...@@ -327,7 +327,7 @@ flutter: ...@@ -327,7 +327,7 @@ flutter:
final AssetBundle bundle = AssetBundleFactory.instance.createBundle(); final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
globals.fs.file('foo/bar/fizz.txt').createSync(recursive: true); globals.fs.file('foo/bar/fizz.txt').createSync(recursive: true);
await bundle.build(manifestPath: 'pubspec.yaml'); await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages');
expect(bundle.entries, hasLength(4)); expect(bundle.entries, hasLength(4));
expect(bundle.needsBuild(manifestPath: 'pubspec.yaml'), false); expect(bundle.needsBuild(manifestPath: 'pubspec.yaml'), false);
...@@ -369,7 +369,7 @@ flutter: ...@@ -369,7 +369,7 @@ flutter:
'''); ''');
final AssetBundle bundle = AssetBundleFactory.instance.createBundle(); final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
expect(await bundle.build(manifestPath: 'pubspec.yaml'), 1); expect(await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages'), 1);
expect(testLogger.errorText, contains('This asset was included from package foo')); expect(testLogger.errorText, contains('This asset was included from package foo'));
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
FileSystem: () => MemoryFileSystem.test(), FileSystem: () => MemoryFileSystem.test(),
...@@ -392,7 +392,7 @@ flutter: ...@@ -392,7 +392,7 @@ flutter:
'''); ''');
final AssetBundle bundle = AssetBundleFactory.instance.createBundle(); final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
expect(await bundle.build(manifestPath: 'pubspec.yaml'), 1); expect(await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages'), 1);
expect(testLogger.errorText, isNot(contains('This asset was included from'))); expect(testLogger.errorText, isNot(contains('This asset was included from')));
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
FileSystem: () => MemoryFileSystem.test(), FileSystem: () => MemoryFileSystem.test(),
...@@ -426,7 +426,7 @@ flutter: ...@@ -426,7 +426,7 @@ flutter:
'''); ''');
final AssetBundle bundle = AssetBundleFactory.instance.createBundle(); final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
expect(await bundle.build(manifestPath: 'pubspec.yaml'), 0); expect(await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages'), 0);
expect((bundle.entries['FontManifest.json'] as DevFSStringContent).string, '[]'); expect((bundle.entries['FontManifest.json'] as DevFSStringContent).string, '[]');
expect((bundle.entries['AssetManifest.json'] as DevFSStringContent).string, '{}'); expect((bundle.entries['AssetManifest.json'] as DevFSStringContent).string, '{}');
expect(testLogger.errorText, contains( expect(testLogger.errorText, contains(
......
...@@ -72,7 +72,7 @@ flutter: ...@@ -72,7 +72,7 @@ flutter:
} }
AssetBundle bundle = AssetBundleFactory.instance.createBundle(); AssetBundle bundle = AssetBundleFactory.instance.createBundle();
await bundle.build(manifestPath: 'pubspec.yaml'); await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages');
// The main asset file, /a/b/c/foo, and its variants exist. // The main asset file, /a/b/c/foo, and its variants exist.
for (final String asset in assets) { for (final String asset in assets) {
...@@ -82,7 +82,7 @@ flutter: ...@@ -82,7 +82,7 @@ flutter:
globals.fs.file(fixPath('a/b/c/foo')).deleteSync(); globals.fs.file(fixPath('a/b/c/foo')).deleteSync();
bundle = AssetBundleFactory.instance.createBundle(); bundle = AssetBundleFactory.instance.createBundle();
await bundle.build(manifestPath: 'pubspec.yaml'); await bundle.build(manifestPath: 'pubspec.yaml', packagesPath: '.packages');
// Now the main asset file, /a/b/c/foo, does not exist. This is OK because // Now the main asset file, /a/b/c/foo, does not exist. This is OK because
// the /a/b/c/*/foo variants do exist. // the /a/b/c/*/foo variants do exist.
......
...@@ -106,6 +106,7 @@ void main() { ...@@ -106,6 +106,7 @@ void main() {
extraFrontEndOptions: <String>['--enable-experiment=non-nullable', 'bar'], extraFrontEndOptions: <String>['--enable-experiment=non-nullable', 'bar'],
extraGenSnapshotOptions: <String>['--enable-experiment=non-nullable', 'fizz'], extraGenSnapshotOptions: <String>['--enable-experiment=non-nullable', 'fizz'],
bundleSkSLPath: 'foo/bar/baz.sksl.json', bundleSkSLPath: 'foo/bar/baz.sksl.json',
packagesPath: 'foo/.packages',
); );
expect(buildInfo.toEnvironmentConfig(), <String, String>{ expect(buildInfo.toEnvironmentConfig(), <String, String>{
...@@ -117,6 +118,7 @@ void main() { ...@@ -117,6 +118,7 @@ void main() {
'EXTRA_FRONT_END_OPTIONS': '--enable-experiment%3Dnon-nullable,bar', 'EXTRA_FRONT_END_OPTIONS': '--enable-experiment%3Dnon-nullable,bar',
'EXTRA_GEN_SNAPSHOT_OPTIONS': '--enable-experiment%3Dnon-nullable,fizz', 'EXTRA_GEN_SNAPSHOT_OPTIONS': '--enable-experiment%3Dnon-nullable,fizz',
'BUNDLE_SKSL_PATH': 'foo/bar/baz.sksl.json', 'BUNDLE_SKSL_PATH': 'foo/bar/baz.sksl.json',
'PACKAGE_CONFIG': 'foo/.packages',
}); });
}); });
......
...@@ -11,7 +11,6 @@ import 'package:flutter_tools/src/build_system/build_system.dart'; ...@@ -11,7 +11,6 @@ import 'package:flutter_tools/src/build_system/build_system.dart';
import 'package:flutter_tools/src/build_system/depfile.dart'; import 'package:flutter_tools/src/build_system/depfile.dart';
import 'package:flutter_tools/src/build_system/targets/common.dart'; import 'package:flutter_tools/src/build_system/targets/common.dart';
import 'package:flutter_tools/src/build_system/targets/web.dart'; import 'package:flutter_tools/src/build_system/targets/web.dart';
import 'package:flutter_tools/src/dart/package_map.dart';
import 'package:flutter_tools/src/globals.dart' as globals; import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:mockito/mockito.dart'; import 'package:mockito/mockito.dart';
import 'package:process/process.dart'; import 'package:process/process.dart';
...@@ -44,10 +43,9 @@ void main() { ...@@ -44,10 +43,9 @@ void main() {
setUp(() { setUp(() {
testbed = Testbed(setup: () { testbed = Testbed(setup: () {
final File packagesFile = globals.fs.file(globals.fs.path.join('foo', '.packages')) globals.fs.file('.packages')
..createSync(recursive: true) ..createSync(recursive: true)
..writeAsStringSync('foo:lib/\n'); ..writeAsStringSync('foo:foo/lib/\n');
globalPackagesPath = packagesFile.path;
globals.fs.currentDirectory.childDirectory('bar').createSync(); globals.fs.currentDirectory.childDirectory('bar').createSync();
processManager = FakeProcessManager.list(<FakeCommand>[]); processManager = FakeProcessManager.list(<FakeCommand>[]);
...@@ -229,7 +227,7 @@ void main() { ...@@ -229,7 +227,7 @@ void main() {
...kDart2jsLinuxArgs, ...kDart2jsLinuxArgs,
'-o', '-o',
environment.buildDir.childFile('app.dill').absolute.path, environment.buildDir.childFile('app.dill').absolute.path,
'--packages=${globals.fs.path.join('foo', '.packages')}', '--packages=.packages',
'-Ddart.vm.profile=true', '-Ddart.vm.profile=true',
'--cfe-only', '--cfe-only',
environment.buildDir.childFile('main.dart').absolute.path, environment.buildDir.childFile('main.dart').absolute.path,
...@@ -263,7 +261,7 @@ void main() { ...@@ -263,7 +261,7 @@ void main() {
'--enable-experiment=non-nullable', '--enable-experiment=non-nullable',
'-o', '-o',
environment.buildDir.childFile('app.dill').absolute.path, environment.buildDir.childFile('app.dill').absolute.path,
'--packages=${globals.fs.path.join('foo', '.packages')}', '--packages=.packages',
'-Ddart.vm.profile=true', '-Ddart.vm.profile=true',
'--cfe-only', '--cfe-only',
environment.buildDir.childFile('main.dart').absolute.path, environment.buildDir.childFile('main.dart').absolute.path,
...@@ -294,7 +292,7 @@ void main() { ...@@ -294,7 +292,7 @@ void main() {
...kDart2jsLinuxArgs, ...kDart2jsLinuxArgs,
'-o', '-o',
environment.buildDir.childFile('app.dill').absolute.path, environment.buildDir.childFile('app.dill').absolute.path,
'--packages=${globals.fs.path.join('foo', '.packages')}', '--packages=.packages',
'-Ddart.vm.profile=true', '-Ddart.vm.profile=true',
'--cfe-only', '--cfe-only',
environment.buildDir.childFile('main.dart').absolute.path, environment.buildDir.childFile('main.dart').absolute.path,
...@@ -324,7 +322,7 @@ void main() { ...@@ -324,7 +322,7 @@ void main() {
...kDart2jsLinuxArgs, ...kDart2jsLinuxArgs,
'-o', '-o',
environment.buildDir.childFile('app.dill').absolute.path, environment.buildDir.childFile('app.dill').absolute.path,
'--packages=${globals.fs.path.join('foo', '.packages')}', '--packages=.packages',
'-Ddart.vm.product=true', '-Ddart.vm.product=true',
'--cfe-only', '--cfe-only',
environment.buildDir.childFile('main.dart').absolute.path, environment.buildDir.childFile('main.dart').absolute.path,
...@@ -354,7 +352,7 @@ void main() { ...@@ -354,7 +352,7 @@ void main() {
...kDart2jsLinuxArgs, ...kDart2jsLinuxArgs,
'-o', '-o',
environment.buildDir.childFile('app.dill').absolute.path, environment.buildDir.childFile('app.dill').absolute.path,
'--packages=${globals.fs.path.join('foo', '.packages')}', '--packages=.packages',
'-Ddart.vm.product=true', '-Ddart.vm.product=true',
'--cfe-only', '--cfe-only',
environment.buildDir.childFile('main.dart').absolute.path, environment.buildDir.childFile('main.dart').absolute.path,
...@@ -403,7 +401,7 @@ void main() { ...@@ -403,7 +401,7 @@ void main() {
...kDart2jsLinuxArgs, ...kDart2jsLinuxArgs,
'-o', '-o',
environment.buildDir.childFile('app.dill').absolute.path, environment.buildDir.childFile('app.dill').absolute.path,
'--packages=${globals.fs.path.join('foo', '.packages')}', '--packages=.packages',
'-Ddart.vm.product=true', '-Ddart.vm.product=true',
'-DFOO=bar', '-DFOO=bar',
'-DBAZ=qux', '-DBAZ=qux',
...@@ -437,7 +435,7 @@ void main() { ...@@ -437,7 +435,7 @@ void main() {
...kDart2jsLinuxArgs, ...kDart2jsLinuxArgs,
'-o', '-o',
environment.buildDir.childFile('app.dill').absolute.path, environment.buildDir.childFile('app.dill').absolute.path,
'--packages=${globals.fs.path.join('foo', '.packages')}', '--packages=.packages',
'-Ddart.vm.profile=true', '-Ddart.vm.profile=true',
'-DFOO=bar', '-DFOO=bar',
'-DBAZ=qux', '-DBAZ=qux',
......
...@@ -77,7 +77,10 @@ void main() { ...@@ -77,7 +77,10 @@ void main() {
final MockFlutterDevice mockFlutterDevice = MockFlutterDevice(); final MockFlutterDevice mockFlutterDevice = MockFlutterDevice();
when(mockFlutterDevice.device).thenReturn(mockDevice); when(mockFlutterDevice.device).thenReturn(mockDevice);
final List<FlutterDevice> devices = <FlutterDevice>[mockFlutterDevice]; final List<FlutterDevice> devices = <FlutterDevice>[mockFlutterDevice];
final int result = await ColdRunner(devices).run(); final int result = await ColdRunner(
devices,
debuggingOptions: DebuggingOptions.disabled(BuildInfo.debug),
).run();
expect(result, 1); expect(result, 1);
expect(testLogger.errorText, matches(r'Tried to run .*, but that file does not exist\.')); expect(testLogger.errorText, matches(r'Tried to run .*, but that file does not exist\.'));
......
...@@ -7,7 +7,6 @@ import 'dart:async'; ...@@ -7,7 +7,6 @@ import 'dart:async';
import 'package:file/memory.dart'; import 'package:file/memory.dart';
import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/platform.dart'; import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/dart/package_map.dart';
import 'package:vm_service/vm_service.dart' as vm_service; import 'package:vm_service/vm_service.dart' as vm_service;
import 'package:flutter_tools/src/artifacts.dart'; import 'package:flutter_tools/src/artifacts.dart';
import 'package:flutter_tools/src/base/io.dart'; import 'package:flutter_tools/src/base/io.dart';
...@@ -163,7 +162,7 @@ void main() { ...@@ -163,7 +162,7 @@ void main() {
}); });
testUsingContext('Does not hot restart when device does not support it', () async { testUsingContext('Does not hot restart when device does not support it', () async {
fileSystem.file(globalPackagesPath) fileSystem.file('.packages')
..createSync(recursive: true) ..createSync(recursive: true)
..writeAsStringSync('\n'); ..writeAsStringSync('\n');
// Setup mocks // Setup mocks
...@@ -175,7 +174,10 @@ void main() { ...@@ -175,7 +174,10 @@ void main() {
final List<FlutterDevice> devices = <FlutterDevice>[ final List<FlutterDevice> devices = <FlutterDevice>[
FlutterDevice(mockDevice, generator: residentCompiler, buildInfo: BuildInfo.debug)..devFS = mockDevFs, FlutterDevice(mockDevice, generator: residentCompiler, buildInfo: BuildInfo.debug)..devFS = mockDevFs,
]; ];
final OperationResult result = await HotRunner(devices).restart(fullRestart: true); final OperationResult result = await HotRunner(
devices,
debuggingOptions: DebuggingOptions.disabled(BuildInfo.debug),
).restart(fullRestart: true);
// Expect hot restart failed. // Expect hot restart failed.
expect(result.isOk, false); expect(result.isOk, false);
expect(result.message, 'hotRestart not supported'); expect(result.message, 'hotRestart not supported');
...@@ -188,7 +190,7 @@ void main() { ...@@ -188,7 +190,7 @@ void main() {
}); });
testUsingContext('Does not hot restart when one of many devices does not support it', () async { testUsingContext('Does not hot restart when one of many devices does not support it', () async {
fileSystem.file(globalPackagesPath) fileSystem.file('.packages')
..createSync(recursive: true) ..createSync(recursive: true)
..writeAsStringSync('\n'); ..writeAsStringSync('\n');
// Setup mocks // Setup mocks
...@@ -203,7 +205,10 @@ void main() { ...@@ -203,7 +205,10 @@ void main() {
FlutterDevice(mockDevice, generator: residentCompiler, buildInfo: BuildInfo.debug)..devFS = mockDevFs, FlutterDevice(mockDevice, generator: residentCompiler, buildInfo: BuildInfo.debug)..devFS = mockDevFs,
FlutterDevice(mockHotDevice, generator: residentCompiler, buildInfo: BuildInfo.debug)..devFS = mockDevFs, FlutterDevice(mockHotDevice, generator: residentCompiler, buildInfo: BuildInfo.debug)..devFS = mockDevFs,
]; ];
final OperationResult result = await HotRunner(devices).restart(fullRestart: true); final OperationResult result = await HotRunner(
devices,
debuggingOptions: DebuggingOptions.disabled(BuildInfo.debug)
).restart(fullRestart: true);
// Expect hot restart failed. // Expect hot restart failed.
expect(result.isOk, false); expect(result.isOk, false);
expect(result.message, 'hotRestart not supported'); expect(result.message, 'hotRestart not supported');
...@@ -302,7 +307,10 @@ void main() { ...@@ -302,7 +307,10 @@ void main() {
..vmService = fakeVmServiceHost.vmService ..vmService = fakeVmServiceHost.vmService
..devFS = mockDevFs, ..devFS = mockDevFs,
]; ];
final HotRunner hotRunner = HotRunner(devices); final HotRunner hotRunner = HotRunner(
devices,
debuggingOptions: DebuggingOptions.disabled(BuildInfo.debug),
);
final OperationResult result = await hotRunner.restart(fullRestart: true); final OperationResult result = await hotRunner.restart(fullRestart: true);
// Expect hot restart was successful. // Expect hot restart was successful.
expect(hotRunner.uri, mockDevFs.baseUri); expect(hotRunner.uri, mockDevFs.baseUri);
...@@ -317,7 +325,7 @@ void main() { ...@@ -317,7 +325,7 @@ void main() {
}); });
testUsingContext('setup function fails', () async { testUsingContext('setup function fails', () async {
fileSystem.file(globalPackagesPath) fileSystem.file('.packages')
..createSync(recursive: true) ..createSync(recursive: true)
..writeAsStringSync('\n'); ..writeAsStringSync('\n');
final MockDevice mockDevice = MockDevice(); final MockDevice mockDevice = MockDevice();
...@@ -327,7 +335,10 @@ void main() { ...@@ -327,7 +335,10 @@ void main() {
final List<FlutterDevice> devices = <FlutterDevice>[ final List<FlutterDevice> devices = <FlutterDevice>[
FlutterDevice(mockDevice, generator: residentCompiler, buildInfo: BuildInfo.debug), FlutterDevice(mockDevice, generator: residentCompiler, buildInfo: BuildInfo.debug),
]; ];
final OperationResult result = await HotRunner(devices).restart(fullRestart: true); final OperationResult result = await HotRunner(
devices,
debuggingOptions: DebuggingOptions.disabled(BuildInfo.debug),
).restart(fullRestart: true);
expect(result.isOk, false); expect(result.isOk, false);
expect(result.message, 'setupHotRestart failed'); expect(result.message, 'setupHotRestart failed');
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
...@@ -339,7 +350,7 @@ void main() { ...@@ -339,7 +350,7 @@ void main() {
}); });
testUsingContext('hot restart supported', () async { testUsingContext('hot restart supported', () async {
fileSystem.file(globalPackagesPath) fileSystem.file('.packages')
..createSync(recursive: true) ..createSync(recursive: true)
..writeAsStringSync('\n'); ..writeAsStringSync('\n');
// Setup mocks // Setup mocks
...@@ -389,7 +400,10 @@ void main() { ...@@ -389,7 +400,10 @@ void main() {
..vmService = fakeVmServiceHost.vmService ..vmService = fakeVmServiceHost.vmService
..devFS = mockDevFs, ..devFS = mockDevFs,
]; ];
final HotRunner hotRunner = HotRunner(devices); final HotRunner hotRunner = HotRunner(
devices,
debuggingOptions: DebuggingOptions.disabled(BuildInfo.debug),
);
final OperationResult result = await hotRunner.restart(fullRestart: true); final OperationResult result = await hotRunner.restart(fullRestart: true);
// Expect hot restart successful. // Expect hot restart successful.
expect(hotRunner.uri, mockDevFs.baseUri); expect(hotRunner.uri, mockDevFs.baseUri);
...@@ -413,7 +427,7 @@ void main() { ...@@ -413,7 +427,7 @@ void main() {
}); });
testUsingContext('shutdown hook called after signal', () async { testUsingContext('shutdown hook called after signal', () async {
fileSystem.file(globalPackagesPath) fileSystem.file('.packages')
..createSync(recursive: true) ..createSync(recursive: true)
..writeAsStringSync('\n'); ..writeAsStringSync('\n');
final MockDevice mockDevice = MockDevice(); final MockDevice mockDevice = MockDevice();
...@@ -423,7 +437,10 @@ void main() { ...@@ -423,7 +437,10 @@ void main() {
final List<FlutterDevice> devices = <FlutterDevice>[ final List<FlutterDevice> devices = <FlutterDevice>[
FlutterDevice(mockDevice, generator: residentCompiler, buildInfo: BuildInfo.debug), FlutterDevice(mockDevice, generator: residentCompiler, buildInfo: BuildInfo.debug),
]; ];
await HotRunner(devices).cleanupAfterSignal(); await HotRunner(
devices,
debuggingOptions: DebuggingOptions.disabled(BuildInfo.debug)
).cleanupAfterSignal();
expect(shutdownTestingConfig.shutdownHookCalled, true); expect(shutdownTestingConfig.shutdownHookCalled, true);
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
HotRunnerConfig: () => shutdownTestingConfig, HotRunnerConfig: () => shutdownTestingConfig,
...@@ -434,7 +451,7 @@ void main() { ...@@ -434,7 +451,7 @@ void main() {
}); });
testUsingContext('shutdown hook called after app stop', () async { testUsingContext('shutdown hook called after app stop', () async {
fileSystem.file(globalPackagesPath) fileSystem.file('.packages')
..createSync(recursive: true) ..createSync(recursive: true)
..writeAsStringSync('\n'); ..writeAsStringSync('\n');
final MockDevice mockDevice = MockDevice(); final MockDevice mockDevice = MockDevice();
...@@ -444,7 +461,10 @@ void main() { ...@@ -444,7 +461,10 @@ void main() {
final List<FlutterDevice> devices = <FlutterDevice>[ final List<FlutterDevice> devices = <FlutterDevice>[
FlutterDevice(mockDevice, generator: residentCompiler, buildInfo: BuildInfo.debug), FlutterDevice(mockDevice, generator: residentCompiler, buildInfo: BuildInfo.debug),
]; ];
await HotRunner(devices).preExit(); await HotRunner(
devices,
debuggingOptions: DebuggingOptions.disabled(BuildInfo.debug)
).preExit();
expect(shutdownTestingConfig.shutdownHookCalled, true); expect(shutdownTestingConfig.shutdownHookCalled, true);
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
HotRunnerConfig: () => shutdownTestingConfig, HotRunnerConfig: () => shutdownTestingConfig,
...@@ -465,7 +485,7 @@ void main() { ...@@ -465,7 +485,7 @@ void main() {
testUsingContext('Exits with code 2 when when HttpException is thrown ' testUsingContext('Exits with code 2 when when HttpException is thrown '
'during VM service connection', () async { 'during VM service connection', () async {
fileSystem.file(globalPackagesPath) fileSystem.file('.packages')
..createSync(recursive: true) ..createSync(recursive: true)
..writeAsStringSync('\n'); ..writeAsStringSync('\n');
......
...@@ -8,7 +8,6 @@ import 'package:file/file.dart'; ...@@ -8,7 +8,6 @@ import 'package:file/file.dart';
import 'package:file/memory.dart'; import 'package:file/memory.dart';
import 'package:file_testing/file_testing.dart'; import 'package:file_testing/file_testing.dart';
import 'package:flutter_tools/src/base/time.dart'; import 'package:flutter_tools/src/base/time.dart';
import 'package:flutter_tools/src/dart/package_map.dart';
import 'package:flutter_tools/src/features.dart'; import 'package:flutter_tools/src/features.dart';
import 'package:flutter_tools/src/globals.dart' as globals; import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:flutter_tools/src/ios/xcodeproj.dart'; import 'package:flutter_tools/src/ios/xcodeproj.dart';
...@@ -107,7 +106,7 @@ void main() { ...@@ -107,7 +106,7 @@ void main() {
// Set up a simple .packages file for all the tests to use, pointing to one package. // Set up a simple .packages file for all the tests to use, pointing to one package.
dummyPackageDirectory = fs.directory('/pubcache/apackage/lib/'); dummyPackageDirectory = fs.directory('/pubcache/apackage/lib/');
packagesFile = fs.file(fs.path.join(flutterProject.directory.path, globalPackagesPath)); packagesFile = fs.file(fs.path.join(flutterProject.directory.path, '.packages'));
packagesFile..createSync(recursive: true) packagesFile..createSync(recursive: true)
..writeAsStringSync('apackage:file://${dummyPackageDirectory.path}\n'); ..writeAsStringSync('apackage:file://${dummyPackageDirectory.path}\n');
}); });
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
import 'dart:async'; import 'dart:async';
import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/dart/package_map.dart';
import 'package:vm_service/vm_service.dart' as vm_service; import 'package:vm_service/vm_service.dart' as vm_service;
import 'package:file/memory.dart'; import 'package:file/memory.dart';
import 'package:file_testing/file_testing.dart'; import 'package:file_testing/file_testing.dart';
...@@ -93,9 +92,8 @@ void main() { ...@@ -93,9 +92,8 @@ void main() {
setUp(() { setUp(() {
testbed = Testbed(setup: () { testbed = Testbed(setup: () {
globals.fs.file(globalPackagesPath) globals.fs.file('.packages')
..createSync(recursive: true) .writeAsStringSync('\n');
..writeAsStringSync('\n');
globals.fs.file(globals.fs.path.join('build', 'app.dill')) globals.fs.file(globals.fs.path.join('build', 'app.dill'))
..createSync(recursive: true) ..createSync(recursive: true)
..writeAsStringSync('ABC'); ..writeAsStringSync('ABC');
...@@ -1124,6 +1122,7 @@ void main() { ...@@ -1124,6 +1122,7 @@ void main() {
final FlutterDevice device = FlutterDevice(mockDevice, buildInfo: BuildInfo.debug); final FlutterDevice device = FlutterDevice(mockDevice, buildInfo: BuildInfo.debug);
final ResidentRunner residentRunner = HotRunner( final ResidentRunner residentRunner = HotRunner(
<FlutterDevice>[device], <FlutterDevice>[device],
debuggingOptions: DebuggingOptions.disabled(BuildInfo.debug)
); );
expect(await residentRunner.listFlutterViews(), isEmpty); expect(await residentRunner.listFlutterViews(), isEmpty);
......
...@@ -16,7 +16,6 @@ import 'package:flutter_tools/src/build_info.dart'; ...@@ -16,7 +16,6 @@ import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/build_runner/devfs_web.dart'; import 'package:flutter_tools/src/build_runner/devfs_web.dart';
import 'package:flutter_tools/src/build_runner/resident_web_runner.dart'; import 'package:flutter_tools/src/build_runner/resident_web_runner.dart';
import 'package:flutter_tools/src/compile.dart'; import 'package:flutter_tools/src/compile.dart';
import 'package:flutter_tools/src/dart/package_map.dart';
import 'package:flutter_tools/src/dart/pub.dart'; import 'package:flutter_tools/src/dart/pub.dart';
import 'package:flutter_tools/src/devfs.dart'; import 'package:flutter_tools/src/devfs.dart';
import 'package:flutter_tools/src/device.dart'; import 'package:flutter_tools/src/device.dart';
...@@ -116,7 +115,7 @@ void main() { ...@@ -116,7 +115,7 @@ void main() {
}); });
testbed = Testbed( testbed = Testbed(
setup: () { setup: () {
globals.fs.file(globalPackagesPath) globals.fs.file('.packages')
..createSync(recursive: true) ..createSync(recursive: true)
..writeAsStringSync('\n'); ..writeAsStringSync('\n');
residentWebRunner = DwdsWebRunnerFactory().createWebRunner( residentWebRunner = DwdsWebRunnerFactory().createWebRunner(
...@@ -127,8 +126,6 @@ void main() { ...@@ -127,8 +126,6 @@ void main() {
stayResident: true, stayResident: true,
urlTunneller: null, urlTunneller: null,
) as ResidentWebRunner; ) as ResidentWebRunner;
globals.fs.currentDirectory.childFile('.packages')
.writeAsStringSync('\n');
}, },
overrides: <Type, Generator>{ overrides: <Type, Generator>{
Pub: () => MockPub(), Pub: () => MockPub(),
......
...@@ -9,7 +9,6 @@ import 'package:flutter_tools/src/base/logger.dart'; ...@@ -9,7 +9,6 @@ import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/base/platform.dart'; import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/build_info.dart'; import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/compile.dart'; import 'package:flutter_tools/src/compile.dart';
import 'package:flutter_tools/src/dart/package_map.dart';
import 'package:flutter_tools/src/project.dart'; import 'package:flutter_tools/src/project.dart';
import 'package:flutter_tools/src/test/test_compiler.dart'; import 'package:flutter_tools/src/test/test_compiler.dart';
import 'package:mockito/mockito.dart'; import 'package:mockito/mockito.dart';
...@@ -32,7 +31,7 @@ void main() { ...@@ -32,7 +31,7 @@ void main() {
fileSystem.file('pubspec.yaml').createSync(); fileSystem.file('pubspec.yaml').createSync();
fileSystem.file('.packages').writeAsStringSync('flutter_test:flutter_test/'); fileSystem.file('.packages').writeAsStringSync('flutter_test:flutter_test/');
fileSystem.file('test/foo.dart').createSync(recursive: true); fileSystem.file('test/foo.dart').createSync(recursive: true);
fileSystem.file(globalPackagesPath) fileSystem.file('.packages')
..createSync() ..createSync()
..writeAsStringSync('flutter_test:flutter_test/'); ..writeAsStringSync('flutter_test:flutter_test/');
residentCompiler = MockResidentCompiler(); residentCompiler = MockResidentCompiler();
......
...@@ -416,7 +416,7 @@ void main() { ...@@ -416,7 +416,7 @@ void main() {
packagesFilePath: '.packages', packagesFilePath: '.packages',
urlTunneller: null, urlTunneller: null,
useSseForDebugProxy: true, useSseForDebugProxy: true,
buildMode: BuildMode.debug, buildInfo: BuildInfo.debug,
enableDwds: false, enableDwds: false,
entrypoint: Uri.base, entrypoint: Uri.base,
testMode: true, testMode: true,
...@@ -510,7 +510,7 @@ void main() { ...@@ -510,7 +510,7 @@ void main() {
packagesFilePath: '.packages', packagesFilePath: '.packages',
urlTunneller: null, urlTunneller: null,
useSseForDebugProxy: true, useSseForDebugProxy: true,
buildMode: BuildMode.debug, buildInfo: BuildInfo.debug,
enableDwds: false, enableDwds: false,
entrypoint: Uri.base, entrypoint: Uri.base,
testMode: true, testMode: true,
......
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