From d775908c7e95a5f00afa21fb92ce03ef65bc6563 Mon Sep 17 00:00:00 2001 From: Alexander Aprelev Date: Mon, 15 Apr 2019 21:02:20 -0700 Subject: [PATCH] Download and handle product version of flutter patched sdk (#31063) * Support release/debug flavors of flutter_patched_sdk * Use [anyNamed] instead of [any] for mocking named arguments * Fix use of local engine in release mode --- packages/flutter_tools/lib/src/artifacts.dart | 36 +++++++++++-------- .../flutter_tools/lib/src/base/build.dart | 8 ++--- packages/flutter_tools/lib/src/bundle.dart | 8 ++--- packages/flutter_tools/lib/src/cache.dart | 1 + .../lib/src/commands/attach.dart | 1 + .../lib/src/commands/daemon.dart | 1 + .../flutter_tools/lib/src/commands/run.dart | 1 + .../flutter_tools/lib/src/ios/xcodeproj.dart | 3 +- .../lib/src/resident_runner.dart | 7 ++-- .../test/android/gradle_test.dart | 3 +- .../flutter_tools/test/artifacts_test.dart | 4 +-- .../flutter_tools/test/base/build_test.dart | 9 +++-- packages/flutter_tools/test/hot_test.dart | 19 +++++----- .../test/ios/xcodeproj_test.dart | 15 +++++--- .../test/resident_runner_test.dart | 3 +- 15 files changed, 72 insertions(+), 47 deletions(-) diff --git a/packages/flutter_tools/lib/src/artifacts.dart b/packages/flutter_tools/lib/src/artifacts.dart index 2c614d6331..7ff4f34a44 100644 --- a/packages/flutter_tools/lib/src/artifacts.dart +++ b/packages/flutter_tools/lib/src/artifacts.dart @@ -105,7 +105,7 @@ abstract class Artifacts { } // Returns the requested [artifact] for the [platform] and [mode] combination. - String getArtifactPath(Artifact artifact, [ TargetPlatform platform, BuildMode mode ]); + String getArtifactPath(Artifact artifact, { TargetPlatform platform, BuildMode mode }); // Returns which set of engine artifacts is currently used for the [platform] // and [mode] combination. @@ -116,7 +116,7 @@ abstract class Artifacts { class CachedArtifacts extends Artifacts { @override - String getArtifactPath(Artifact artifact, [ TargetPlatform platform, BuildMode mode ]) { + String getArtifactPath(Artifact artifact, { TargetPlatform platform, BuildMode mode }) { platform ??= _currentHostPlatform; switch (platform) { case TargetPlatform.android_arm: @@ -173,9 +173,10 @@ class CachedArtifacts extends Artifacts { } } - String _getFlutterPatchedSdkPath() { + String _getFlutterPatchedSdkPath(BuildMode mode) { final String engineArtifactsPath = cache.getArtifactDirectory('engine').path; - return fs.path.join(engineArtifactsPath, 'common', 'flutter_patched_sdk'); + return fs.path.join(engineArtifactsPath, 'common', + mode == BuildMode.release ? 'flutter_patched_sdk_product' : 'flutter_patched_sdk'); } String _getFlutterWebSdkPath() { @@ -200,11 +201,11 @@ class CachedArtifacts extends Artifacts { case Artifact.engineDartBinary: return fs.path.join(dartSdkPath, 'bin', _artifactToFileName(artifact)); case Artifact.platformKernelDill: - return fs.path.join(_getFlutterPatchedSdkPath(), _artifactToFileName(artifact)); + return fs.path.join(_getFlutterPatchedSdkPath(mode), _artifactToFileName(artifact)); case Artifact.platformLibrariesJson: - return fs.path.join(_getFlutterPatchedSdkPath(), 'lib', _artifactToFileName(artifact)); + return fs.path.join(_getFlutterPatchedSdkPath(mode), 'lib', _artifactToFileName(artifact)); case Artifact.flutterPatchedSdkPath: - return _getFlutterPatchedSdkPath(); + return _getFlutterPatchedSdkPath(mode); case Artifact.flutterWebSdk: return _getFlutterWebSdkPath(); case Artifact.dart2jsSnapshot: @@ -262,7 +263,7 @@ class LocalEngineArtifacts extends Artifacts { String _hostEngineOutPath; @override - String getArtifactPath(Artifact artifact, [ TargetPlatform platform, BuildMode mode ]) { + String getArtifactPath(Artifact artifact, { TargetPlatform platform, BuildMode mode }) { switch (artifact) { case Artifact.snapshotDart: return fs.path.join(_engineSrcPath, 'flutter', 'lib', 'snapshot', _artifactToFileName(artifact)); @@ -274,13 +275,17 @@ class LocalEngineArtifacts extends Artifacts { case Artifact.vmSnapshotData: return fs.path.join(engineOutPath, 'gen', 'flutter', 'lib', 'snapshot', _artifactToFileName(artifact)); case Artifact.platformKernelDill: - return fs.path.join(_getFlutterPatchedSdkPath(), _artifactToFileName(artifact)); + return fs.path.join(_getFlutterPatchedSdkPath(mode), _artifactToFileName(artifact)); case Artifact.platformLibrariesJson: - return fs.path.join(_getFlutterPatchedSdkPath(), 'lib', _artifactToFileName(artifact)); + return fs.path.join(_getFlutterPatchedSdkPath(mode), 'lib', _artifactToFileName(artifact)); case Artifact.flutterFramework: return fs.path.join(engineOutPath, _artifactToFileName(artifact)); case Artifact.flutterPatchedSdkPath: - return _getFlutterPatchedSdkPath(); + // When using local engine always use [BuildMode.debug] regardless of + // what was specified in [mode] argument because local engine will + // have only one flutter_patched_sdk in standard location, that + // is happen to be what debug(non-release) mode is using. + return _getFlutterPatchedSdkPath(BuildMode.debug); case Artifact.flutterWebSdk: return _getFlutterWebSdkPath(); case Artifact.frontendServerSnapshotForEngineDartSdk: @@ -303,8 +308,9 @@ class LocalEngineArtifacts extends Artifacts { return fs.path.basename(engineOutPath); } - String _getFlutterPatchedSdkPath() { - return fs.path.join(engineOutPath, 'flutter_patched_sdk'); + String _getFlutterPatchedSdkPath(BuildMode buildMode) { + return fs.path.join(engineOutPath, + buildMode == BuildMode.release ? 'flutter_patched_sdk_product' : 'flutter_patched_sdk'); } String _getFlutterWebSdkPath() { @@ -356,7 +362,7 @@ class OverrideArtifacts implements Artifacts { final File flutterPatchedSdk; @override - String getArtifactPath(Artifact artifact, [ TargetPlatform platform, BuildMode mode ]) { + String getArtifactPath(Artifact artifact, { TargetPlatform platform, BuildMode mode }) { if (artifact == Artifact.frontendServerSnapshotForEngineDartSdk && frontendServer != null) { return frontendServer.path; } @@ -369,7 +375,7 @@ class OverrideArtifacts implements Artifacts { if (artifact == Artifact.flutterPatchedSdkPath && flutterPatchedSdk != null) { return flutterPatchedSdk.path; } - return parent.getArtifactPath(artifact, platform, mode); + return parent.getArtifactPath(artifact, platform: platform, mode: mode); } @override diff --git a/packages/flutter_tools/lib/src/base/build.dart b/packages/flutter_tools/lib/src/base/build.dart index 90c4259a5a..578c82ee92 100644 --- a/packages/flutter_tools/lib/src/base/build.dart +++ b/packages/flutter_tools/lib/src/base/build.dart @@ -43,7 +43,7 @@ class GenSnapshot { static String getSnapshotterPath(SnapshotType snapshotType) { return artifacts.getArtifactPath( - Artifact.genSnapshot, snapshotType.platform, snapshotType.mode); + Artifact.genSnapshot, platform: snapshotType.platform, mode: snapshotType.mode); } Future run({ @@ -317,7 +317,7 @@ class AOTSnapshotter { final String depfilePath = fs.path.join(outputPath, 'kernel_compile.d'); final KernelCompiler kernelCompiler = await kernelCompilerFactory.create(flutterProject); final CompilerOutput compilerOutput = await _timedStep('frontend', () => kernelCompiler.compile( - sdkRoot: artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath), + sdkRoot: artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath, mode: buildMode), mainPath: mainPath, packagesPath: packagesPath, outputFilePath: getKernelPathForTransformerOptions( @@ -391,8 +391,8 @@ class JITSnapshotter { final Directory outputDir = fs.directory(outputPath); outputDir.createSync(recursive: true); - final String engineVmSnapshotData = artifacts.getArtifactPath(Artifact.vmSnapshotData, null, buildMode); - final String engineIsolateSnapshotData = artifacts.getArtifactPath(Artifact.isolateSnapshotData, null, buildMode); + final String engineVmSnapshotData = artifacts.getArtifactPath(Artifact.vmSnapshotData, mode: buildMode); + final String engineIsolateSnapshotData = artifacts.getArtifactPath(Artifact.isolateSnapshotData, mode: buildMode); final String isolateSnapshotData = fs.path.join(outputDir.path, 'isolate_snapshot_data'); final String isolateSnapshotInstructions = fs.path.join(outputDir.path, 'isolate_snapshot_instr'); diff --git a/packages/flutter_tools/lib/src/bundle.dart b/packages/flutter_tools/lib/src/bundle.dart index 8cff1b20a2..7e2fe447e5 100644 --- a/packages/flutter_tools/lib/src/bundle.dart +++ b/packages/flutter_tools/lib/src/bundle.dart @@ -103,7 +103,7 @@ Future build({ ensureDirectoryExists(applicationKernelFilePath); final KernelCompiler kernelCompiler = await kernelCompilerFactory.create(flutterProject); final CompilerOutput compilerOutput = await kernelCompiler.compile( - sdkRoot: artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath), + sdkRoot: artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath, mode: buildMode), incrementalCompilerByteStorePath: compilationTraceFilePath != null ? null : fs.path.absolute(getIncrementalCompilerByteStoreDirectory()), mainPath: fs.file(mainPath).absolute.path, @@ -202,15 +202,15 @@ Future assemble({ final Map assetEntries = Map.from(assetBundle.entries); if (kernelContent != null) { if (compilationTraceFilePath != null) { - final String vmSnapshotData = artifacts.getArtifactPath(Artifact.vmSnapshotData, null, buildMode); + final String vmSnapshotData = artifacts.getArtifactPath(Artifact.vmSnapshotData, mode: buildMode); final String isolateSnapshotData = fs.path.join(getBuildDirectory(), _kIsolateSnapshotData); final String isolateSnapshotInstr = fs.path.join(getBuildDirectory(), _kIsolateSnapshotInstr); assetEntries[_kVMSnapshotData] = DevFSFileContent(fs.file(vmSnapshotData)); assetEntries[_kIsolateSnapshotData] = DevFSFileContent(fs.file(isolateSnapshotData)); assetEntries[_kIsolateSnapshotInstr] = DevFSFileContent(fs.file(isolateSnapshotInstr)); } else { - final String vmSnapshotData = artifacts.getArtifactPath(Artifact.vmSnapshotData, null, buildMode); - final String isolateSnapshotData = artifacts.getArtifactPath(Artifact.isolateSnapshotData, null, buildMode); + final String vmSnapshotData = artifacts.getArtifactPath(Artifact.vmSnapshotData, mode: buildMode); + final String isolateSnapshotData = artifacts.getArtifactPath(Artifact.isolateSnapshotData, mode: buildMode); assetEntries[_kKernelKey] = kernelContent; assetEntries[_kVMSnapshotData] = DevFSFileContent(fs.file(vmSnapshotData)); assetEntries[_kIsolateSnapshotData] = DevFSFileContent(fs.file(isolateSnapshotData)); diff --git a/packages/flutter_tools/lib/src/cache.dart b/packages/flutter_tools/lib/src/cache.dart index bfdb74c5b4..dcfe070c45 100644 --- a/packages/flutter_tools/lib/src/cache.dart +++ b/packages/flutter_tools/lib/src/cache.dart @@ -609,6 +609,7 @@ class FlutterSdk extends EngineCachedArtifact { List> getBinaryDirs() { final List> binaryDirs = >[ ['common', 'flutter_patched_sdk.zip'], + ['common', 'flutter_patched_sdk_product.zip'], ]; if (cache.includeAllPlatforms) { binaryDirs.addAll(>[ diff --git a/packages/flutter_tools/lib/src/commands/attach.dart b/packages/flutter_tools/lib/src/commands/attach.dart index 0031a4c599..43f15a1491 100644 --- a/packages/flutter_tools/lib/src/commands/attach.dart +++ b/packages/flutter_tools/lib/src/commands/attach.dart @@ -216,6 +216,7 @@ class AttachCommand extends FlutterCommand { viewFilter: argResults['isolate-filter'], target: argResults['target'], targetModel: TargetModel(argResults['target-model']), + buildMode: getBuildMode(), ); flutterDevice.observatoryUris = [ observatoryUri ]; final List flutterDevices = [flutterDevice]; diff --git a/packages/flutter_tools/lib/src/commands/daemon.dart b/packages/flutter_tools/lib/src/commands/daemon.dart index a4e1524ad3..08e52075a1 100644 --- a/packages/flutter_tools/lib/src/commands/daemon.dart +++ b/packages/flutter_tools/lib/src/commands/daemon.dart @@ -351,6 +351,7 @@ class AppDomain extends Domain { dillOutputPath: dillOutputPath, viewFilter: isolateFilter, target: target, + buildMode: options.buildInfo.mode, ); ResidentRunner runner; diff --git a/packages/flutter_tools/lib/src/commands/run.dart b/packages/flutter_tools/lib/src/commands/run.dart index e013079d89..926154c0f2 100644 --- a/packages/flutter_tools/lib/src/commands/run.dart +++ b/packages/flutter_tools/lib/src/commands/run.dart @@ -369,6 +369,7 @@ class RunCommand extends RunCommandBase { viewFilter: argResults['isolate-filter'], experimentalFlags: expFlags, target: argResults['target'], + buildMode: getBuildMode(), ); flutterDevices.add(flutterDevice); } diff --git a/packages/flutter_tools/lib/src/ios/xcodeproj.dart b/packages/flutter_tools/lib/src/ios/xcodeproj.dart index 3261776add..c929186bf3 100644 --- a/packages/flutter_tools/lib/src/ios/xcodeproj.dart +++ b/packages/flutter_tools/lib/src/ios/xcodeproj.dart @@ -23,7 +23,8 @@ final RegExp _settingExpr = RegExp(r'(\w+)\s*=\s*(.*)$'); final RegExp _varExpr = RegExp(r'\$\(([^)]*)\)'); String flutterFrameworkDir(BuildMode mode) { - return fs.path.normalize(fs.path.dirname(artifacts.getArtifactPath(Artifact.flutterFramework, TargetPlatform.ios, mode))); + return fs.path.normalize(fs.path.dirname(artifacts.getArtifactPath( + Artifact.flutterFramework, platform: TargetPlatform.ios, mode: mode))); } /// Writes or rewrites Xcode property files with the specified information. diff --git a/packages/flutter_tools/lib/src/resident_runner.dart b/packages/flutter_tools/lib/src/resident_runner.dart index 2fd1b1952b..47b7964efe 100644 --- a/packages/flutter_tools/lib/src/resident_runner.dart +++ b/packages/flutter_tools/lib/src/resident_runner.dart @@ -38,9 +38,10 @@ class FlutterDevice { TargetModel targetModel = TargetModel.flutter, List experimentalFlags, ResidentCompiler generator, + @required BuildMode buildMode, }) : assert(trackWidgetCreation != null), generator = generator ?? ResidentCompiler( - artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath), + artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath, mode: buildMode), trackWidgetCreation: trackWidgetCreation, fileSystemRoots: fileSystemRoots, fileSystemScheme: fileSystemScheme, @@ -60,6 +61,7 @@ class FlutterDevice { TargetModel targetModel = TargetModel.flutter, List experimentalFlags, ResidentCompiler generator, + @required BuildMode buildMode, }) async { ResidentCompiler generator; final FlutterProject flutterProject = await FlutterProject.current(); @@ -69,7 +71,7 @@ class FlutterDevice { ); } else { generator = ResidentCompiler( - artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath), + artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath, mode: buildMode), trackWidgetCreation: trackWidgetCreation, fileSystemRoots: fileSystemRoots, fileSystemScheme: fileSystemScheme, @@ -87,6 +89,7 @@ class FlutterDevice { experimentalFlags: experimentalFlags, targetModel: targetModel, generator: generator, + buildMode: buildMode, ); } diff --git a/packages/flutter_tools/test/android/gradle_test.dart b/packages/flutter_tools/test/android/gradle_test.dart index c25d2adc24..d9cbefe2cf 100644 --- a/packages/flutter_tools/test/android/gradle_test.dart +++ b/packages/flutter_tools/test/android/gradle_test.dart @@ -252,7 +252,8 @@ someOtherTask String expectedBuildName, String expectedBuildNumber, }) async { - when(mockArtifacts.getArtifactPath(Artifact.flutterFramework, TargetPlatform.android_arm, any)).thenReturn('engine'); + when(mockArtifacts.getArtifactPath(Artifact.flutterFramework, + platform: TargetPlatform.android_arm, mode: anyNamed('mode'))).thenReturn('engine'); when(mockArtifacts.engineOutPath).thenReturn(fs.path.join('out', 'android_arm')); final File manifestFile = fs.file('path/to/project/pubspec.yaml'); diff --git a/packages/flutter_tools/test/artifacts_test.dart b/packages/flutter_tools/test/artifacts_test.dart index 00b17e45b4..fcc6c8f1d8 100644 --- a/packages/flutter_tools/test/artifacts_test.dart +++ b/packages/flutter_tools/test/artifacts_test.dart @@ -28,7 +28,7 @@ void main() { testUsingContext('getArtifactPath', () { expect( - artifacts.getArtifactPath(Artifact.flutterFramework, TargetPlatform.ios, BuildMode.release), + artifacts.getArtifactPath(Artifact.flutterFramework, platform: TargetPlatform.ios, mode: BuildMode.release), fs.path.join(tempDir.path, 'bin', 'cache', 'artifacts', 'engine', 'ios-release', 'Flutter.framework'), ); expect( @@ -78,7 +78,7 @@ void main() { testUsingContext('getArtifactPath', () { expect( - artifacts.getArtifactPath(Artifact.flutterFramework, TargetPlatform.ios, BuildMode.release), + artifacts.getArtifactPath(Artifact.flutterFramework, platform: TargetPlatform.ios, mode: BuildMode.release), fs.path.join(tempDir.path, 'out', 'android_debug_unopt', 'Flutter.framework'), ); expect( diff --git a/packages/flutter_tools/test/base/build_test.dart b/packages/flutter_tools/test/base/build_test.dart index 41ed0d93e9..facb0fd3b3 100644 --- a/packages/flutter_tools/test/base/build_test.dart +++ b/packages/flutter_tools/test/base/build_test.dart @@ -114,7 +114,8 @@ void main() { mockXcode = MockXcode(); bufferLogger = BufferLogger(); for (BuildMode mode in BuildMode.values) { - when(mockArtifacts.getArtifactPath(Artifact.snapshotDart, any, mode)).thenReturn(kSnapshotDart); + when(mockArtifacts.getArtifactPath(Artifact.snapshotDart, + platform: anyNamed('platform'), mode: mode)).thenReturn(kSnapshotDart); } }); @@ -552,9 +553,11 @@ void main() { mockArtifacts = MockArtifacts(); for (BuildMode mode in BuildMode.values) { - when(mockArtifacts.getArtifactPath(Artifact.vmSnapshotData, null, mode)) + when(mockArtifacts.getArtifactPath(Artifact.vmSnapshotData, + platform: anyNamed('platform'), mode: mode)) .thenReturn(kEngineVmSnapshotData); - when(mockArtifacts.getArtifactPath(Artifact.isolateSnapshotData, null, mode)) + when(mockArtifacts.getArtifactPath(Artifact.isolateSnapshotData, + platform: anyNamed('platform'), mode: mode)) .thenReturn(kEngineIsolateSnapshotData); } }); diff --git a/packages/flutter_tools/test/hot_test.dart b/packages/flutter_tools/test/hot_test.dart index 37ac83fdee..4868321fbc 100644 --- a/packages/flutter_tools/test/hot_test.dart +++ b/packages/flutter_tools/test/hot_test.dart @@ -5,6 +5,7 @@ import 'dart:async'; import 'package:flutter_tools/src/artifacts.dart'; +import 'package:flutter_tools/src/build_info.dart'; import 'package:flutter_tools/src/devfs.dart'; import 'package:flutter_tools/src/device.dart'; import 'package:flutter_tools/src/resident_runner.dart'; @@ -130,7 +131,7 @@ void main() { when(mockDevice.supportsHotRestart).thenReturn(false); // Trigger hot restart. final List devices = [ - FlutterDevice(mockDevice, generator: residentCompiler, trackWidgetCreation: false)..devFS = mockDevFs, + FlutterDevice(mockDevice, generator: residentCompiler, trackWidgetCreation: false, buildMode: BuildMode.debug)..devFS = mockDevFs, ]; final OperationResult result = await HotRunner(devices).restart(fullRestart: true); // Expect hot restart failed. @@ -151,8 +152,8 @@ void main() { when(mockHotDevice.supportsHotRestart).thenReturn(true); // Trigger hot restart. final List devices = [ - FlutterDevice(mockDevice, generator: residentCompiler, trackWidgetCreation: false)..devFS = mockDevFs, - FlutterDevice(mockHotDevice, generator: residentCompiler, trackWidgetCreation: false)..devFS = mockDevFs, + FlutterDevice(mockDevice, generator: residentCompiler, trackWidgetCreation: false, buildMode: BuildMode.debug)..devFS = mockDevFs, + FlutterDevice(mockHotDevice, generator: residentCompiler, trackWidgetCreation: false, buildMode: BuildMode.debug)..devFS = mockDevFs, ]; final OperationResult result = await HotRunner(devices).restart(fullRestart: true); // Expect hot restart failed. @@ -173,8 +174,8 @@ void main() { when(mockHotDevice.supportsHotRestart).thenReturn(true); // Trigger a restart. final List devices = [ - FlutterDevice(mockDevice, generator: residentCompiler, trackWidgetCreation: false)..devFS = mockDevFs, - FlutterDevice(mockHotDevice, generator: residentCompiler, trackWidgetCreation: false)..devFS = mockDevFs, + FlutterDevice(mockDevice, generator: residentCompiler, trackWidgetCreation: false, buildMode: BuildMode.debug)..devFS = mockDevFs, + FlutterDevice(mockHotDevice, generator: residentCompiler, trackWidgetCreation: false, buildMode: BuildMode.debug)..devFS = mockDevFs, ]; final OperationResult result = await HotRunner(devices).restart(fullRestart: true); // Expect hot restart was successful. @@ -190,7 +191,7 @@ void main() { when(mockDevice.supportsHotReload).thenReturn(true); when(mockDevice.supportsHotRestart).thenReturn(true); final List devices = [ - FlutterDevice(mockDevice, generator: residentCompiler, trackWidgetCreation: false), + FlutterDevice(mockDevice, generator: residentCompiler, trackWidgetCreation: false, buildMode: BuildMode.debug), ]; final OperationResult result = await HotRunner(devices).restart(fullRestart: true); expect(result.isOk, false); @@ -207,7 +208,7 @@ void main() { when(mockDevice.supportsHotRestart).thenReturn(true); // Trigger hot restart. final List devices = [ - FlutterDevice(mockDevice, generator: residentCompiler, trackWidgetCreation: false)..devFS = mockDevFs, + FlutterDevice(mockDevice, generator: residentCompiler, trackWidgetCreation: false, buildMode: BuildMode.debug)..devFS = mockDevFs, ]; final OperationResult result = await HotRunner(devices).restart(fullRestart: true); // Expect hot restart successful. @@ -233,7 +234,7 @@ void main() { when(mockDevice.supportsHotRestart).thenReturn(true); when(mockDevice.supportsStopApp).thenReturn(false); final List devices = [ - FlutterDevice(mockDevice, generator: residentCompiler, trackWidgetCreation: false), + FlutterDevice(mockDevice, generator: residentCompiler, trackWidgetCreation: false, buildMode: BuildMode.debug), ]; await HotRunner(devices).cleanupAfterSignal(); expect(shutdownTestingConfig.shutdownHookCalled, true); @@ -248,7 +249,7 @@ void main() { when(mockDevice.supportsHotRestart).thenReturn(true); when(mockDevice.supportsStopApp).thenReturn(false); final List devices = [ - FlutterDevice(mockDevice, generator: residentCompiler, trackWidgetCreation: false), + FlutterDevice(mockDevice, generator: residentCompiler, trackWidgetCreation: false, buildMode: BuildMode.debug), ]; await HotRunner(devices).preStop(); expect(shutdownTestingConfig.shutdownHookCalled, true); diff --git a/packages/flutter_tools/test/ios/xcodeproj_test.dart b/packages/flutter_tools/test/ios/xcodeproj_test.dart index ed4fa5e07e..86e33f473c 100644 --- a/packages/flutter_tools/test/ios/xcodeproj_test.dart +++ b/packages/flutter_tools/test/ios/xcodeproj_test.dart @@ -282,7 +282,8 @@ Information about project "Runner": } testUsingOsxContext('sets ARCHS=armv7 when armv7 local engine is set', () async { - when(mockArtifacts.getArtifactPath(Artifact.flutterFramework, TargetPlatform.ios, any)).thenReturn('engine'); + when(mockArtifacts.getArtifactPath(Artifact.flutterFramework, + platform: TargetPlatform.ios, mode: anyNamed('mode'))).thenReturn('engine'); when(mockArtifacts.engineOutPath).thenReturn(fs.path.join('out', 'ios_profile_arm')); const BuildInfo buildInfo = BuildInfo(BuildMode.debug, null, targetPlatform: TargetPlatform.ios); @@ -300,7 +301,8 @@ Information about project "Runner": }); testUsingOsxContext('sets TRACK_WIDGET_CREATION=true when trackWidgetCreation is true', () async { - when(mockArtifacts.getArtifactPath(Artifact.flutterFramework, TargetPlatform.ios, any)).thenReturn('engine'); + when(mockArtifacts.getArtifactPath(Artifact.flutterFramework, + platform: TargetPlatform.ios, mode: anyNamed('mode'))).thenReturn('engine'); when(mockArtifacts.engineOutPath).thenReturn(fs.path.join('out', 'ios_profile_arm')); const BuildInfo buildInfo = BuildInfo(BuildMode.debug, null, trackWidgetCreation: true, targetPlatform: TargetPlatform.ios); final FlutterProject project = await FlutterProject.fromPath('path/to/project'); @@ -317,7 +319,8 @@ Information about project "Runner": }); testUsingOsxContext('does not set TRACK_WIDGET_CREATION when trackWidgetCreation is false', () async { - when(mockArtifacts.getArtifactPath(Artifact.flutterFramework, TargetPlatform.ios, any)).thenReturn('engine'); + when(mockArtifacts.getArtifactPath(Artifact.flutterFramework, + platform: TargetPlatform.ios, mode: anyNamed('mode'))).thenReturn('engine'); when(mockArtifacts.engineOutPath).thenReturn(fs.path.join('out', 'ios_profile_arm')); const BuildInfo buildInfo = BuildInfo(BuildMode.debug, null, targetPlatform: TargetPlatform.ios); final FlutterProject project = await FlutterProject.fromPath('path/to/project'); @@ -334,7 +337,8 @@ Information about project "Runner": }); testUsingOsxContext('sets ARCHS=armv7 when armv7 local engine is set', () async { - when(mockArtifacts.getArtifactPath(Artifact.flutterFramework, TargetPlatform.ios, any)).thenReturn('engine'); + when(mockArtifacts.getArtifactPath(Artifact.flutterFramework, + platform: TargetPlatform.ios, mode: anyNamed('mode'))).thenReturn('engine'); when(mockArtifacts.engineOutPath).thenReturn(fs.path.join('out', 'ios_profile')); const BuildInfo buildInfo = BuildInfo(BuildMode.debug, null, targetPlatform: TargetPlatform.ios); @@ -366,7 +370,8 @@ Information about project "Runner": String expectedBuildName, String expectedBuildNumber, }) async { - when(mockArtifacts.getArtifactPath(Artifact.flutterFramework, TargetPlatform.ios, any)).thenReturn('engine'); + when(mockArtifacts.getArtifactPath(Artifact.flutterFramework, + platform: TargetPlatform.ios, mode: anyNamed('mode'))).thenReturn('engine'); when(mockArtifacts.engineOutPath).thenReturn(fs.path.join('out', 'ios')); final File manifestFile = fs.file('path/to/project/pubspec.yaml'); diff --git a/packages/flutter_tools/test/resident_runner_test.dart b/packages/flutter_tools/test/resident_runner_test.dart index 2a20530991..a4c96b39d7 100644 --- a/packages/flutter_tools/test/resident_runner_test.dart +++ b/packages/flutter_tools/test/resident_runner_test.dart @@ -3,6 +3,7 @@ // found in the LICENSE file. import 'dart:async'; +import 'package:flutter_tools/src/build_info.dart'; import 'package:flutter_tools/src/device.dart'; import 'package:flutter_tools/src/resident_runner.dart'; import 'package:mockito/mockito.dart'; @@ -53,7 +54,7 @@ void main() { // TODO(jacobr): make these tests run with `trackWidgetCreation: true` as // well as the default flags. return TestRunner( - [FlutterDevice(MockDevice(), trackWidgetCreation: false)], + [FlutterDevice(MockDevice(), trackWidgetCreation: false, buildMode: BuildMode.debug)], ); }