Unverified Commit b0864737 authored by Danny Tuppeny's avatar Danny Tuppeny Committed by GitHub

Pass multidex flag when using --machine mode (#101689)

parent 2302daa3
......@@ -157,12 +157,12 @@ class Daemon {
this.logToStdout = false,
}) {
// Set up domains.
_registerDomain(daemonDomain = DaemonDomain(this));
_registerDomain(appDomain = AppDomain(this));
_registerDomain(deviceDomain = DeviceDomain(this));
_registerDomain(emulatorDomain = EmulatorDomain(this));
_registerDomain(devToolsDomain = DevToolsDomain(this));
_registerDomain(proxyDomain = ProxyDomain(this));
registerDomain(daemonDomain = DaemonDomain(this));
registerDomain(appDomain = AppDomain(this));
registerDomain(deviceDomain = DeviceDomain(this));
registerDomain(emulatorDomain = EmulatorDomain(this));
registerDomain(devToolsDomain = DevToolsDomain(this));
registerDomain(proxyDomain = ProxyDomain(this));
// Start listening.
_commandSubscription = connection.incomingCommands.listen(
......@@ -192,7 +192,8 @@ class Daemon {
final Completer<int> _onExitCompleter = Completer<int>();
final Map<String, Domain> _domainMap = <String, Domain>{};
void _registerDomain(Domain domain) {
@visibleForTesting
void registerDomain(Domain domain) {
_domainMap[domain.name] = domain;
}
......@@ -496,6 +497,7 @@ class AppDomain extends Domain {
String packagesFilePath,
String dillOutputPath,
bool ipv6 = false,
bool multidexEnabled = false,
String isolateFilter,
bool machine = true,
}) async {
......@@ -544,6 +546,7 @@ class AppDomain extends Domain {
projectRootPath: projectRootPath,
dillOutputPath: dillOutputPath,
ipv6: ipv6,
multidexEnabled: multidexEnabled,
hostIsIde: true,
machine: machine,
);
......@@ -554,6 +557,7 @@ class AppDomain extends Domain {
debuggingOptions: options,
applicationBinary: applicationBinary,
ipv6: ipv6,
multidexEnabled: multidexEnabled,
machine: machine,
);
}
......
......@@ -551,6 +551,21 @@ class RunCommand extends RunCommandBase {
);
}
@visibleForTesting
Daemon createMachineDaemon() {
final Daemon daemon = Daemon(
DaemonConnection(
daemonStreams: DaemonStreams.fromStdio(globals.stdio, logger: globals.logger),
logger: globals.logger,
),
notifyingLogger: (globals.logger is NotifyingLogger)
? globals.logger as NotifyingLogger
: NotifyingLogger(verbose: globals.logger.isVerbose, parent: globals.logger),
logToStdout: true,
);
return daemon;
}
@override
Future<FlutterCommandResult> runCommand() async {
// Enable hot mode by default if `--no-hot` was not passed and we are in
......@@ -563,16 +578,7 @@ class RunCommand extends RunCommandBase {
if (devices.length > 1) {
throwToolExit('"--machine" does not support "-d all".');
}
final Daemon daemon = Daemon(
DaemonConnection(
daemonStreams: DaemonStreams.fromStdio(globals.stdio, logger: globals.logger),
logger: globals.logger,
),
notifyingLogger: (globals.logger is NotifyingLogger)
? globals.logger as NotifyingLogger
: NotifyingLogger(verbose: globals.logger.isVerbose, parent: globals.logger),
logToStdout: true,
);
final Daemon daemon = createMachineDaemon();
AppInstance app;
try {
app = await daemon.appDomain.startApp(
......@@ -586,6 +592,7 @@ class RunCommand extends RunCommandBase {
packagesFilePath: globalResults['packages'] as String,
dillOutputPath: stringArg('output-dill'),
ipv6: ipv6,
multidexEnabled: boolArg('multidex'),
);
} on Exception catch (error) {
throwToolExit(error.toString());
......
......@@ -26,6 +26,7 @@ import 'package:flutter_tools/src/base/platform.dart';
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/daemon.dart';
import 'package:flutter_tools/src/commands/run.dart';
import 'package:flutter_tools/src/devfs.dart';
import 'package:flutter_tools/src/device.dart';
......@@ -405,6 +406,67 @@ void main() {
ProcessManager: () => FakeProcessManager.any(),
Usage: () => usage,
});
group('--machine', () {
testUsingContext('enables multidex by default', () async {
final DaemonCapturingRunCommand command = DaemonCapturingRunCommand();
final FakeDevice device = FakeDevice();
mockDeviceManager
..devices = <Device>[device]
..targetDevices = <Device>[device];
await expectLater(
() => createTestCommandRunner(command).run(<String>[
'run',
'--no-pub',
'--machine',
'-d',
device.id,
]),
throwsToolExit(),
);
expect(command.appDomain.multidexEnabled, isTrue);
}, overrides: <Type, Generator>{
Artifacts: () => artifacts,
Cache: () => Cache.test(processManager: FakeProcessManager.any()),
DeviceManager: () => mockDeviceManager,
FileSystem: () => fs,
ProcessManager: () => FakeProcessManager.any(),
Usage: () => usage,
Stdio: () => FakeStdio(),
Logger: () => AppRunLogger(parent: BufferLogger.test()),
});
testUsingContext('can disable multidex with --no-multidex', () async {
final DaemonCapturingRunCommand command = DaemonCapturingRunCommand();
final FakeDevice device = FakeDevice();
mockDeviceManager
..devices = <Device>[device]
..targetDevices = <Device>[device];
await expectLater(
() => createTestCommandRunner(command).run(<String>[
'run',
'--no-pub',
'--no-multidex',
'--machine',
'-d',
device.id,
]),
throwsToolExit(),
);
expect(command.appDomain.multidexEnabled, isFalse);
}, overrides: <Type, Generator>{
Artifacts: () => artifacts,
Cache: () => Cache.test(processManager: FakeProcessManager.any()),
DeviceManager: () => mockDeviceManager,
FileSystem: () => fs,
ProcessManager: () => FakeProcessManager.any(),
Usage: () => usage,
Stdio: () => FakeStdio(),
Logger: () => AppRunLogger(parent: BufferLogger.test()),
});
});
});
group('Fatal Logs', () {
......@@ -687,6 +749,13 @@ class FakeDeviceManager extends Fake implements DeviceManager {
return targetDevices;
}
@override
List<DeviceDiscovery> get deviceDiscoverers {
final FakePollingDeviceDiscovery discoverer = FakePollingDeviceDiscovery();
devices.forEach(discoverer.addDevice);
return <DeviceDiscovery>[discoverer];
}
@override
Future<List<Device>> getAllConnectedDevices() async => devices;
}
......@@ -739,6 +808,9 @@ class FakeDevice extends Fake implements Device {
@override
bool supportsHotReload = false;
@override
bool get supportsHotRestart => true;
@override
bool get supportsFastStart => false;
......@@ -858,3 +930,44 @@ class FakeResidentRunner extends Fake implements ResidentRunner {
return 0;
}
}
class DaemonCapturingRunCommand extends RunCommand {
/*late*/ Daemon daemon;
/*late*/ CapturingAppDomain appDomain;
@override
Daemon createMachineDaemon() {
daemon = super.createMachineDaemon();
appDomain = daemon.appDomain = CapturingAppDomain(daemon);
daemon.registerDomain(appDomain);
return daemon;
}
}
class CapturingAppDomain extends AppDomain {
CapturingAppDomain(Daemon daemon) : super(daemon);
bool /*?*/ multidexEnabled;
@override
Future<AppInstance> startApp(
Device device,
String projectDirectory,
String target,
String route,
DebuggingOptions options,
bool enableHotReload, {
File applicationBinary,
@required bool trackWidgetCreation,
String projectRootPath,
String packagesFilePath,
String dillOutputPath,
bool ipv6 = false,
bool multidexEnabled = false,
String isolateFilter,
bool machine = true,
}) async {
this.multidexEnabled = multidexEnabled;
throwToolExit('');
}
}
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