Skip to content

Commit

Permalink
Add retry test.
Browse files Browse the repository at this point in the history
  • Loading branch information
natebiggs committed Dec 20, 2024
1 parent b9241e0 commit 34aa5f5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
20 changes: 18 additions & 2 deletions dwds/test/expression_evaluator_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import 'package:dwds/src/debugging/location.dart';
import 'package:dwds/src/debugging/skip_list.dart';
import 'package:dwds/src/services/batched_expression_evaluator.dart';
import 'package:dwds/src/services/expression_evaluator.dart';
import 'package:dwds/src/utilities/shared.dart';

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

late StreamController<DebuggerPausedEvent> pausedController;
late StreamController<Event> debugEventController;
late FakeInspector inspector;
setUp(() async {
final assetReader = FakeAssetReader(sourceMap: '');
final toolConfiguration = TestToolConfiguration.withLoadStrategy(
Expand Down Expand Up @@ -64,8 +66,7 @@ void main() async {
skipLists,
root,
);
final inspector =
FakeInspector(webkitDebugger, fakeIsolate: simpleIsolate);
inspector = FakeInspector(webkitDebugger, fakeIsolate: simpleIsolate);
debugger.updateInspector(inspector);

_evaluator = ExpressionEvaluator(
Expand Down Expand Up @@ -192,6 +193,21 @@ void main() async {
);
});

test('retries failed batched expression', () async {
safeUnawaited(
evaluator.evaluateExpression('2', 'main.dart', 'true', {}),
);

await evaluator.evaluateExpression('2', 'main.dart', 'false', {});
expect(inspector.functionsCalled.length, 3);
expect(
inspector.functionsCalled[0].contains('return [ true, false ];'),
true,
);
expect(inspector.functionsCalled[1].contains('return true;'), true);
expect(inspector.functionsCalled[2].contains('return false;'), true);
});

test('returns error if closed', () async {
evaluator.close();
final result =
Expand Down
11 changes: 9 additions & 2 deletions dwds/test/fixtures/fakes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ Isolate get simpleIsolate => Isolate(

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

Isolate fakeIsolate;
Expand All @@ -61,8 +62,10 @@ class FakeInspector implements AppInspector {
Future<RemoteObject> callFunction(
String function,
Iterable<String> argumentIds,
) async =>
RemoteObject({'type': 'string', 'value': 'true'});
) async {
functionsCalled.add(function);
return RemoteObject({'type': 'string', 'value': 'true'});
}

@override
Future<void> initialize() async => {};
Expand Down Expand Up @@ -473,3 +476,7 @@ final fakeWipResponse = WipResponse({
'id': 1,
'result': {'fake': ''},
});

final fakeFailingWipResponse = WipResponse({
'result': 'Error: Bad request',
});

0 comments on commit 34aa5f5

Please sign in to comment.