Files
sdk/pkg/vm_service/test/break_on_async_function_test.dart
T
Ben Konyi 7eb95ad901 [ package:vm_service ] Enable recommended_lints for tests
Change-Id: I6e02b29fedcb92a6670665c70f6a9b34a06c5d9d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/335242
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Derek Xu <derekx@google.com>
2023-11-13 19:54:40 +00:00

60 lines
1.5 KiB
Dart

// Copyright (c) 2023, 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';
import 'package:vm_service/vm_service.dart';
import 'common/service_test_common.dart';
import 'common/test_helper.dart';
// AUTOGENERATED START
//
// Update these constants by running:
//
// dart pkg/vm_service/test/update_line_numbers.dart <test.dart>
//
const LINE_A = 21;
// AUTOGENERATED END
/* LINE_A */ Future<String> testFunction() async {
await Future.delayed(Duration(milliseconds: 1));
return 'Done';
}
Future<void> testMain() async {
debugger();
print(await testFunction());
}
final tests = <IsolateTest>[
hasStoppedAtBreakpoint,
// Add breakpoint at the entry of async function
(VmService service, IsolateRef isolateRef) async {
final isolateId = isolateRef.id!;
final isolate = await service.getIsolate(isolateId);
final rootLib =
(await service.getObject(isolateId, isolate.rootLib!.id!)) as Library;
final function =
rootLib.functions!.singleWhere((f) => f.name == 'testFunction');
final bpt = await service.addBreakpointAtEntry(isolateId, function.id!);
print(bpt);
},
resumeIsolate,
hasStoppedAtBreakpoint,
stoppedAtLine(LINE_A),
resumeIsolate,
];
void main(args) => runIsolateTests(
args,
tests,
'break_on_async_function_test.dart',
testeeConcurrent: testMain,
);