Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
b5cd3ce8
Unverified
Commit
b5cd3ce8
authored
Mar 24, 2020
by
Jonah Williams
Committed by
GitHub
Mar 24, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] test and catch more exception types in web runner (#53183)
parent
d6614dba
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
48 deletions
+57
-48
resident_web_runner.dart
...utter_tools/lib/src/build_runner/resident_web_runner.dart
+2
-0
resident_web_runner_test.dart
...er_tools/test/general.shard/resident_web_runner_test.dart
+55
-48
No files found.
packages/flutter_tools/lib/src/build_runner/resident_web_runner.dart
View file @
b5cd3ce8
...
@@ -520,6 +520,8 @@ class _ResidentWebRunner extends ResidentWebRunner {
...
@@ -520,6 +520,8 @@ class _ResidentWebRunner extends ResidentWebRunner {
return
OperationResult
(
1
,
err
.
toString
(),
fatal:
true
);
return
OperationResult
(
1
,
err
.
toString
(),
fatal:
true
);
}
on
WipError
catch
(
err
)
{
}
on
WipError
catch
(
err
)
{
return
OperationResult
(
1
,
err
.
toString
(),
fatal:
true
);
return
OperationResult
(
1
,
err
.
toString
(),
fatal:
true
);
}
on
vmservice
.
RPCError
catch
(
err
)
{
return
OperationResult
(
1
,
err
.
toString
(),
fatal:
true
);
}
finally
{
}
finally
{
status
.
stop
();
status
.
stop
();
}
}
...
...
packages/flutter_tools/test/general.shard/resident_web_runner_test.dart
View file @
b5cd3ce8
...
@@ -513,54 +513,61 @@ void main() {
...
@@ -513,54 +513,61 @@ void main() {
Usage:
()
=>
MockFlutterUsage
(),
Usage:
()
=>
MockFlutterUsage
(),
}));
}));
// TODO(jonahwilliams): re-enable tests once we switch back to DWDS for hot reload/restart.
test
(
'Fails non-fatally on vmservice response error for hot restart'
,
()
=>
testbed
.
run
(()
async
{
// test('Fails on vmservice response error for hot restart', () => testbed.run(() async {
_setupMocks
();
// _setupMocks();
final
Completer
<
DebugConnectionInfo
>
connectionInfoCompleter
=
Completer
<
DebugConnectionInfo
>();
// final Completer<DebugConnectionInfo> connectionInfoCompleter = Completer<DebugConnectionInfo>();
unawaited
(
residentWebRunner
.
run
(
// unawaited(residentWebRunner.run(
connectionInfoCompleter:
connectionInfoCompleter
,
// connectionInfoCompleter: connectionInfoCompleter,
));
// ));
await
connectionInfoCompleter
.
future
;
// await connectionInfoCompleter.future;
when
(
mockVmService
.
callMethod
(
'hotRestart'
)).
thenAnswer
((
Invocation
_
)
async
{
// when(mockVmService.callServiceExtension('fullReload')).thenAnswer((Invocation _) async {
return
Response
.
parse
(<
String
,
Object
>{
'type'
:
'Failed'
});
// return Response.parse(<String, Object>{'type': 'Failed'});
});
// });
final
OperationResult
result
=
await
residentWebRunner
.
restart
(
fullRestart:
false
);
// final OperationResult result = await residentWebRunner.restart(fullRestart: true);
expect
(
result
.
code
,
0
);
// expect(result.code, 1);
}));
// expect(result.message, contains('Failed'));
// }));
test
(
'Fails fatally on vmservice RpcError'
,
()
=>
testbed
.
run
(()
async
{
_setupMocks
();
// TODO(jonahwilliams): re-enable tests once we switch back to DWDS for hot reload/restart.
final
Completer
<
DebugConnectionInfo
>
connectionInfoCompleter
=
Completer
<
DebugConnectionInfo
>();
// test('Fails on vmservice response error for hot reload', () => testbed.run(() async {
unawaited
(
residentWebRunner
.
run
(
// _setupMocks();
connectionInfoCompleter:
connectionInfoCompleter
,
// final Completer<DebugConnectionInfo> connectionInfoCompleter = Completer<DebugConnectionInfo>();
));
// unawaited(residentWebRunner.run(
await
connectionInfoCompleter
.
future
;
// connectionInfoCompleter: connectionInfoCompleter,
when
(
mockVmService
.
callMethod
(
'hotRestart'
)).
thenThrow
(
RPCError
(
'Something went wrong'
,
2
,
'123'
));
// ));
final
OperationResult
result
=
await
residentWebRunner
.
restart
(
fullRestart:
false
);
// await connectionInfoCompleter.future;
// when(mockVmService.callServiceExtension('hotRestart')).thenAnswer((Invocation _) async {
expect
(
result
.
code
,
1
);
// return Response.parse(<String, Object>{'type': 'Failed'});
expect
(
result
.
message
,
contains
(
'Something went wrong'
));
// });
}));
// final OperationResult result = await residentWebRunner.restart(fullRestart: false);
test
(
'Fails fatally on vmservice WipError'
,
()
=>
testbed
.
run
(()
async
{
// expect(result.code, 1);
_setupMocks
();
// expect(result.message, contains('Failed'));
final
Completer
<
DebugConnectionInfo
>
connectionInfoCompleter
=
Completer
<
DebugConnectionInfo
>();
// }));
unawaited
(
residentWebRunner
.
run
(
connectionInfoCompleter:
connectionInfoCompleter
,
// TODO(jonahwilliams): re-enable tests once we switch back to DWDS for hot reload/restart.
));
// test('Fails on vmservice RpcError', () => testbed.run(() async {
await
connectionInfoCompleter
.
future
;
// _setupMocks();
when
(
mockVmService
.
callMethod
(
'hotRestart'
)).
thenThrow
(
WipError
(<
String
,
String
>{}));
// final Completer<DebugConnectionInfo> connectionInfoCompleter = Completer<DebugConnectionInfo>();
final
OperationResult
result
=
await
residentWebRunner
.
restart
(
fullRestart:
false
);
// unawaited(residentWebRunner.run(
// connectionInfoCompleter: connectionInfoCompleter,
expect
(
result
.
code
,
1
);
// ));
}));
// await connectionInfoCompleter.future;
// when(mockVmService.callServiceExtension('hotRestart')).thenThrow(RPCError('', 2, '123'));
test
(
'Fails fatally on vmservice Exception'
,
()
=>
testbed
.
run
(()
async
{
// final OperationResult result = await residentWebRunner.restart(fullRestart: false);
_setupMocks
();
final
Completer
<
DebugConnectionInfo
>
connectionInfoCompleter
=
Completer
<
DebugConnectionInfo
>();
// expect(result.code, 1);
unawaited
(
residentWebRunner
.
run
(
// expect(result.message, contains('Page requires refresh'));
connectionInfoCompleter:
connectionInfoCompleter
,
// }));
));
await
connectionInfoCompleter
.
future
;
when
(
mockVmService
.
callMethod
(
'hotRestart'
)).
thenThrow
(
Exception
(
'Something went wrong'
));
final
OperationResult
result
=
await
residentWebRunner
.
restart
(
fullRestart:
false
);
expect
(
result
.
code
,
1
);
expect
(
result
.
message
,
contains
(
'Something went wrong'
));
}));
test
(
'printHelp without details has web warning'
,
()
=>
testbed
.
run
(()
async
{
test
(
'printHelp without details has web warning'
,
()
=>
testbed
.
run
(()
async
{
residentWebRunner
.
printHelp
(
details:
false
);
residentWebRunner
.
printHelp
(
details:
false
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment