Skip to content

Commit

Permalink
[ DDS ] Fix failing tests
Browse files Browse the repository at this point in the history
Fixes failing tests introduced by
https://dart-review.googlesource.com/c/sdk/+/383780.

Change-Id: I700543f4dc6481dd905ffdc44177b009612565d6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384880
Auto-Submit: Ben Konyi <[email protected]>
Commit-Queue: Ben Konyi <[email protected]>
Reviewed-by: Derek Xu <[email protected]>
  • Loading branch information
bkonyi authored and Commit Queue committed Sep 11, 2024
1 parent 6f1887a commit a5cd16c
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 18 deletions.
1 change: 1 addition & 0 deletions pkg/dds/lib/src/dap/adapters/dart_cli_adapter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ class DartCliDebugAdapter extends DartDebugAdapter<DartLaunchRequestArguments,
if (!enableAuthCodes) '--disable-service-auth-codes'
],
'--disable-dart-dev',
'--no-dds',
if (debug && vmServiceInfoFile != null) ...[
'-DSILENT_VM_SERVICE=true',
'--write-service-info=${Uri.file(vmServiceInfoFile.path)}'
Expand Down
28 changes: 17 additions & 11 deletions pkg/dds/test/dap_handler_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,19 @@ import 'package:vm_service/vm_service_io.dart';

import 'common/test_helper.dart';

Future<Isolate> waitForFirstRunnableIsolate(VmService service) async {
VM vm;
do {
vm = await service.getVM();
} while (vm.isolates!.isEmpty);
final isolateId = vm.isolates!.first.id!;
Isolate isolate;
do {
isolate = await service.getIsolate(isolateId);
} while (!isolate.runnable!);
return isolate;
}

void main() {
Process? process;
DartDevelopmentService? dds;
Expand Down Expand Up @@ -116,18 +129,10 @@ void main() {
);
service = await vmServiceConnectUri(dds!.wsUri!.toString());

final isolateRef = (await service.getVM()).isolates!.first;
final isolateId = isolateRef.id!;

// Wait for the isolate to become runnable as `evaluateInFrame` requires
// the isolate to be runnable.
Isolate? isolate;
do {
if (isolate != null) {
await Future.delayed(const Duration(milliseconds: 50));
}
isolate = await service.getIsolate(isolateId);
} while (!isolate.runnable!);
final isolate = await waitForFirstRunnableIsolate(service);
final isolateId = isolate.id!;

// Get the variable for 'myInstance'.
final originalInstanceRef = (await service.evaluateInFrame(
Expand Down Expand Up @@ -173,7 +178,8 @@ void main() {
service = await vmServiceConnectUri(dds!.wsUri!.toString());

// Get the expected isolateId.
final isolateId = (await service.getVM()).isolates!.first.id!;
final isolate = await waitForFirstRunnableIsolate(service);
final isolateId = isolate.id!;

// Ask DAP for all threads.
final threadsResult = await sendDapRequest(Command.threads);
Expand Down
25 changes: 18 additions & 7 deletions pkg/dds/test/external_compilation_service_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,28 @@
// 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:async';
import 'dart:io';

import 'package:dds/dds.dart';
import 'package:test/test.dart';
import 'package:vm_service/vm_service.dart';
import 'package:vm_service/vm_service_io.dart';
import 'common/test_helper.dart';

Future<Isolate> waitForFirstRunnableIsolate(VmService service) async {
VM vm;
do {
vm = await service.getVM();
} while (vm.isolates!.isEmpty);
final isolateId = vm.isolates!.first.id!;
Isolate isolate;
do {
isolate = await service.getIsolate(isolateId);
} while (!isolate.runnable!);
return isolate;
}

void main() {
group('DDS', () {
late Process process;
Expand Down Expand Up @@ -39,8 +54,7 @@ void main() {
invokedCompileExpression = true;
throw 'error';
});
final vm = await service.getVM();
final isolate = await service.getIsolate(vm.isolates!.first.id!);
final isolate = await waitForFirstRunnableIsolate(service);
try {
await service.evaluate(
isolate.id!, isolate.libraries!.first.id!, '1 + 1');
Expand All @@ -66,14 +80,11 @@ void main() {
invokedCompileExpression = true;
throw 'error';
});
final vm = await service.getVM();
final isolate = await service.getIsolate(vm.isolates!.first.id!);
final isolate = await waitForFirstRunnableIsolate(service);
await service.resume(isolate.id!);
try {
await service.evaluateInFrame(isolate.id!, 0, '1 + 1');
} catch (e, st) {
print(e);
print(st);
} catch (_) {
// ignore error
}
expect(invokedCompileExpression, true);
Expand Down

0 comments on commit a5cd16c

Please sign in to comment.