@@ -12,18 +12,26 @@ import 'package:vm_service/vm_service.dart';
1212import 'package:vm_service/vm_service_io.dart' ;
1313
1414void main (List <String > args) async {
15+ // Change to package root so relative paths work in CI
16+ final scriptDir = p.dirname (p.fromUri (Platform .script));
17+ final packageRoot = p.dirname (scriptDir);
18+ Directory .current = packageRoot;
19+
1520 try {
1621 watch.start ();
1722 if (args.isNotEmpty) {
1823 throw ArgumentError ('No command line args are supported' );
1924 }
2025
26+ final packagesPath = findNearestPackageConfigPath ();
2127 final client = await FrontendServerClient .start (
2228 'org-dartlang-root:///$app ' ,
2329 outputDill,
2430 p.join (sdkDir, 'lib' , '_internal' , 'vm_platform_strong.dill' ),
31+ packagesJson: packagesPath ?? '.dart_tool/package_config.json' ,
2532 target: 'vm' ,
26- fileSystemRoots: [p.url.current],
33+ // Use an absolute filesystem root so org-dartlang-root:/// URIs resolve reliably in CI
34+ fileSystemRoots: [Directory .current.path],
2735 fileSystemScheme: 'org-dartlang-root' ,
2836 verbose: true ,
2937 );
@@ -35,10 +43,10 @@ void main(List<String> args) async {
3543 Process appProcess;
3644 final vmServiceCompleter = Completer <VmService >();
3745 appProcess = await Process .start (Platform .resolvedExecutable, [
38- '--enable-vm-service=0 ' ,
46+ '--enable-vm-service' ,
3947 result.dillOutput! ,
4048 ]);
41- final sawHelloWorld = Completer ();
49+ final sawHelloWorld = Completer < void > ();
4250 appProcess.stdout
4351 .transform (utf8.decoder)
4452 .transform (const LineSplitter ())
@@ -52,7 +60,9 @@ void main(List<String> args) async {
5260 )) {
5361 final observatoryUri =
5462 '${line .split (' ' ).last .replaceFirst ('http' , 'ws' )}ws' ;
55- vmServiceCompleter.complete (vmServiceConnectUri (observatoryUri));
63+ if (! vmServiceCompleter.isCompleted) {
64+ vmServiceCompleter.complete (vmServiceConnectUri (observatoryUri));
65+ }
5666 }
5767 });
5868 appProcess.stderr
0 commit comments