mirror of
https://github.com/dart-lang/sdk
synced 2024-09-15 22:59:47 +00:00
[ 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:
parent
9460ac3c8d
commit
b75df6f268
|
@ -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`
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
9
pkg/dds/test/external_compilation_service_script.dart
Normal file
9
pkg/dds/test/external_compilation_service_script.dart
Normal 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();
|
||||
}
|
81
pkg/dds/test/external_compilation_service_test.dart
Normal file
81
pkg/dds/test/external_compilation_service_test.dart
Normal 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);
|
||||
});
|
||||
});
|
||||
}
|
Loading…
Reference in a new issue