99import 'dart:async' ;
1010import 'dart:convert' ;
1111import 'dart:io' as io;
12+ import 'dart:isolate' as isolate;
1213
1314import 'package:test/test.dart' ;
1415import 'package:vm_service/vm_service.dart' ;
@@ -31,6 +32,11 @@ const Map<String, String> _TESTEE_SPAWN_ENV = {_TESTEE_ENV_KEY: 'true'};
3132
3233late Uri remoteVmServiceUri;
3334
35+ /// Resolves a path as if it was relative to the `test` dir in this package.
36+ Uri resolveTestRelativePath (String relativePath) =>
37+ isolate.Isolate .resolvePackageUriSync (Uri .parse ('package:dds/' ))!
38+ .resolve ('../test/$relativePath ' );
39+
3440Future <io.Process > spawnDartProcess (
3541 String script, {
3642 bool serveObservatory = true ,
@@ -51,7 +57,7 @@ Future<io.Process> spawnDartProcess(
5157 if (disableServiceAuthCodes) '--disable-service-auth-codes' ,
5258 '--write-service-info=$serviceInfoUri ' ,
5359 ...io.Platform .executableArguments,
54- io. Platform .script. resolve (script).toString (),
60+ resolveTestRelativePath (script).toFilePath (),
5561 ];
5662 final process = await io.Process .start (executable, arguments);
5763 if (subscribeToStdio) {
@@ -89,12 +95,8 @@ Future<void> executeUntilNextPause(VmService service) async {
8995}
9096
9197/// Returns the resolved URI to the pre-built devtools app.
92- ///
93- /// The method caller is responsible for providing the relative [prefix] that
94- /// will resolve to the sdk/ directory (e.g. '../../../').
95- Uri devtoolsAppUri ({required String prefix}) {
96- const pathFromSdkDirectory = 'third_party/devtools/web' ;
97- return io.Platform .script.resolve ('$prefix $pathFromSdkDirectory ' );
98+ Uri devtoolsAppUri () {
99+ return resolveTestRelativePath ('../../../third_party/devtools/web' );
98100}
99101
100102bool _isTestee () {
@@ -113,7 +115,7 @@ Uri _getTestUri(String script) {
113115 } else {
114116 // Resolve the script to ensure that test will fail if the provided script
115117 // name doesn't match the actual script.
116- return io. Platform .script. resolve (script);
118+ return resolveTestRelativePath (script);
117119 }
118120}
119121
0 commit comments