Skip to content

Commit 34aa5f5

Browse files
committed
Add retry test.
1 parent b9241e0 commit 34aa5f5

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

dwds/test/expression_evaluator_test.dart

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import 'package:dwds/src/debugging/location.dart';
1313
import 'package:dwds/src/debugging/skip_list.dart';
1414
import 'package:dwds/src/services/batched_expression_evaluator.dart';
1515
import 'package:dwds/src/services/expression_evaluator.dart';
16+
import 'package:dwds/src/utilities/shared.dart';
1617

1718
import 'package:test/test.dart';
1819
import 'package:vm_service/vm_service.dart' hide LogRecord;
@@ -36,6 +37,7 @@ void main() async {
3637

3738
late StreamController<DebuggerPausedEvent> pausedController;
3839
late StreamController<Event> debugEventController;
40+
late FakeInspector inspector;
3941
setUp(() async {
4042
final assetReader = FakeAssetReader(sourceMap: '');
4143
final toolConfiguration = TestToolConfiguration.withLoadStrategy(
@@ -64,8 +66,7 @@ void main() async {
6466
skipLists,
6567
root,
6668
);
67-
final inspector =
68-
FakeInspector(webkitDebugger, fakeIsolate: simpleIsolate);
69+
inspector = FakeInspector(webkitDebugger, fakeIsolate: simpleIsolate);
6970
debugger.updateInspector(inspector);
7071

7172
_evaluator = ExpressionEvaluator(
@@ -192,6 +193,21 @@ void main() async {
192193
);
193194
});
194195

196+
test('retries failed batched expression', () async {
197+
safeUnawaited(
198+
evaluator.evaluateExpression('2', 'main.dart', 'true', {}),
199+
);
200+
201+
await evaluator.evaluateExpression('2', 'main.dart', 'false', {});
202+
expect(inspector.functionsCalled.length, 3);
203+
expect(
204+
inspector.functionsCalled[0].contains('return [ true, false ];'),
205+
true,
206+
);
207+
expect(inspector.functionsCalled[1].contains('return true;'), true);
208+
expect(inspector.functionsCalled[2].contains('return false;'), true);
209+
});
210+
195211
test('returns error if closed', () async {
196212
evaluator.close();
197213
final result =

dwds/test/fixtures/fakes.dart

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ Isolate get simpleIsolate => Isolate(
4848

4949
class FakeInspector implements AppInspector {
5050
final WebkitDebugger _remoteDebugger;
51+
final List<String> functionsCalled = [];
5152
FakeInspector(this._remoteDebugger, {required this.fakeIsolate});
5253

5354
Isolate fakeIsolate;
@@ -61,8 +62,10 @@ class FakeInspector implements AppInspector {
6162
Future<RemoteObject> callFunction(
6263
String function,
6364
Iterable<String> argumentIds,
64-
) async =>
65-
RemoteObject({'type': 'string', 'value': 'true'});
65+
) async {
66+
functionsCalled.add(function);
67+
return RemoteObject({'type': 'string', 'value': 'true'});
68+
}
6669

6770
@override
6871
Future<void> initialize() async => {};
@@ -473,3 +476,7 @@ final fakeWipResponse = WipResponse({
473476
'id': 1,
474477
'result': {'fake': ''},
475478
});
479+
480+
final fakeFailingWipResponse = WipResponse({
481+
'result': 'Error: Bad request',
482+
});

0 commit comments

Comments
 (0)