[ package:dds ] Fixed expression evaluator expecting a double-nested

'result' from an external 'compileExpression' implementation

Also adds expression evaluation tests for external clients.

Change-Id: Ibc1ee098df1de4d191627cbccb44e24fbcb43adf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/154300
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
This commit is contained in:
Ben Konyi 2020-07-14 00:32:49 +00:00 committed by commit-bot@chromium.org
parent 9460ac3c8d
commit b75df6f268
5 changed files with 97 additions and 2 deletions

View file

@ -1,3 +1,8 @@
# 1.2.3
- Fixed issue where DDS was expecting a client provided implementation of
`compileExpression` to return a response with two layers of `response` objects.
# 1.2.2
- Fixed issue where a `StateError` could be raised within `DartDevelopmentService`

View file

@ -76,7 +76,7 @@ class _ExpressionEvaluator {
return (await externalClient.sendRequest(
'compileExpression',
compileParams,
))['result']['kernelBytes'];
))['kernelBytes'];
} else {
// Fallback to compiling using the kernel service.
return (await dds._vmServiceClient.sendRequest(

View file

@ -3,7 +3,7 @@ description: >-
A library used to spawn the Dart Developer Service, used to communicate with
a Dart VM Service instance.
version: 1.2.2
version: 1.2.3
homepage: https://github.com/dart-lang/sdk/tree/master/pkg/dds

View file

@ -0,0 +1,9 @@
// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:developer';
main() {
debugger();
}

View file

@ -0,0 +1,81 @@
// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:io';
import 'package:dds/dds.dart';
import 'package:test/test.dart';
import 'package:vm_service/vm_service_io.dart';
import 'common/test_helper.dart';
void main() {
group('DDS', () {
Process process;
DartDevelopmentService dds;
setUp(() async {
process =
await spawnDartProcess('external_compilation_service_script.dart');
});
tearDown(() async {
await dds?.shutdown();
process?.kill();
dds = null;
process = null;
});
test('evaluate invokes client provided compileExpression RPC', () async {
dds = await DartDevelopmentService.startDartDevelopmentService(
remoteVmServiceUri,
);
expect(dds.isRunning, true);
final service = await vmServiceConnectUri(dds.wsUri.toString());
await service.registerService(
'compileExpression',
'Custom Expression Compilation',
);
bool invokedCompileExpression = false;
service.registerServiceCallback('compileExpression', (params) async {
invokedCompileExpression = true;
throw 'error';
});
final vm = await service.getVM();
final isolate = await service.getIsolate(vm.isolates.first.id);
try {
await service.evaluate(isolate.id, isolate.libraries.first.id, '1 + 1');
} catch (_) {
// ignore error
}
expect(invokedCompileExpression, true);
});
test('evaluateInFrame invokes client provided compileExpression RPC',
() async {
dds = await DartDevelopmentService.startDartDevelopmentService(
remoteVmServiceUri,
);
expect(dds.isRunning, true);
final service = await vmServiceConnectUri(dds.wsUri.toString());
await service.registerService(
'compileExpression',
'Custom Expression Compilation',
);
bool invokedCompileExpression = false;
service.registerServiceCallback('compileExpression', (params) async {
invokedCompileExpression = true;
throw 'error';
});
final vm = await service.getVM();
final isolate = await service.getIsolate(vm.isolates.first.id);
await service.resume(isolate.id);
try {
await service.evaluateInFrame(isolate.id, 0, '1 + 1');
} catch (_) {
// ignore error
}
expect(invokedCompileExpression, true);
});
});
}