Skip to content

Hot Restart progress events #221

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions webdev/lib/src/daemon/app_domain.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class AppDomain extends Domain {
WebdevVmClient _webdevVmClient;
DebugService _debugService;
bool _isShutdown = false;
var _progressEventId = 0;

void _initialize(ServerManager serverManager) async {
var devHandler = serverManager.servers.first.devHandler;
Expand Down Expand Up @@ -90,7 +91,20 @@ class AppDomain extends Domain {
}
// TODO(grouma) - Support pauseAfterRestart.
// var pauseAfterRestart = getBoolArg(args, 'pause') ?? false;
_progressEventId++;
sendEvent('app.progress', {
'appId': _appId,
'id': '$_progressEventId',
'message': 'Performing hot restart...',
'progressId': 'hot.restart',
});
var response = await _vmService.callServiceExtension('hotRestart');
sendEvent('app.progress', {
'appId': _appId,
'id': '$_progressEventId',
'finished': true,
'progressId': 'hot.restart',
});
return {
'code': response.type == 'Success' ? 0 : 1,
'message': response.toString()
Expand Down
12 changes: 10 additions & 2 deletions webdev/test/daemon/app_domain_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,16 @@ void main() {
var extensionCall = '[{"method":"app.restart","id":0,'
'"params" : { "appId" : "$appId", "fullRestart" : true}}]';
webdev.stdin.add(utf8.encode('$extensionCall\n'));
await expectLater(webdev.stdout,
emitsThrough(startsWith('[{"id":0,"result":{"code":0')));
await expectLater(
webdev.stdout,
emitsThrough(emitsInOrder([
startsWith(
'[{"event":"app.progress","params":{"appId":"$appId","id":"1",'
'"message":"Performing hot restart..."'),
startsWith(
'[{"event":"app.progress","params":{"appId":"$appId","id":"1",'
'"finished":true')
])));
await exitWebdev(webdev);
});
});
Expand Down