Unverified Commit d775908c authored by Alexander Aprelev's avatar Alexander Aprelev Committed by GitHub

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
parent 4ef02927
...@@ -105,7 +105,7 @@ abstract class Artifacts { ...@@ -105,7 +105,7 @@ abstract class Artifacts {
} }
// Returns the requested [artifact] for the [platform] and [mode] combination. // 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] // Returns which set of engine artifacts is currently used for the [platform]
// and [mode] combination. // and [mode] combination.
...@@ -116,7 +116,7 @@ abstract class Artifacts { ...@@ -116,7 +116,7 @@ abstract class Artifacts {
class CachedArtifacts extends Artifacts { class CachedArtifacts extends Artifacts {
@override @override
String getArtifactPath(Artifact artifact, [ TargetPlatform platform, BuildMode mode ]) { String getArtifactPath(Artifact artifact, { TargetPlatform platform, BuildMode mode }) {
platform ??= _currentHostPlatform; platform ??= _currentHostPlatform;
switch (platform) { switch (platform) {
case TargetPlatform.android_arm: case TargetPlatform.android_arm:
...@@ -173,9 +173,10 @@ class CachedArtifacts extends Artifacts { ...@@ -173,9 +173,10 @@ class CachedArtifacts extends Artifacts {
} }
} }
String _getFlutterPatchedSdkPath() { String _getFlutterPatchedSdkPath(BuildMode mode) {
final String engineArtifactsPath = cache.getArtifactDirectory('engine').path; 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() { String _getFlutterWebSdkPath() {
...@@ -200,11 +201,11 @@ class CachedArtifacts extends Artifacts { ...@@ -200,11 +201,11 @@ class CachedArtifacts extends Artifacts {
case Artifact.engineDartBinary: case Artifact.engineDartBinary:
return fs.path.join(dartSdkPath, 'bin', _artifactToFileName(artifact)); return fs.path.join(dartSdkPath, 'bin', _artifactToFileName(artifact));
case Artifact.platformKernelDill: case Artifact.platformKernelDill:
return fs.path.join(_getFlutterPatchedSdkPath(), _artifactToFileName(artifact)); return fs.path.join(_getFlutterPatchedSdkPath(mode), _artifactToFileName(artifact));
case Artifact.platformLibrariesJson: case Artifact.platformLibrariesJson:
return fs.path.join(_getFlutterPatchedSdkPath(), 'lib', _artifactToFileName(artifact)); return fs.path.join(_getFlutterPatchedSdkPath(mode), 'lib', _artifactToFileName(artifact));
case Artifact.flutterPatchedSdkPath: case Artifact.flutterPatchedSdkPath:
return _getFlutterPatchedSdkPath(); return _getFlutterPatchedSdkPath(mode);
case Artifact.flutterWebSdk: case Artifact.flutterWebSdk:
return _getFlutterWebSdkPath(); return _getFlutterWebSdkPath();
case Artifact.dart2jsSnapshot: case Artifact.dart2jsSnapshot:
...@@ -262,7 +263,7 @@ class LocalEngineArtifacts extends Artifacts { ...@@ -262,7 +263,7 @@ class LocalEngineArtifacts extends Artifacts {
String _hostEngineOutPath; String _hostEngineOutPath;
@override @override
String getArtifactPath(Artifact artifact, [ TargetPlatform platform, BuildMode mode ]) { String getArtifactPath(Artifact artifact, { TargetPlatform platform, BuildMode mode }) {
switch (artifact) { switch (artifact) {
case Artifact.snapshotDart: case Artifact.snapshotDart:
return fs.path.join(_engineSrcPath, 'flutter', 'lib', 'snapshot', _artifactToFileName(artifact)); return fs.path.join(_engineSrcPath, 'flutter', 'lib', 'snapshot', _artifactToFileName(artifact));
...@@ -274,13 +275,17 @@ class LocalEngineArtifacts extends Artifacts { ...@@ -274,13 +275,17 @@ class LocalEngineArtifacts extends Artifacts {
case Artifact.vmSnapshotData: case Artifact.vmSnapshotData:
return fs.path.join(engineOutPath, 'gen', 'flutter', 'lib', 'snapshot', _artifactToFileName(artifact)); return fs.path.join(engineOutPath, 'gen', 'flutter', 'lib', 'snapshot', _artifactToFileName(artifact));
case Artifact.platformKernelDill: case Artifact.platformKernelDill:
return fs.path.join(_getFlutterPatchedSdkPath(), _artifactToFileName(artifact)); return fs.path.join(_getFlutterPatchedSdkPath(mode), _artifactToFileName(artifact));
case Artifact.platformLibrariesJson: case Artifact.platformLibrariesJson:
return fs.path.join(_getFlutterPatchedSdkPath(), 'lib', _artifactToFileName(artifact)); return fs.path.join(_getFlutterPatchedSdkPath(mode), 'lib', _artifactToFileName(artifact));
case Artifact.flutterFramework: case Artifact.flutterFramework:
return fs.path.join(engineOutPath, _artifactToFileName(artifact)); return fs.path.join(engineOutPath, _artifactToFileName(artifact));
case Artifact.flutterPatchedSdkPath: 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: case Artifact.flutterWebSdk:
return _getFlutterWebSdkPath(); return _getFlutterWebSdkPath();
case Artifact.frontendServerSnapshotForEngineDartSdk: case Artifact.frontendServerSnapshotForEngineDartSdk:
...@@ -303,8 +308,9 @@ class LocalEngineArtifacts extends Artifacts { ...@@ -303,8 +308,9 @@ class LocalEngineArtifacts extends Artifacts {
return fs.path.basename(engineOutPath); return fs.path.basename(engineOutPath);
} }
String _getFlutterPatchedSdkPath() { String _getFlutterPatchedSdkPath(BuildMode buildMode) {
return fs.path.join(engineOutPath, 'flutter_patched_sdk'); return fs.path.join(engineOutPath,
buildMode == BuildMode.release ? 'flutter_patched_sdk_product' : 'flutter_patched_sdk');
} }
String _getFlutterWebSdkPath() { String _getFlutterWebSdkPath() {
...@@ -356,7 +362,7 @@ class OverrideArtifacts implements Artifacts { ...@@ -356,7 +362,7 @@ class OverrideArtifacts implements Artifacts {
final File flutterPatchedSdk; final File flutterPatchedSdk;
@override @override
String getArtifactPath(Artifact artifact, [ TargetPlatform platform, BuildMode mode ]) { String getArtifactPath(Artifact artifact, { TargetPlatform platform, BuildMode mode }) {
if (artifact == Artifact.frontendServerSnapshotForEngineDartSdk && frontendServer != null) { if (artifact == Artifact.frontendServerSnapshotForEngineDartSdk && frontendServer != null) {
return frontendServer.path; return frontendServer.path;
} }
...@@ -369,7 +375,7 @@ class OverrideArtifacts implements Artifacts { ...@@ -369,7 +375,7 @@ class OverrideArtifacts implements Artifacts {
if (artifact == Artifact.flutterPatchedSdkPath && flutterPatchedSdk != null) { if (artifact == Artifact.flutterPatchedSdkPath && flutterPatchedSdk != null) {
return flutterPatchedSdk.path; return flutterPatchedSdk.path;
} }
return parent.getArtifactPath(artifact, platform, mode); return parent.getArtifactPath(artifact, platform: platform, mode: mode);
} }
@override @override
......
...@@ -43,7 +43,7 @@ class GenSnapshot { ...@@ -43,7 +43,7 @@ class GenSnapshot {
static String getSnapshotterPath(SnapshotType snapshotType) { static String getSnapshotterPath(SnapshotType snapshotType) {
return artifacts.getArtifactPath( return artifacts.getArtifactPath(
Artifact.genSnapshot, snapshotType.platform, snapshotType.mode); Artifact.genSnapshot, platform: snapshotType.platform, mode: snapshotType.mode);
} }
Future<int> run({ Future<int> run({
...@@ -317,7 +317,7 @@ class AOTSnapshotter { ...@@ -317,7 +317,7 @@ class AOTSnapshotter {
final String depfilePath = fs.path.join(outputPath, 'kernel_compile.d'); final String depfilePath = fs.path.join(outputPath, 'kernel_compile.d');
final KernelCompiler kernelCompiler = await kernelCompilerFactory.create(flutterProject); final KernelCompiler kernelCompiler = await kernelCompilerFactory.create(flutterProject);
final CompilerOutput compilerOutput = await _timedStep('frontend', () => kernelCompiler.compile( final CompilerOutput compilerOutput = await _timedStep('frontend', () => kernelCompiler.compile(
sdkRoot: artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath), sdkRoot: artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath, mode: buildMode),
mainPath: mainPath, mainPath: mainPath,
packagesPath: packagesPath, packagesPath: packagesPath,
outputFilePath: getKernelPathForTransformerOptions( outputFilePath: getKernelPathForTransformerOptions(
...@@ -391,8 +391,8 @@ class JITSnapshotter { ...@@ -391,8 +391,8 @@ class JITSnapshotter {
final Directory outputDir = fs.directory(outputPath); final Directory outputDir = fs.directory(outputPath);
outputDir.createSync(recursive: true); outputDir.createSync(recursive: true);
final String engineVmSnapshotData = artifacts.getArtifactPath(Artifact.vmSnapshotData, null, buildMode); final String engineVmSnapshotData = artifacts.getArtifactPath(Artifact.vmSnapshotData, mode: buildMode);
final String engineIsolateSnapshotData = artifacts.getArtifactPath(Artifact.isolateSnapshotData, null, buildMode); final String engineIsolateSnapshotData = artifacts.getArtifactPath(Artifact.isolateSnapshotData, mode: buildMode);
final String isolateSnapshotData = fs.path.join(outputDir.path, 'isolate_snapshot_data'); final String isolateSnapshotData = fs.path.join(outputDir.path, 'isolate_snapshot_data');
final String isolateSnapshotInstructions = fs.path.join(outputDir.path, 'isolate_snapshot_instr'); final String isolateSnapshotInstructions = fs.path.join(outputDir.path, 'isolate_snapshot_instr');
......
...@@ -103,7 +103,7 @@ Future<void> build({ ...@@ -103,7 +103,7 @@ Future<void> build({
ensureDirectoryExists(applicationKernelFilePath); ensureDirectoryExists(applicationKernelFilePath);
final KernelCompiler kernelCompiler = await kernelCompilerFactory.create(flutterProject); final KernelCompiler kernelCompiler = await kernelCompilerFactory.create(flutterProject);
final CompilerOutput compilerOutput = await kernelCompiler.compile( final CompilerOutput compilerOutput = await kernelCompiler.compile(
sdkRoot: artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath), sdkRoot: artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath, mode: buildMode),
incrementalCompilerByteStorePath: compilationTraceFilePath != null ? null : incrementalCompilerByteStorePath: compilationTraceFilePath != null ? null :
fs.path.absolute(getIncrementalCompilerByteStoreDirectory()), fs.path.absolute(getIncrementalCompilerByteStoreDirectory()),
mainPath: fs.file(mainPath).absolute.path, mainPath: fs.file(mainPath).absolute.path,
...@@ -202,15 +202,15 @@ Future<void> assemble({ ...@@ -202,15 +202,15 @@ Future<void> assemble({
final Map<String, DevFSContent> assetEntries = Map<String, DevFSContent>.from(assetBundle.entries); final Map<String, DevFSContent> assetEntries = Map<String, DevFSContent>.from(assetBundle.entries);
if (kernelContent != null) { if (kernelContent != null) {
if (compilationTraceFilePath != 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 isolateSnapshotData = fs.path.join(getBuildDirectory(), _kIsolateSnapshotData);
final String isolateSnapshotInstr = fs.path.join(getBuildDirectory(), _kIsolateSnapshotInstr); final String isolateSnapshotInstr = fs.path.join(getBuildDirectory(), _kIsolateSnapshotInstr);
assetEntries[_kVMSnapshotData] = DevFSFileContent(fs.file(vmSnapshotData)); assetEntries[_kVMSnapshotData] = DevFSFileContent(fs.file(vmSnapshotData));
assetEntries[_kIsolateSnapshotData] = DevFSFileContent(fs.file(isolateSnapshotData)); assetEntries[_kIsolateSnapshotData] = DevFSFileContent(fs.file(isolateSnapshotData));
assetEntries[_kIsolateSnapshotInstr] = DevFSFileContent(fs.file(isolateSnapshotInstr)); assetEntries[_kIsolateSnapshotInstr] = DevFSFileContent(fs.file(isolateSnapshotInstr));
} else { } else {
final String vmSnapshotData = artifacts.getArtifactPath(Artifact.vmSnapshotData, null, buildMode); final String vmSnapshotData = artifacts.getArtifactPath(Artifact.vmSnapshotData, mode: buildMode);
final String isolateSnapshotData = artifacts.getArtifactPath(Artifact.isolateSnapshotData, null, buildMode); final String isolateSnapshotData = artifacts.getArtifactPath(Artifact.isolateSnapshotData, mode: buildMode);
assetEntries[_kKernelKey] = kernelContent; assetEntries[_kKernelKey] = kernelContent;
assetEntries[_kVMSnapshotData] = DevFSFileContent(fs.file(vmSnapshotData)); assetEntries[_kVMSnapshotData] = DevFSFileContent(fs.file(vmSnapshotData));
assetEntries[_kIsolateSnapshotData] = DevFSFileContent(fs.file(isolateSnapshotData)); assetEntries[_kIsolateSnapshotData] = DevFSFileContent(fs.file(isolateSnapshotData));
......
...@@ -609,6 +609,7 @@ class FlutterSdk extends EngineCachedArtifact { ...@@ -609,6 +609,7 @@ class FlutterSdk extends EngineCachedArtifact {
List<List<String>> getBinaryDirs() { List<List<String>> getBinaryDirs() {
final List<List<String>> binaryDirs = <List<String>>[ final List<List<String>> binaryDirs = <List<String>>[
<String>['common', 'flutter_patched_sdk.zip'], <String>['common', 'flutter_patched_sdk.zip'],
<String>['common', 'flutter_patched_sdk_product.zip'],
]; ];
if (cache.includeAllPlatforms) { if (cache.includeAllPlatforms) {
binaryDirs.addAll(<List<String>>[ binaryDirs.addAll(<List<String>>[
......
...@@ -216,6 +216,7 @@ class AttachCommand extends FlutterCommand { ...@@ -216,6 +216,7 @@ class AttachCommand extends FlutterCommand {
viewFilter: argResults['isolate-filter'], viewFilter: argResults['isolate-filter'],
target: argResults['target'], target: argResults['target'],
targetModel: TargetModel(argResults['target-model']), targetModel: TargetModel(argResults['target-model']),
buildMode: getBuildMode(),
); );
flutterDevice.observatoryUris = <Uri>[ observatoryUri ]; flutterDevice.observatoryUris = <Uri>[ observatoryUri ];
final List<FlutterDevice> flutterDevices = <FlutterDevice>[flutterDevice]; final List<FlutterDevice> flutterDevices = <FlutterDevice>[flutterDevice];
......
...@@ -351,6 +351,7 @@ class AppDomain extends Domain { ...@@ -351,6 +351,7 @@ class AppDomain extends Domain {
dillOutputPath: dillOutputPath, dillOutputPath: dillOutputPath,
viewFilter: isolateFilter, viewFilter: isolateFilter,
target: target, target: target,
buildMode: options.buildInfo.mode,
); );
ResidentRunner runner; ResidentRunner runner;
......
...@@ -369,6 +369,7 @@ class RunCommand extends RunCommandBase { ...@@ -369,6 +369,7 @@ class RunCommand extends RunCommandBase {
viewFilter: argResults['isolate-filter'], viewFilter: argResults['isolate-filter'],
experimentalFlags: expFlags, experimentalFlags: expFlags,
target: argResults['target'], target: argResults['target'],
buildMode: getBuildMode(),
); );
flutterDevices.add(flutterDevice); flutterDevices.add(flutterDevice);
} }
......
...@@ -23,7 +23,8 @@ final RegExp _settingExpr = RegExp(r'(\w+)\s*=\s*(.*)$'); ...@@ -23,7 +23,8 @@ final RegExp _settingExpr = RegExp(r'(\w+)\s*=\s*(.*)$');
final RegExp _varExpr = RegExp(r'\$\(([^)]*)\)'); final RegExp _varExpr = RegExp(r'\$\(([^)]*)\)');
String flutterFrameworkDir(BuildMode mode) { 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. /// Writes or rewrites Xcode property files with the specified information.
......
...@@ -38,9 +38,10 @@ class FlutterDevice { ...@@ -38,9 +38,10 @@ class FlutterDevice {
TargetModel targetModel = TargetModel.flutter, TargetModel targetModel = TargetModel.flutter,
List<String> experimentalFlags, List<String> experimentalFlags,
ResidentCompiler generator, ResidentCompiler generator,
@required BuildMode buildMode,
}) : assert(trackWidgetCreation != null), }) : assert(trackWidgetCreation != null),
generator = generator ?? ResidentCompiler( generator = generator ?? ResidentCompiler(
artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath), artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath, mode: buildMode),
trackWidgetCreation: trackWidgetCreation, trackWidgetCreation: trackWidgetCreation,
fileSystemRoots: fileSystemRoots, fileSystemRoots: fileSystemRoots,
fileSystemScheme: fileSystemScheme, fileSystemScheme: fileSystemScheme,
...@@ -60,6 +61,7 @@ class FlutterDevice { ...@@ -60,6 +61,7 @@ class FlutterDevice {
TargetModel targetModel = TargetModel.flutter, TargetModel targetModel = TargetModel.flutter,
List<String> experimentalFlags, List<String> experimentalFlags,
ResidentCompiler generator, ResidentCompiler generator,
@required BuildMode buildMode,
}) async { }) async {
ResidentCompiler generator; ResidentCompiler generator;
final FlutterProject flutterProject = await FlutterProject.current(); final FlutterProject flutterProject = await FlutterProject.current();
...@@ -69,7 +71,7 @@ class FlutterDevice { ...@@ -69,7 +71,7 @@ class FlutterDevice {
); );
} else { } else {
generator = ResidentCompiler( generator = ResidentCompiler(
artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath), artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath, mode: buildMode),
trackWidgetCreation: trackWidgetCreation, trackWidgetCreation: trackWidgetCreation,
fileSystemRoots: fileSystemRoots, fileSystemRoots: fileSystemRoots,
fileSystemScheme: fileSystemScheme, fileSystemScheme: fileSystemScheme,
...@@ -87,6 +89,7 @@ class FlutterDevice { ...@@ -87,6 +89,7 @@ class FlutterDevice {
experimentalFlags: experimentalFlags, experimentalFlags: experimentalFlags,
targetModel: targetModel, targetModel: targetModel,
generator: generator, generator: generator,
buildMode: buildMode,
); );
} }
......
...@@ -252,7 +252,8 @@ someOtherTask ...@@ -252,7 +252,8 @@ someOtherTask
String expectedBuildName, String expectedBuildName,
String expectedBuildNumber, String expectedBuildNumber,
}) async { }) 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')); when(mockArtifacts.engineOutPath).thenReturn(fs.path.join('out', 'android_arm'));
final File manifestFile = fs.file('path/to/project/pubspec.yaml'); final File manifestFile = fs.file('path/to/project/pubspec.yaml');
......
...@@ -28,7 +28,7 @@ void main() { ...@@ -28,7 +28,7 @@ void main() {
testUsingContext('getArtifactPath', () { testUsingContext('getArtifactPath', () {
expect( 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'), fs.path.join(tempDir.path, 'bin', 'cache', 'artifacts', 'engine', 'ios-release', 'Flutter.framework'),
); );
expect( expect(
...@@ -78,7 +78,7 @@ void main() { ...@@ -78,7 +78,7 @@ void main() {
testUsingContext('getArtifactPath', () { testUsingContext('getArtifactPath', () {
expect( 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'), fs.path.join(tempDir.path, 'out', 'android_debug_unopt', 'Flutter.framework'),
); );
expect( expect(
......
...@@ -114,7 +114,8 @@ void main() { ...@@ -114,7 +114,8 @@ void main() {
mockXcode = MockXcode(); mockXcode = MockXcode();
bufferLogger = BufferLogger(); bufferLogger = BufferLogger();
for (BuildMode mode in BuildMode.values) { 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() { ...@@ -552,9 +553,11 @@ void main() {
mockArtifacts = MockArtifacts(); mockArtifacts = MockArtifacts();
for (BuildMode mode in BuildMode.values) { 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); .thenReturn(kEngineVmSnapshotData);
when(mockArtifacts.getArtifactPath(Artifact.isolateSnapshotData, null, mode)) when(mockArtifacts.getArtifactPath(Artifact.isolateSnapshotData,
platform: anyNamed('platform'), mode: mode))
.thenReturn(kEngineIsolateSnapshotData); .thenReturn(kEngineIsolateSnapshotData);
} }
}); });
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
import 'dart:async'; import 'dart:async';
import 'package:flutter_tools/src/artifacts.dart'; 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/devfs.dart';
import 'package:flutter_tools/src/device.dart'; import 'package:flutter_tools/src/device.dart';
import 'package:flutter_tools/src/resident_runner.dart'; import 'package:flutter_tools/src/resident_runner.dart';
...@@ -130,7 +131,7 @@ void main() { ...@@ -130,7 +131,7 @@ void main() {
when(mockDevice.supportsHotRestart).thenReturn(false); when(mockDevice.supportsHotRestart).thenReturn(false);
// Trigger hot restart. // Trigger hot restart.
final List<FlutterDevice> devices = <FlutterDevice>[ final List<FlutterDevice> devices = <FlutterDevice>[
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); final OperationResult result = await HotRunner(devices).restart(fullRestart: true);
// Expect hot restart failed. // Expect hot restart failed.
...@@ -151,8 +152,8 @@ void main() { ...@@ -151,8 +152,8 @@ void main() {
when(mockHotDevice.supportsHotRestart).thenReturn(true); when(mockHotDevice.supportsHotRestart).thenReturn(true);
// Trigger hot restart. // Trigger hot restart.
final List<FlutterDevice> devices = <FlutterDevice>[ final List<FlutterDevice> devices = <FlutterDevice>[
FlutterDevice(mockDevice, generator: residentCompiler, trackWidgetCreation: false)..devFS = mockDevFs, FlutterDevice(mockDevice, generator: residentCompiler, trackWidgetCreation: false, buildMode: BuildMode.debug)..devFS = mockDevFs,
FlutterDevice(mockHotDevice, generator: residentCompiler, trackWidgetCreation: false)..devFS = mockDevFs, FlutterDevice(mockHotDevice, generator: residentCompiler, trackWidgetCreation: false, buildMode: BuildMode.debug)..devFS = mockDevFs,
]; ];
final OperationResult result = await HotRunner(devices).restart(fullRestart: true); final OperationResult result = await HotRunner(devices).restart(fullRestart: true);
// Expect hot restart failed. // Expect hot restart failed.
...@@ -173,8 +174,8 @@ void main() { ...@@ -173,8 +174,8 @@ void main() {
when(mockHotDevice.supportsHotRestart).thenReturn(true); when(mockHotDevice.supportsHotRestart).thenReturn(true);
// Trigger a restart. // Trigger a restart.
final List<FlutterDevice> devices = <FlutterDevice>[ final List<FlutterDevice> devices = <FlutterDevice>[
FlutterDevice(mockDevice, generator: residentCompiler, trackWidgetCreation: false)..devFS = mockDevFs, FlutterDevice(mockDevice, generator: residentCompiler, trackWidgetCreation: false, buildMode: BuildMode.debug)..devFS = mockDevFs,
FlutterDevice(mockHotDevice, generator: residentCompiler, trackWidgetCreation: false)..devFS = mockDevFs, FlutterDevice(mockHotDevice, generator: residentCompiler, trackWidgetCreation: false, buildMode: BuildMode.debug)..devFS = mockDevFs,
]; ];
final OperationResult result = await HotRunner(devices).restart(fullRestart: true); final OperationResult result = await HotRunner(devices).restart(fullRestart: true);
// Expect hot restart was successful. // Expect hot restart was successful.
...@@ -190,7 +191,7 @@ void main() { ...@@ -190,7 +191,7 @@ void main() {
when(mockDevice.supportsHotReload).thenReturn(true); when(mockDevice.supportsHotReload).thenReturn(true);
when(mockDevice.supportsHotRestart).thenReturn(true); when(mockDevice.supportsHotRestart).thenReturn(true);
final List<FlutterDevice> devices = <FlutterDevice>[ final List<FlutterDevice> devices = <FlutterDevice>[
FlutterDevice(mockDevice, generator: residentCompiler, trackWidgetCreation: false), FlutterDevice(mockDevice, generator: residentCompiler, trackWidgetCreation: false, buildMode: BuildMode.debug),
]; ];
final OperationResult result = await HotRunner(devices).restart(fullRestart: true); final OperationResult result = await HotRunner(devices).restart(fullRestart: true);
expect(result.isOk, false); expect(result.isOk, false);
...@@ -207,7 +208,7 @@ void main() { ...@@ -207,7 +208,7 @@ void main() {
when(mockDevice.supportsHotRestart).thenReturn(true); when(mockDevice.supportsHotRestart).thenReturn(true);
// Trigger hot restart. // Trigger hot restart.
final List<FlutterDevice> devices = <FlutterDevice>[ final List<FlutterDevice> devices = <FlutterDevice>[
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); final OperationResult result = await HotRunner(devices).restart(fullRestart: true);
// Expect hot restart successful. // Expect hot restart successful.
...@@ -233,7 +234,7 @@ void main() { ...@@ -233,7 +234,7 @@ void main() {
when(mockDevice.supportsHotRestart).thenReturn(true); when(mockDevice.supportsHotRestart).thenReturn(true);
when(mockDevice.supportsStopApp).thenReturn(false); when(mockDevice.supportsStopApp).thenReturn(false);
final List<FlutterDevice> devices = <FlutterDevice>[ final List<FlutterDevice> devices = <FlutterDevice>[
FlutterDevice(mockDevice, generator: residentCompiler, trackWidgetCreation: false), FlutterDevice(mockDevice, generator: residentCompiler, trackWidgetCreation: false, buildMode: BuildMode.debug),
]; ];
await HotRunner(devices).cleanupAfterSignal(); await HotRunner(devices).cleanupAfterSignal();
expect(shutdownTestingConfig.shutdownHookCalled, true); expect(shutdownTestingConfig.shutdownHookCalled, true);
...@@ -248,7 +249,7 @@ void main() { ...@@ -248,7 +249,7 @@ void main() {
when(mockDevice.supportsHotRestart).thenReturn(true); when(mockDevice.supportsHotRestart).thenReturn(true);
when(mockDevice.supportsStopApp).thenReturn(false); when(mockDevice.supportsStopApp).thenReturn(false);
final List<FlutterDevice> devices = <FlutterDevice>[ final List<FlutterDevice> devices = <FlutterDevice>[
FlutterDevice(mockDevice, generator: residentCompiler, trackWidgetCreation: false), FlutterDevice(mockDevice, generator: residentCompiler, trackWidgetCreation: false, buildMode: BuildMode.debug),
]; ];
await HotRunner(devices).preStop(); await HotRunner(devices).preStop();
expect(shutdownTestingConfig.shutdownHookCalled, true); expect(shutdownTestingConfig.shutdownHookCalled, true);
......
...@@ -282,7 +282,8 @@ Information about project "Runner": ...@@ -282,7 +282,8 @@ Information about project "Runner":
} }
testUsingOsxContext('sets ARCHS=armv7 when armv7 local engine is set', () async { 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')); when(mockArtifacts.engineOutPath).thenReturn(fs.path.join('out', 'ios_profile_arm'));
const BuildInfo buildInfo = BuildInfo(BuildMode.debug, null, targetPlatform: TargetPlatform.ios); const BuildInfo buildInfo = BuildInfo(BuildMode.debug, null, targetPlatform: TargetPlatform.ios);
...@@ -300,7 +301,8 @@ Information about project "Runner": ...@@ -300,7 +301,8 @@ Information about project "Runner":
}); });
testUsingOsxContext('sets TRACK_WIDGET_CREATION=true when trackWidgetCreation is true', () async { 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')); when(mockArtifacts.engineOutPath).thenReturn(fs.path.join('out', 'ios_profile_arm'));
const BuildInfo buildInfo = BuildInfo(BuildMode.debug, null, trackWidgetCreation: true, targetPlatform: TargetPlatform.ios); const BuildInfo buildInfo = BuildInfo(BuildMode.debug, null, trackWidgetCreation: true, targetPlatform: TargetPlatform.ios);
final FlutterProject project = await FlutterProject.fromPath('path/to/project'); final FlutterProject project = await FlutterProject.fromPath('path/to/project');
...@@ -317,7 +319,8 @@ Information about project "Runner": ...@@ -317,7 +319,8 @@ Information about project "Runner":
}); });
testUsingOsxContext('does not set TRACK_WIDGET_CREATION when trackWidgetCreation is false', () async { 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')); when(mockArtifacts.engineOutPath).thenReturn(fs.path.join('out', 'ios_profile_arm'));
const BuildInfo buildInfo = BuildInfo(BuildMode.debug, null, targetPlatform: TargetPlatform.ios); const BuildInfo buildInfo = BuildInfo(BuildMode.debug, null, targetPlatform: TargetPlatform.ios);
final FlutterProject project = await FlutterProject.fromPath('path/to/project'); final FlutterProject project = await FlutterProject.fromPath('path/to/project');
...@@ -334,7 +337,8 @@ Information about project "Runner": ...@@ -334,7 +337,8 @@ Information about project "Runner":
}); });
testUsingOsxContext('sets ARCHS=armv7 when armv7 local engine is set', () async { 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')); when(mockArtifacts.engineOutPath).thenReturn(fs.path.join('out', 'ios_profile'));
const BuildInfo buildInfo = BuildInfo(BuildMode.debug, null, targetPlatform: TargetPlatform.ios); const BuildInfo buildInfo = BuildInfo(BuildMode.debug, null, targetPlatform: TargetPlatform.ios);
...@@ -366,7 +370,8 @@ Information about project "Runner": ...@@ -366,7 +370,8 @@ Information about project "Runner":
String expectedBuildName, String expectedBuildName,
String expectedBuildNumber, String expectedBuildNumber,
}) async { }) 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')); when(mockArtifacts.engineOutPath).thenReturn(fs.path.join('out', 'ios'));
final File manifestFile = fs.file('path/to/project/pubspec.yaml'); final File manifestFile = fs.file('path/to/project/pubspec.yaml');
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:async'; import 'dart:async';
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/device.dart'; import 'package:flutter_tools/src/device.dart';
import 'package:flutter_tools/src/resident_runner.dart'; import 'package:flutter_tools/src/resident_runner.dart';
import 'package:mockito/mockito.dart'; import 'package:mockito/mockito.dart';
...@@ -53,7 +54,7 @@ void main() { ...@@ -53,7 +54,7 @@ void main() {
// TODO(jacobr): make these tests run with `trackWidgetCreation: true` as // TODO(jacobr): make these tests run with `trackWidgetCreation: true` as
// well as the default flags. // well as the default flags.
return TestRunner( return TestRunner(
<FlutterDevice>[FlutterDevice(MockDevice(), trackWidgetCreation: false)], <FlutterDevice>[FlutterDevice(MockDevice(), trackWidgetCreation: false, buildMode: BuildMode.debug)],
); );
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment