Unverified Commit 79323f7c authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

Ensure target platform is passed is always passed to assemble (#43862)

parent 40670c09
......@@ -50,7 +50,7 @@ class BundleBuilder {
/// The default `mainPath` is `lib/main.dart`.
/// The default `manifestPath` is `pubspec.yaml`
Future<void> build({
TargetPlatform platform,
@required TargetPlatform platform,
BuildMode buildMode,
String mainPath,
String manifestPath = defaultManifestPath,
......
......@@ -5,6 +5,8 @@
import 'dart:async';
import 'dart:math' as math;
import 'package:meta/meta.dart';
import '../application_package.dart';
import '../base/common.dart';
import '../base/context.dart';
......@@ -417,7 +419,7 @@ class IOSSimulator extends Device {
}
Future<void> _setupUpdatedApplicationBundle(covariant BuildableIOSApp app, BuildInfo buildInfo, String mainPath) async {
await _sideloadUpdatedAssetsForInstalledApplicationBundle(app, buildInfo, mainPath);
await sideloadUpdatedAssetsForInstalledApplicationBundle(buildInfo, mainPath);
// Step 1: Build the Xcode project.
// The build mode for the simulator is always debug.
......@@ -448,9 +450,11 @@ class IOSSimulator extends Device {
await SimControl.instance.install(id, fs.path.absolute(bundle.path));
}
Future<void> _sideloadUpdatedAssetsForInstalledApplicationBundle(ApplicationPackage app, BuildInfo buildInfo, String mainPath) {
@visibleForTesting
Future<void> sideloadUpdatedAssetsForInstalledApplicationBundle(BuildInfo buildInfo, String mainPath) {
// Run compiler to produce kernel file for the application.
return BundleBuilder().build(
platform: TargetPlatform.ios,
mainPath: mainPath,
precompiledSnapshot: false,
buildMode: buildInfo.mode,
......
......@@ -8,6 +8,8 @@ import 'dart:io' show ProcessResult, Process;
import 'package:file/file.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:file/memory.dart';
import 'package:flutter_tools/src/build_system/build_system.dart';
import 'package:flutter_tools/src/build_system/targets/dart.dart';
import 'package:flutter_tools/src/device.dart';
import 'package:flutter_tools/src/application_package.dart';
import 'package:flutter_tools/src/base/file_system.dart';
......@@ -183,6 +185,25 @@ void main() {
});
});
testUsingContext('builds with targetPlatform', () async {
final IOSSimulator simulator = IOSSimulator('x', name: 'iPhone X');
when(buildSystem.build(any, any)).thenAnswer((Invocation invocation) async {
return BuildResult(success: true);
});
await simulator.sideloadUpdatedAssetsForInstalledApplicationBundle(BuildInfo.debug, 'lib/main.dart');
final VerificationResult result = verify(buildSystem.build(any, captureAny));
final Environment environment = result.captured.single;
expect(environment.defines, <String, String>{
kTargetFile: 'lib/main.dart',
kTargetPlatform: 'ios',
kBuildMode: 'debug',
kTrackWidgetCreation: 'false',
});
}, overrides: <Type, Generator>{
BuildSystem: () => MockBuildSystem(),
});
group('Simulator screenshot', () {
MockXcode mockXcode;
MockProcessManager mockProcessManager;
......@@ -512,3 +533,5 @@ flutter:
ProcessManager: () => FakeProcessManager.any(),
});
}
class MockBuildSystem extends Mock implements BuildSystem {}
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