[flutter_tools] migrate .packages to package_config, partial (#70200)
This commit is contained in:
parent
5b19328ff0
commit
a40ee8a3fb
@ -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/cache.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/globals.dart' as globals;
|
||||
import 'package:flutter_tools/src/project.dart';
|
||||
@ -108,13 +107,11 @@ Future<void> run(List<String> args) async {
|
||||
// TODO(tvolkert): Remove once flutter_tester no longer looks for this.
|
||||
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;
|
||||
CoverageCollector collector;
|
||||
if (argResults['coverage'] as bool) {
|
||||
collector = CoverageCollector(
|
||||
packagesPath: globals.fs.path.normalize(globals.fs.path.absolute(argResults[_kOptionPackages] as String)),
|
||||
libraryPredicate: (String libraryName) {
|
||||
// If we have a specified coverage directory then accept all libraries.
|
||||
if (coverageDirectory != null) {
|
||||
@ -147,7 +144,12 @@ Future<void> run(List<String> args) async {
|
||||
watcher: collector,
|
||||
ipv6: false,
|
||||
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,
|
||||
concurrency: math.max(1, globals.platform.numberOfProcessors - 2),
|
||||
icudtlPath: globals.fs.path.absolute(argResults[_kOptionIcudtl] as String),
|
||||
|
@ -32,7 +32,7 @@ class BuildInfo {
|
||||
this.dartExperiments = const <String>[],
|
||||
@required this.treeShakeIcons,
|
||||
this.performanceMeasurementFile,
|
||||
this.packagesPath = '.packages',
|
||||
this.packagesPath = '.packages', // TODO(jonahwilliams): make this required and remove the default.
|
||||
this.nullSafetyMode = NullSafetyMode.autodetect,
|
||||
this.codeSizeDirectory,
|
||||
this.androidGradleDaemon = true,
|
||||
|
@ -81,9 +81,7 @@ class BundleBuilder {
|
||||
String manifestPath = defaultManifestPath,
|
||||
String applicationKernelFilePath,
|
||||
String depfilePath,
|
||||
String privateKeyPath = defaultPrivateKeyPath,
|
||||
String assetDirPath,
|
||||
String packagesPath,
|
||||
bool precompiledSnapshot = false,
|
||||
bool reportLicensedPackages = false,
|
||||
bool trackWidgetCreation = false,
|
||||
@ -96,7 +94,6 @@ class BundleBuilder {
|
||||
mainPath ??= defaultMainPath;
|
||||
depfilePath ??= defaultDepfilePath;
|
||||
assetDirPath ??= getAssetBuildDirectory();
|
||||
packagesPath ??= globals.fs.path.absolute('.packages');
|
||||
final FlutterProject flutterProject = FlutterProject.current();
|
||||
await buildWithAssemble(
|
||||
buildMode: buildInfo.mode,
|
||||
|
@ -741,7 +741,7 @@ class PubDependencies extends ArtifactSet {
|
||||
FileSystem fileSystem,
|
||||
) async {
|
||||
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()) {
|
||||
return false;
|
||||
|
@ -121,7 +121,6 @@ class BuildBundleCommand extends BuildSubCommand {
|
||||
mainPath: targetFile,
|
||||
manifestPath: stringArg('manifest'),
|
||||
depfilePath: stringArg('depfile'),
|
||||
privateKeyPath: stringArg('private-key'),
|
||||
assetDirPath: stringArg('asset-dir'),
|
||||
precompiledSnapshot: boolArg('precompiled'),
|
||||
reportLicensedPackages: boolArg('report-licensed-packages'),
|
||||
|
@ -171,6 +171,7 @@ class TestCommand extends FlutterCommand {
|
||||
final List<String> plainNames = stringsArg('plain-name');
|
||||
final String tags = stringArg('tags');
|
||||
final String excludeTags = stringArg('exclude-tags');
|
||||
final BuildInfo buildInfo = getBuildInfo(forcedBuildMode: BuildMode.debug);
|
||||
|
||||
if (buildTestAssets && flutterProject.manifest.assets.isNotEmpty) {
|
||||
await _buildTestAsset();
|
||||
@ -225,6 +226,8 @@ class TestCommand extends FlutterCommand {
|
||||
collector = CoverageCollector(
|
||||
verbose: !machine,
|
||||
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 {
|
||||
}
|
||||
|
||||
final bool disableServiceAuthCodes = boolArg('disable-service-auth-codes');
|
||||
final BuildInfo buildInfo = getBuildInfo(forcedBuildMode: BuildMode.debug);
|
||||
|
||||
final int result = await testRunner.runTests(
|
||||
testWrapper,
|
||||
|
@ -11,23 +11,10 @@ import '../base/common.dart';
|
||||
import '../base/file_system.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]
|
||||
/// 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.
|
||||
Future<PackageConfig> loadPackageConfigWithLogging(File file, {
|
||||
@required Logger logger,
|
||||
|
@ -1092,7 +1092,7 @@ Future<Directory> _loadDwdsDirectory(
|
||||
final String toolPackagePath =
|
||||
fileSystem.path.join(Cache.flutterRoot, 'packages', 'flutter_tools');
|
||||
final String packageFilePath =
|
||||
fileSystem.path.join(toolPackagePath, kPackagesFileName);
|
||||
fileSystem.path.join(toolPackagePath, '.dart_tool', 'package_config.json');
|
||||
final PackageConfig packageConfig = await loadPackageConfigWithLogging(
|
||||
fileSystem.file(packageFilePath),
|
||||
logger: logger,
|
||||
|
@ -369,9 +369,8 @@ class FlutterDevice {
|
||||
|
||||
Future<Uri> setupDevFS(
|
||||
String fsName,
|
||||
Directory rootDirectory, {
|
||||
String packagesFilePath,
|
||||
}) {
|
||||
Directory rootDirectory,
|
||||
) {
|
||||
// One devFS per device. Shared by all running instances.
|
||||
devFS = DevFS(
|
||||
vmService,
|
||||
|
@ -366,7 +366,6 @@ class HotRunner extends ResidentRunner {
|
||||
await device.setupDevFS(
|
||||
fsName,
|
||||
globals.fs.directory(projectRootPath),
|
||||
packagesFilePath: packagesFilePath,
|
||||
),
|
||||
];
|
||||
}
|
||||
|
@ -21,7 +21,6 @@ import '../build_system/targets/icon_tree_shaker.dart' show kIconTreeShakerEnabl
|
||||
import '../bundle.dart' as bundle;
|
||||
import '../cache.dart';
|
||||
import '../dart/generate_synthetic_packages.dart';
|
||||
import '../dart/package_map.dart';
|
||||
import '../dart/pub.dart';
|
||||
import '../device.dart';
|
||||
import '../features.dart';
|
||||
@ -882,7 +881,8 @@ abstract class FlutterCommand extends Command<void> {
|
||||
bundleSkSLPath: bundleSkSLPath,
|
||||
dartExperiments: experiments,
|
||||
performanceMeasurementFile: performanceMeasurementFile,
|
||||
packagesPath: globalResults['packages'] as String ?? '.packages',
|
||||
packagesPath: globalResults['packages'] as String
|
||||
?? globals.fs.path.absolute('.dart_tool', 'package_config.json'),
|
||||
nullSafetyMode: nullSafetyMode,
|
||||
codeSizeDirectory: codeSizeDirectory,
|
||||
androidGradleDaemon: androidGradleDaemon,
|
||||
@ -1174,7 +1174,7 @@ abstract class FlutterCommand extends Command<void> {
|
||||
@protected
|
||||
@mustCallSuper
|
||||
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.
|
||||
|
||||
// If there is no pubspec in the current directory, look in the parent
|
||||
|
@ -16,7 +16,6 @@ import '../base/user_messages.dart';
|
||||
import '../base/utils.dart';
|
||||
import '../cache.dart';
|
||||
import '../convert.dart';
|
||||
import '../dart/package_map.dart';
|
||||
import '../globals.dart' as globals;
|
||||
import '../tester/flutter_tester.dart';
|
||||
|
||||
@ -82,19 +81,9 @@ class FlutterCommandRunner extends CommandRunner<void> {
|
||||
argParser.addFlag('suppress-analytics',
|
||||
negatable: false,
|
||||
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',
|
||||
hide: !showPackagesCommand,
|
||||
help: 'Path to your ".packages" file.\n$packagesHelp');
|
||||
hide: !verboseHelp,
|
||||
help: 'Path to your "package_config.json" file.');
|
||||
if (verboseHelp) {
|
||||
argParser.addSeparator('Local build selection options (not normally required):');
|
||||
}
|
||||
@ -219,7 +208,8 @@ class FlutterCommandRunner extends CommandRunner<void> {
|
||||
// Set up the tooling configuration.
|
||||
final EngineBuildPaths engineBuildPaths = await globals.localEngineLocator.findEnginePath(
|
||||
topLevelResults['local-engine-src-path'] as String,
|
||||
topLevelResults['local-engine'] as String
|
||||
topLevelResults['local-engine'] as String,
|
||||
topLevelResults['packages'] as String,
|
||||
);
|
||||
if (engineBuildPaths != null) {
|
||||
contextOverrides.addAll(<Type, dynamic>{
|
||||
@ -254,10 +244,6 @@ class FlutterCommandRunner extends CommandRunner<void> {
|
||||
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.
|
||||
globals.deviceManager.specifiedDeviceId = topLevelResults['device-id'] as String;
|
||||
|
||||
|
@ -47,13 +47,16 @@ class LocalEngineLocator {
|
||||
final UserMessages _userMessages;
|
||||
|
||||
/// 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];
|
||||
|
||||
if (engineSourcePath == null && localEngine != null) {
|
||||
try {
|
||||
final PackageConfig packageConfig = await loadPackageConfigWithLogging(
|
||||
_fileSystem.file(globalPackagesPath),
|
||||
_fileSystem.file(
|
||||
// TODO(jonahwilliams): update to package_config
|
||||
packagePath ?? _fileSystem.path.join('.packages'),
|
||||
),
|
||||
logger: _logger,
|
||||
throwOnError: false,
|
||||
);
|
||||
|
@ -281,7 +281,7 @@ Directory _templateDirectoryInPackage(String name, FileSystem fileSystem) {
|
||||
Future<Directory> _templateImageDirectory(String name, FileSystem fileSystem, Logger logger) async {
|
||||
final String toolPackagePath = fileSystem.path.join(
|
||||
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(
|
||||
fileSystem.file(packageFilePath),
|
||||
logger: logger,
|
||||
|
@ -3,13 +3,13 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:coverage/coverage.dart' as coverage;
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:vm_service/vm_service.dart' as vm_service;
|
||||
|
||||
import '../base/file_system.dart';
|
||||
import '../base/io.dart';
|
||||
import '../base/process.dart';
|
||||
import '../base/utils.dart';
|
||||
import '../dart/package_map.dart';
|
||||
import '../globals.dart' as globals;
|
||||
import '../vmservice.dart';
|
||||
|
||||
@ -17,9 +17,10 @@ import 'watcher.dart';
|
||||
|
||||
/// A class that's used to collect coverage data during tests.
|
||||
class CoverageCollector extends TestWatcher {
|
||||
CoverageCollector({this.libraryPredicate, this.verbose = true});
|
||||
CoverageCollector({this.libraryPredicate, this.verbose = true, @required this.packagesPath});
|
||||
|
||||
final bool verbose;
|
||||
final String packagesPath;
|
||||
Map<String, Map<int, int>> _globalHitmap;
|
||||
bool Function(String) libraryPredicate;
|
||||
|
||||
@ -66,7 +67,7 @@ class CoverageCollector extends TestWatcher {
|
||||
_logMessage('($observatoryUri): collected coverage data; merging...');
|
||||
_addHitmap(await coverage.createHitmap(
|
||||
data['coverage'] as List<Map<String, dynamic>>,
|
||||
packagesPath: globalPackagesPath,
|
||||
packagesPath: packagesPath,
|
||||
checkIgnoredLines: true,
|
||||
));
|
||||
_logMessage('($observatoryUri): done merging coverage data into global coverage map.');
|
||||
@ -102,7 +103,7 @@ class CoverageCollector extends TestWatcher {
|
||||
_logMessage('pid $pid ($observatoryUri): collected coverage data; merging...');
|
||||
_addHitmap(await coverage.createHitmap(
|
||||
data['coverage'] as List<Map<String, dynamic>>,
|
||||
packagesPath: globalPackagesPath,
|
||||
packagesPath: packagesPath,
|
||||
checkIgnoredLines: true,
|
||||
));
|
||||
_logMessage('pid $pid ($observatoryUri): done merging coverage data into global coverage map.');
|
||||
@ -116,12 +117,13 @@ class CoverageCollector extends TestWatcher {
|
||||
Future<String> finalizeCoverage({
|
||||
coverage.Formatter formatter,
|
||||
Directory coverageDirectory,
|
||||
String packagesPath,
|
||||
}) async {
|
||||
if (_globalHitmap == null) {
|
||||
return 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 List<String> reportOn = coverageDirectory == null
|
||||
? <String>[globals.fs.path.join(packagePath, 'lib')]
|
||||
|
@ -377,7 +377,7 @@ class FlutterPlatform extends PlatformPlugin {
|
||||
int ourTestCount,
|
||||
) async {
|
||||
_packageConfig ??= await loadPackageConfigWithLogging(
|
||||
globals.fs.file(globalPackagesPath),
|
||||
globals.fs.file(buildInfo.packagesPath),
|
||||
logger: globals.logger,
|
||||
);
|
||||
globals.printTrace('test $ourTestCount: starting test $testPath');
|
||||
@ -446,7 +446,7 @@ class FlutterPlatform extends PlatformPlugin {
|
||||
final Process process = await _startProcess(
|
||||
shellPath,
|
||||
mainDart,
|
||||
packages: globalPackagesPath,
|
||||
packages: buildInfo.packagesPath,
|
||||
enableObservatory: enableObservatory,
|
||||
startPaused: startPaused,
|
||||
disableServiceAuthCodes: disableServiceAuthCodes,
|
||||
|
@ -90,7 +90,7 @@ class FlutterWebPlatform extends PlatformPlugin {
|
||||
}
|
||||
|
||||
final Future<PackageConfig> _packagesFuture = loadPackageConfigWithLogging(
|
||||
globals.fs.file(globalPackagesPath),
|
||||
globals.fs.file(globals.fs.path.join('.dart_tool', 'package_config.json')),
|
||||
logger: globals.logger,
|
||||
);
|
||||
|
||||
@ -864,7 +864,7 @@ class TestGoldenComparator {
|
||||
shellPath,
|
||||
'--disable-observatory',
|
||||
'--non-interactive',
|
||||
'--packages=$globalPackagesPath',
|
||||
'--packages=${globals.fs.path.join('.dart_tool', 'package_config.json')}',
|
||||
output,
|
||||
];
|
||||
|
||||
|
@ -9,7 +9,6 @@ import '../base/common.dart';
|
||||
import '../base/file_system.dart';
|
||||
import '../base/io.dart';
|
||||
import '../build_info.dart';
|
||||
import '../dart/package_map.dart';
|
||||
import '../globals.dart' as globals;
|
||||
import '../project.dart';
|
||||
import '../web/compile.dart';
|
||||
@ -178,11 +177,6 @@ class _FlutterTestRunnerImpl implements FlutterTestRunner {
|
||||
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.
|
||||
final Directory saved = globals.fs.currentDirectory;
|
||||
try {
|
||||
|
@ -107,7 +107,7 @@ class TestCompiler {
|
||||
initializeFromDill: testFilePath,
|
||||
unsafePackageSerialization: false,
|
||||
dartDefines: buildInfo.dartDefines,
|
||||
packagesPath: globalPackagesPath,
|
||||
packagesPath: buildInfo.packagesPath,
|
||||
extraFrontEndOptions: buildInfo.extraFrontEndOptions,
|
||||
platform: globals.platform,
|
||||
testCompilation: true,
|
||||
@ -129,7 +129,7 @@ class TestCompiler {
|
||||
}
|
||||
if (_packageConfig == null) {
|
||||
_packageConfig ??= await loadPackageConfigWithLogging(
|
||||
globals.fs.file(globalPackagesPath),
|
||||
globals.fs.file(buildInfo.packagesPath),
|
||||
logger: globals.logger,
|
||||
);
|
||||
// Compilation will fail if there is no flutter_test dependency, since
|
||||
|
@ -6,6 +6,7 @@ import 'package:args/command_runner.dart';
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
import 'package:flutter_tools/src/cache.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/reporting/reporting.dart';
|
||||
import 'package:flutter_tools/src/globals.dart' as globals;
|
||||
@ -39,14 +40,24 @@ void main() {
|
||||
}
|
||||
// Set up enough of the packages to satisfy the templating code.
|
||||
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(
|
||||
globals.fs.path.join('flutter', 'packages', 'flutter_tools', 'templates', 'template_manifest.json'))
|
||||
..createSync(recursive: true);
|
||||
final Directory templateImagesDirectory = globals.fs.directory('flutter_template_images');
|
||||
templateImagesDirectory.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":[]}');
|
||||
}, overrides: <Type, Generator>{
|
||||
DoctorValidatorsProvider: () => FakeDoctorValidatorsProvider(),
|
||||
|
@ -38,9 +38,7 @@ void main() {
|
||||
manifestPath: anyNamed('manifestPath'),
|
||||
applicationKernelFilePath: anyNamed('applicationKernelFilePath'),
|
||||
depfilePath: anyNamed('depfilePath'),
|
||||
privateKeyPath: anyNamed('privateKeyPath'),
|
||||
assetDirPath: anyNamed('assetDirPath'),
|
||||
packagesPath: anyNamed('packagesPath'),
|
||||
precompiledSnapshot: anyNamed('precompiledSnapshot'),
|
||||
reportLicensedPackages: anyNamed('reportLicensedPackages'),
|
||||
trackWidgetCreation: anyNamed('trackWidgetCreation'),
|
||||
|
@ -2701,7 +2701,7 @@ plugin1=${plugin1.path}
|
||||
legacySettingsDotGradleFiles.readAsStringSync().split(';EOF').map<String>((String body) => body.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].
|
||||
|
@ -23,7 +23,10 @@ void main() {
|
||||
|
||||
setUp(() {
|
||||
fileSystem = MemoryFileSystem.test();
|
||||
fileSystem.file('.packages').writeAsStringSync('\n');
|
||||
fileSystem
|
||||
.file('.dart_tool/package_config.json')
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync('{"configVersion":2,"packages":[]}');
|
||||
});
|
||||
|
||||
group('FlutterPlatform', () {
|
||||
@ -82,7 +85,7 @@ void main() {
|
||||
'--enable-dart-profiling',
|
||||
'--non-interactive',
|
||||
'--use-test-fonts',
|
||||
'--packages=.packages',
|
||||
'--packages=.dart_tool/package_config.json',
|
||||
'example.dill'
|
||||
],
|
||||
stdout: 'success',
|
||||
@ -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.
|
||||
class TestFlutterPlatform extends FlutterPlatform {
|
||||
TestFlutterPlatform() : super(
|
||||
buildInfo: BuildInfo.debug,
|
||||
buildInfo: const BuildInfo(BuildMode.debug, '', treeShakeIcons: false, packagesPath: '.dart_tool/package_config.json'),
|
||||
shellPath: '/',
|
||||
precompiledDillPath: 'example.dill',
|
||||
host: InternetAddress.loopbackIPv6,
|
||||
@ -259,7 +262,7 @@ class TestFlutterPlatform extends FlutterPlatform {
|
||||
// Uses a mock HttpServer. We don't want to bind random ports in our CI hosts.
|
||||
class TestObservatoryFlutterPlatform extends FlutterPlatform {
|
||||
TestObservatoryFlutterPlatform() : super(
|
||||
buildInfo: BuildInfo.debug,
|
||||
buildInfo: const BuildInfo(BuildMode.debug, '', treeShakeIcons: false, packagesPath: '.dart_tool/package_config.json'),
|
||||
shellPath: '/',
|
||||
precompiledDillPath: 'example.dill',
|
||||
host: InternetAddress.loopbackIPv6,
|
||||
|
@ -699,7 +699,10 @@ apply plugin: 'kotlin-android'
|
||||
|
||||
Future<FlutterProject> someProject() async {
|
||||
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);
|
||||
final Directory androidDirectory = directory
|
||||
.childDirectory('android')
|
||||
@ -750,7 +753,11 @@ flutter:
|
||||
|
||||
Future<FlutterProject> aModuleProject() async {
|
||||
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('''
|
||||
name: my_module
|
||||
flutter:
|
||||
@ -768,7 +775,11 @@ void _testInMemory(String description, Future<void> testMethod()) {
|
||||
final FileSystem testFileSystem = MemoryFileSystem(
|
||||
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
|
||||
// to the in-memory file system used during testing.
|
||||
transfer(Cache(
|
||||
@ -789,11 +800,22 @@ void _testInMemory(String description, Future<void> testMethod()) {
|
||||
final File packagesFile = testFileSystem.directory(Cache.flutterRoot)
|
||||
.childDirectory('packages')
|
||||
.childDirectory('flutter_tools')
|
||||
.childFile('.packages');
|
||||
.childDirectory('.dart_tool')
|
||||
.childFile('package_config.json');
|
||||
final Directory dummyTemplateImagesDirectory = testFileSystem.directory(Cache.flutterRoot).parent;
|
||||
dummyTemplateImagesDirectory.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(
|
||||
fileSystem: testFileSystem,
|
||||
|
@ -194,7 +194,7 @@ void main() {
|
||||
compileExpression: anyNamed('compileExpression'),
|
||||
getSkSLMethod: anyNamed('getSkSLMethod'),
|
||||
)).thenAnswer((Invocation invocation) async { });
|
||||
when(mockFlutterDevice.setupDevFS(any, any, packagesFilePath: anyNamed('packagesFilePath')))
|
||||
when(mockFlutterDevice.setupDevFS(any, any))
|
||||
.thenAnswer((Invocation invocation) async {
|
||||
return testUri;
|
||||
});
|
||||
|
@ -43,7 +43,7 @@ void main() {
|
||||
);
|
||||
|
||||
expect(
|
||||
await localEngineLocator.findEnginePath(null, 'ios_debug'),
|
||||
await localEngineLocator.findEnginePath(null, 'ios_debug', null),
|
||||
matchesEngineBuildPaths(
|
||||
hostEngine: '/arbitrary/engine/src/out/host_debug',
|
||||
targetEngine: '/arbitrary/engine/src/out/ios_debug',
|
||||
@ -57,7 +57,7 @@ void main() {
|
||||
.writeAsStringSync('sky_engine:file:///symlink/src/out/ios_debug/gen/dart-pkg/sky_engine/lib/');
|
||||
|
||||
expect(
|
||||
await localEngineLocator.findEnginePath(null, 'ios_debug'),
|
||||
await localEngineLocator.findEnginePath(null, 'ios_debug', null),
|
||||
matchesEngineBuildPaths(
|
||||
hostEngine: '/symlink/src/out/host_debug',
|
||||
targetEngine: '/symlink/src/out/ios_debug',
|
||||
@ -81,7 +81,7 @@ void main() {
|
||||
);
|
||||
|
||||
expect(
|
||||
await localEngineLocator.findEnginePath('$kArbitraryEngineRoot/src', 'ios_debug'),
|
||||
await localEngineLocator.findEnginePath('$kArbitraryEngineRoot/src', 'ios_debug', null),
|
||||
matchesEngineBuildPaths(
|
||||
hostEngine: '/arbitrary/engine/src/out/host_debug',
|
||||
targetEngine: '/arbitrary/engine/src/out/ios_debug',
|
||||
@ -112,7 +112,7 @@ void main() {
|
||||
);
|
||||
|
||||
expect(
|
||||
await localEngineLocator.findEnginePath(null, 'ios_debug'),
|
||||
await localEngineLocator.findEnginePath(null, 'ios_debug', null),
|
||||
matchesEngineBuildPaths(
|
||||
hostEngine: 'flutter/engine/src/out/host_debug',
|
||||
targetEngine: 'flutter/engine/src/out/ios_debug',
|
||||
|
Loading…
x
Reference in New Issue
Block a user