Unverified Commit 24d8dbb1 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[flutter_tools] remove web defines workaround (#75361)

parent f3fad81b
......@@ -164,7 +164,7 @@ abstract class RunCommandBase extends FlutterCommand with DeviceBasedDevelopment
/// Create a debugging options instance for the current `run` or `drive` invocation.
Future<DebuggingOptions> createDebuggingOptions(bool webMode) async {
final BuildInfo buildInfo = await getBuildInfo(updateWebDefines: webMode);
final BuildInfo buildInfo = await getBuildInfo();
final int browserDebugPort = featureFlags.isWebEnabled && argResults.wasParsed('web-browser-debug-port')
? int.parse(stringArg('web-browser-debug-port'))
: null;
......@@ -398,7 +398,7 @@ class RunCommand extends RunCommandBase {
}
}
final BuildInfo buildInfo = await getBuildInfo(updateWebDefines: webMode);
final BuildInfo buildInfo = await getBuildInfo();
final String modeName = buildInfo.modeName;
return <CustomDimensions, String>{
CustomDimensions.commandRunIsEmulator: '$isEmulator',
......@@ -510,7 +510,7 @@ class RunCommand extends RunCommandBase {
Future<FlutterCommandResult> runCommand() async {
// Enable hot mode by default if `--no-hot` was not passed and we are in
// debug mode.
final BuildInfo buildInfo = await getBuildInfo(updateWebDefines: webMode);
final BuildInfo buildInfo = await getBuildInfo();
final bool hotMode = shouldUseHotMode(buildInfo);
final String applicationBinaryPath = stringArg('use-application-binary');
......
......@@ -820,7 +820,7 @@ abstract class FlutterCommand extends Command<void> {
///
/// Throws a [ToolExit] if the current set of options is not compatible with
/// each other.
Future<BuildInfo> getBuildInfo({ BuildMode forcedBuildMode, bool updateWebDefines = true }) async {
Future<BuildInfo> getBuildInfo({ BuildMode forcedBuildMode }) async {
final bool trackWidgetCreation = argParser.options.containsKey('track-widget-creation') &&
boolArg('track-widget-creation');
......@@ -940,7 +940,7 @@ abstract class FlutterCommand extends Command<void> {
? stringsArg(FlutterOptions.kDartDefinesOption)
: <String>[];
if (argParser.options.containsKey('web-renderer') && updateWebDefines) {
if (argParser.options.containsKey('web-renderer')) {
dartDefines = updateDartDefines(dartDefines, stringArg('web-renderer'));
}
......
......@@ -19,7 +19,6 @@ import 'package:flutter_tools/src/base/user_messages.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/commands/run.dart';
import 'package:flutter_tools/src/convert.dart';
import 'package:flutter_tools/src/device.dart';
import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:flutter_tools/src/project.dart';
......@@ -394,66 +393,6 @@ void main() {
ProcessManager: () => mockProcessManager,
Usage: () => usage,
});
testUsingContext('No web renderer options are added to non web device', () async {
final FakeApplicationPackageFactory applicationPackageFactory = ApplicationPackageFactory.instance as FakeApplicationPackageFactory;
final RunCommand command = RunCommand();
final MockDevice mockDevice = MockDevice(TargetPlatform.ios);
when(mockDevice.supportsRuntimeMode(any)).thenAnswer((Invocation invocation) => true);
when(mockDevice.isLocalEmulator).thenAnswer((Invocation invocation) => Future<bool>.value(false));
when(mockDevice.getLogReader(app: anyNamed('app'))).thenReturn(FakeDeviceLogReader());
when(mockDevice.supportsFastStart).thenReturn(true);
when(mockDevice.sdkNameAndVersion).thenAnswer((Invocation invocation) => Future<String>.value('iOS 13'));
applicationPackageFactory.package = PrebuiltIOSApp(projectBundleId: 'test');
DebuggingOptions debuggingOptions;
when(mockDevice.startApp(
any,
mainPath: anyNamed('mainPath'),
debuggingOptions: anyNamed('debuggingOptions'),
platformArgs: anyNamed('platformArgs'),
route: anyNamed('route'),
prebuiltApplication: anyNamed('prebuiltApplication'),
ipv6: anyNamed('ipv6'),
userIdentifier: anyNamed('userIdentifier'),
)).thenAnswer((Invocation invocation) {
debuggingOptions = invocation.namedArguments[#debuggingOptions] as DebuggingOptions;
return Future<LaunchResult>.value(LaunchResult.failed());
});
when(mockDeviceManager.getDevices()).thenAnswer(
(Invocation invocation) => Future<List<Device>>.value(<Device>[mockDevice])
);
when(mockDeviceManager.findTargetDevices(any, timeout: anyNamed('timeout'))).thenAnswer(
(Invocation invocation) => Future<List<Device>>.value(<Device>[mockDevice])
);
final Directory tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_run_test.');
tempDir.childDirectory('ios').childFile('AppDelegate.swift').createSync(recursive: true);
tempDir.childFile('.dart_tool/package_config')
..createSync(recursive: true)
..writeAsStringSync(json.encode(<String, Object>{'configVersion': 2, 'packages': <Object>[]}));
tempDir.childDirectory('lib').childFile('main.dart').createSync(recursive: true);
tempDir.childFile('pubspec.yaml').writeAsStringSync('name: test');
globals.fs.currentDirectory = tempDir;
await expectToolExitLater(createTestCommandRunner(command).run(<String>[
'run',
'--no-pub',
'--no-hot',
]), isNull);
// No web renderer options are added.
expect(debuggingOptions.buildInfo.dartDefines, isEmpty);
}, overrides: <Type, Generator>{
Artifacts: () => artifacts,
Cache: () => mockCache,
DeviceManager: () => mockDeviceManager,
FileSystem: () => fs,
ProcessManager: () => mockProcessManager,
ApplicationPackageFactory: () => FakeApplicationPackageFactory(),
});
});
testUsingContext('should only request artifacts corresponding to connected devices', () async {
......
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