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 {
ResidentRunner createWebRunner(
Device device, {
String target,
@required bool stayResident,
@required FlutterProject flutterProject,
@required bool ipv6,
@required DebuggingOptions debuggingOptions,
......@@ -46,6 +47,7 @@ class DwdsWebRunnerFactory extends WebRunnerFactory {
flutterProject: flutterProject,
debuggingOptions: debuggingOptions,
ipv6: ipv6,
stayResident: stayResident,
);
}
}
......@@ -57,12 +59,13 @@ class ResidentWebRunner extends ResidentRunner {
@required this.flutterProject,
@required bool ipv6,
@required DebuggingOptions debuggingOptions,
bool stayResident = true,
}) : super(
<FlutterDevice>[],
target: target ?? fs.path.join('lib', 'main.dart'),
debuggingOptions: debuggingOptions,
ipv6: ipv6,
stayResident: true,
stayResident: stayResident,
);
final Device device;
......@@ -316,9 +319,15 @@ class ResidentWebRunner extends ResidentRunner {
connectionInfoCompleter?.complete(
DebugConnectionInfo(wsUri: websocketUri)
);
final int result = await waitForAppToFinish();
if (stayResident) {
await waitForAppToFinish();
} else {
await stopEchoingDeviceLog();
await exitApp();
}
await cleanupAtFinish();
return result;
return 0;
}
@override
......
......@@ -435,6 +435,7 @@ class AppDomain extends Domain {
target: target,
debuggingOptions: options,
ipv6: ipv6,
stayResident: true,
);
} else if (enableHotReload) {
runner = HotRunner(
......
......@@ -457,6 +457,7 @@ class RunCommand extends RunCommandBase {
flutterProject: flutterProject,
ipv6: ipv6,
debuggingOptions: _createDebuggingOptions(),
stayResident: stayResident,
);
} else {
runner = ColdRunner(
......
......@@ -19,6 +19,7 @@ abstract class WebRunnerFactory {
ResidentRunner createWebRunner(
Device device, {
String target,
@required bool stayResident,
@required FlutterProject flutterProject,
@required bool ipv6,
@required DebuggingOptions debuggingOptions,
......
......@@ -154,6 +154,19 @@ void main() {
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 {
_setupMocks();
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