-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[VM/Service] Correctly forward errors returned by external clients th…
…at handle 'compileExpression' requests TEST=pkg/vm_service/test/forward_compile_expression_error_from_external_client_with_dds_test.dart and pkg/vm_service/test/forward_compile_expression_error_from_external_client_without_dds_test.dart CoreLibraryReviewExempt: This CL does not include any core library API changes, only VM Service implementation changes in sdk/lib/vmservice/running_isolates.dart. Fixes: #59603 Change-Id: I2b9edf69feb6149c80afe9fc753c73e069af0479 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/397580 Reviewed-by: Ben Konyi <[email protected]> Commit-Queue: Derek Xu <[email protected]>
- Loading branch information
Showing
5 changed files
with
126 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
pkg/vm_service/test/forward_compile_expression_error_from_external_client_test_common.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright (c) 2024, 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 'package:test/test.dart'; | ||
import 'package:vm_service/vm_service.dart'; | ||
import 'package:vm_service/vm_service_io.dart' show vmServiceConnectUri; | ||
|
||
import 'common/service_test_common.dart'; | ||
|
||
final tests = <IsolateTest>[ | ||
hasStoppedAtExit, | ||
(VmService primaryClient, IsolateRef isolateRef) async { | ||
const expressionCompilationFailedMessage = 'Expresion compilation failed'; | ||
|
||
final secondaryClient = await vmServiceConnectUri(primaryClient.wsUri!); | ||
secondaryClient.registerServiceCallback('compileExpression', | ||
(params) async { | ||
return { | ||
'jsonrpc': '2.0', | ||
'id': 0, | ||
'error': { | ||
'code': RPCErrorKind.kExpressionCompilationError.code, | ||
'message': expressionCompilationFailedMessage, | ||
'data': {'details': expressionCompilationFailedMessage}, | ||
}, | ||
}; | ||
}); | ||
await secondaryClient.registerService( | ||
'compileExpression', | ||
'Custom Expression Compilation', | ||
); | ||
|
||
final isolateId = isolateRef.id!; | ||
try { | ||
final isolate = await primaryClient.getIsolate(isolateId); | ||
await primaryClient.evaluate(isolateId, isolate.rootLib!.id!, '123'); | ||
fail('Expected to catch an RPCError'); | ||
} on RPCError catch (e) { | ||
expect(e.code, RPCErrorKind.kExpressionCompilationError.code); | ||
// [e.details] used to be the string | ||
// "{code: 113, message: Expresion compilation failed, data: ...}", so we | ||
// want to avoid regressing to that behaviour. | ||
expect(e.details, expressionCompilationFailedMessage); | ||
} | ||
}, | ||
]; |
15 changes: 15 additions & 0 deletions
15
pkg/vm_service/test/forward_compile_expression_error_from_external_client_with_dds_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright (c) 2024, 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. | ||
|
||
// This is a regression test for https://dartbug.com/59603. | ||
|
||
import 'common/test_helper.dart'; | ||
import 'forward_compile_expression_error_from_external_client_test_common.dart'; | ||
|
||
void main([args = const <String>[]]) => runIsolateTests( | ||
args, | ||
tests, | ||
'forward_compile_expression_error_from_external_client_with_dds_test.dart', | ||
pauseOnExit: true, | ||
); |
16 changes: 16 additions & 0 deletions
16
..._service/test/forward_compile_expression_error_from_external_client_without_dds_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright (c) 2024, 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. | ||
|
||
// This is a regression test for https://dartbug.com/59603. | ||
|
||
import 'common/test_helper.dart'; | ||
import 'forward_compile_expression_error_from_external_client_test_common.dart'; | ||
|
||
void main([args = const <String>[]]) => runIsolateTests( | ||
args, | ||
tests, | ||
'forward_compile_expression_error_from_external_client_without_dds_test.dart', | ||
pauseOnExit: true, | ||
extraArgs: ['--no-dds'], | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters