Skip to content

Commit 001c538

Browse files
authored
fix precompiled vm tests loaded from a package: uri (#2152)
1 parent fb3b572 commit 001c538

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

pkgs/test_core/lib/src/runner/vm/platform.dart

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -254,24 +254,26 @@ stderr: ${processResult.stderr}''');
254254

255255
Future<Isolate> _spawnPrecompiledIsolate(String testPath, SendPort message,
256256
String precompiledPath, Compiler compiler) async {
257-
testPath =
258-
(await absoluteUri('${p.join(precompiledPath, testPath)}.vm_test.dart'))
259-
.path
260-
.stripDriveLetterLeadingSlash;
257+
var testUri =
258+
await absoluteUri('${p.join(precompiledPath, testPath)}.vm_test.dart');
259+
testUri = testUri.replace(path: testUri.path.stripDriveLetterLeadingSlash);
260+
261261
switch (compiler) {
262262
case Compiler.kernel:
263-
var dillTestpath =
264-
'${testPath.substring(0, testPath.length - '.dart'.length)}'
265-
'.vm.app.dill';
266-
if (await File(dillTestpath).exists()) {
267-
testPath = dillTestpath;
263+
// Load `.dill` files from their absolute file path.
264+
var dillUri = (await Isolate.resolvePackageUri(testUri.replace(
265+
path:
266+
'${testUri.path.substring(0, testUri.path.length - '.dart'.length)}'
267+
'.vm.app.dill')))!;
268+
if (await File.fromUri(dillUri).exists()) {
269+
testUri = dillUri;
268270
}
269271
// TODO: Compile to kernel manually here? Otherwise we aren't compiling
270272
// with kernel when we technically should be, based on the compiler
271273
// setting.
272274
break;
273275
case Compiler.source:
274-
// Just leave test path as is.
276+
// Just leave test uri as is.
275277
break;
276278
default:
277279
throw StateError('Unsupported compiler for the VM platform $compiler.');
@@ -284,7 +286,7 @@ stderr: ${processResult.stderr}''');
284286
packageConfig = null;
285287
}
286288
}
287-
return await Isolate.spawnUri(p.toUri(testPath), [], message,
289+
return await Isolate.spawnUri(testUri, [], message,
288290
packageConfig: packageConfig?.uri, checked: true);
289291
}
290292

0 commit comments

Comments
 (0)