Unverified Commit 5e1bb20c authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

support --no-resident on the web (#44028)

parent ee032f67
...@@ -36,6 +36,7 @@ class DwdsWebRunnerFactory extends WebRunnerFactory { ...@@ -36,6 +36,7 @@ class DwdsWebRunnerFactory extends WebRunnerFactory {
ResidentRunner createWebRunner( ResidentRunner createWebRunner(
Device device, { Device device, {
String target, String target,
@required bool stayResident,
@required FlutterProject flutterProject, @required FlutterProject flutterProject,
@required bool ipv6, @required bool ipv6,
@required DebuggingOptions debuggingOptions, @required DebuggingOptions debuggingOptions,
...@@ -46,6 +47,7 @@ class DwdsWebRunnerFactory extends WebRunnerFactory { ...@@ -46,6 +47,7 @@ class DwdsWebRunnerFactory extends WebRunnerFactory {
flutterProject: flutterProject, flutterProject: flutterProject,
debuggingOptions: debuggingOptions, debuggingOptions: debuggingOptions,
ipv6: ipv6, ipv6: ipv6,
stayResident: stayResident,
); );
} }
} }
...@@ -57,12 +59,13 @@ class ResidentWebRunner extends ResidentRunner { ...@@ -57,12 +59,13 @@ class ResidentWebRunner extends ResidentRunner {
@required this.flutterProject, @required this.flutterProject,
@required bool ipv6, @required bool ipv6,
@required DebuggingOptions debuggingOptions, @required DebuggingOptions debuggingOptions,
bool stayResident = true,
}) : super( }) : super(
<FlutterDevice>[], <FlutterDevice>[],
target: target ?? fs.path.join('lib', 'main.dart'), target: target ?? fs.path.join('lib', 'main.dart'),
debuggingOptions: debuggingOptions, debuggingOptions: debuggingOptions,
ipv6: ipv6, ipv6: ipv6,
stayResident: true, stayResident: stayResident,
); );
final Device device; final Device device;
...@@ -316,9 +319,15 @@ class ResidentWebRunner extends ResidentRunner { ...@@ -316,9 +319,15 @@ class ResidentWebRunner extends ResidentRunner {
connectionInfoCompleter?.complete( connectionInfoCompleter?.complete(
DebugConnectionInfo(wsUri: websocketUri) DebugConnectionInfo(wsUri: websocketUri)
); );
final int result = await waitForAppToFinish();
if (stayResident) {
await waitForAppToFinish();
} else {
await stopEchoingDeviceLog();
await exitApp();
}
await cleanupAtFinish(); await cleanupAtFinish();
return result; return 0;
} }
@override @override
......
...@@ -435,6 +435,7 @@ class AppDomain extends Domain { ...@@ -435,6 +435,7 @@ class AppDomain extends Domain {
target: target, target: target,
debuggingOptions: options, debuggingOptions: options,
ipv6: ipv6, ipv6: ipv6,
stayResident: true,
); );
} else if (enableHotReload) { } else if (enableHotReload) {
runner = HotRunner( runner = HotRunner(
......
...@@ -457,6 +457,7 @@ class RunCommand extends RunCommandBase { ...@@ -457,6 +457,7 @@ class RunCommand extends RunCommandBase {
flutterProject: flutterProject, flutterProject: flutterProject,
ipv6: ipv6, ipv6: ipv6,
debuggingOptions: _createDebuggingOptions(), debuggingOptions: _createDebuggingOptions(),
stayResident: stayResident,
); );
} else { } else {
runner = ColdRunner( runner = ColdRunner(
......
...@@ -19,6 +19,7 @@ abstract class WebRunnerFactory { ...@@ -19,6 +19,7 @@ abstract class WebRunnerFactory {
ResidentRunner createWebRunner( ResidentRunner createWebRunner(
Device device, { Device device, {
String target, String target,
@required bool stayResident,
@required FlutterProject flutterProject, @required FlutterProject flutterProject,
@required bool ipv6, @required bool ipv6,
@required DebuggingOptions debuggingOptions, @required DebuggingOptions debuggingOptions,
......
...@@ -154,6 +154,19 @@ void main() { ...@@ -154,6 +154,19 @@ void main() {
Logger: () => DelegateLogger(BufferLogger()), Logger: () => DelegateLogger(BufferLogger()),
})); }));
test('Can successfully run and disconnect with --no-resident', () => testbed.run(() async {
_setupMocks();
residentWebRunner = ResidentWebRunner(
mockWebDevice,
flutterProject: FlutterProject.current(),
debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug),
ipv6: true,
stayResident: false,
);
expect(await residentWebRunner.run(), 0);
}));
test('Listens to stdout streams before running main', () => testbed.run(() async { test('Listens to stdout streams before running main', () => testbed.run(() async {
_setupMocks(); _setupMocks();
final BufferLogger bufferLogger = logger; final BufferLogger bufferLogger = logger;
......
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