mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 00:58:29 +00:00
884cfae2c7
- Convert to google3:/// scheme and call `lookupPackageUris` for setting breakpoints - Return file:/// scheme URIs from DDS Change-Id: If9a541be21f5830ec68dc39eb2f308f7ce90c5fe Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/252782 Reviewed-by: Danny Tuppeny <danny@tuppeny.com> Commit-Queue: Helin Shiah <helinx@google.com> Reviewed-by: Ben Konyi <bkonyi@google.com>
77 lines
2.3 KiB
Dart
77 lines
2.3 KiB
Dart
// Copyright (c) 2021, 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: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';
|
|
|
|
void main() {
|
|
late Process process;
|
|
DartDevelopmentService? dds;
|
|
|
|
setUp(() async {
|
|
process = await spawnDartProcess(
|
|
'get_cached_cpu_samples_script.dart',
|
|
disableServiceAuthCodes: true,
|
|
);
|
|
});
|
|
|
|
tearDown(() async {
|
|
await dds?.shutdown();
|
|
process.kill();
|
|
});
|
|
|
|
test(
|
|
'DDS returns local paths with a converter',
|
|
() async {
|
|
Uri serviceUri = remoteVmServiceUri;
|
|
dds = await DartDevelopmentService.startDartDevelopmentService(
|
|
remoteVmServiceUri,
|
|
uriConverter: (uri) => uri == 'package:test/has_local.dart'
|
|
? '/home/has_local.dart'
|
|
: null,
|
|
);
|
|
serviceUri = dds!.wsUri!;
|
|
expect(dds!.isRunning, true);
|
|
final service = await vmServiceConnectUri(serviceUri.toString());
|
|
|
|
IsolateRef isolate;
|
|
while (true) {
|
|
final vm = await service.getVM();
|
|
if (vm.isolates!.isNotEmpty) {
|
|
isolate = vm.isolates!.first;
|
|
try {
|
|
isolate = await service.getIsolate(isolate.id!);
|
|
if ((isolate as Isolate).runnable!) {
|
|
break;
|
|
}
|
|
} on SentinelException {
|
|
// ignore
|
|
}
|
|
}
|
|
await Future.delayed(const Duration(seconds: 1));
|
|
}
|
|
expect(isolate, isNotNull);
|
|
|
|
final unresolvedUris = <String>[
|
|
'dart:io', // dart:io -> org-dartlang-sdk:///sdk/lib/io/io.dart
|
|
'package:test/has_local.dart', // package:test/test.dart -> file:///has_local.dart
|
|
'package:does_not_exist/does_not_exist.dart', // invalid URI -> null
|
|
];
|
|
var result = await service
|
|
.lookupResolvedPackageUris(isolate.id!, unresolvedUris, local: true);
|
|
|
|
expect(result.uris?[0], 'org-dartlang-sdk:///sdk/lib/io/io.dart');
|
|
expect(result.uris?[1], 'file:///home/has_local.dart');
|
|
expect(result.uris?[2], null);
|
|
},
|
|
timeout: Timeout.none,
|
|
);
|
|
}
|