@@ -39,6 +39,7 @@ class VMPlatform extends PlatformPlugin {
39
39
final _compiler = TestCompiler (
40
40
p.join (p.current, '.dart_tool' , 'test' , 'incremental_kernel' ));
41
41
final _closeMemo = AsyncMemoizer <void >();
42
+ final _workingDirectory = Directory .current.uri;
42
43
43
44
@override
44
45
Future <RunnerSuite ?> load (String path, SuitePlatform platform,
@@ -86,7 +87,7 @@ class VMPlatform extends PlatformPlugin {
86
87
await Service .controlWebServer (enable: true , silenceOutput: true );
87
88
var isolateID = Service .getIsolateID (isolate)! ;
88
89
89
- var libraryPath = p. toUri (p. absolute ( path) ).toString ();
90
+ var libraryPath = _absolute ( path).toString ();
90
91
var serverUri = info.serverUri! ;
91
92
client = await vmServiceConnectUri (_wsUriFor (serverUri).toString ());
92
93
var isolateNumber = int .parse (isolateID.split ('/' ).last);
@@ -126,6 +127,12 @@ class VMPlatform extends PlatformPlugin {
126
127
@override
127
128
Future close () => _closeMemo.runOnce (_compiler.dispose);
128
129
130
+ Uri _absolute (String path) {
131
+ final uri = p.toUri (path);
132
+ if (uri.isAbsolute) return uri;
133
+ return _workingDirectory.resolveUri (uri);
134
+ }
135
+
129
136
/// Spawns an isolate and passes it [message] .
130
137
///
131
138
/// This isolate connects an [IsolateChannel] to [message] and sends the
@@ -153,48 +160,48 @@ class VMPlatform extends PlatformPlugin {
153
160
/// isolate.
154
161
Future <Isolate > _spawnKernelIsolate (
155
162
String path, SendPort message, Metadata suiteMetadata) async {
156
- final response =
157
- await _compiler.compile (File (path).absolute.uri, suiteMetadata);
163
+ final response = await _compiler.compile (_absolute (path), suiteMetadata);
158
164
var compiledDill = response.kernelOutputUri? .toFilePath ();
159
165
if (compiledDill == null || response.errorCount > 0 ) {
160
166
throw LoadException (path, response.compilerOutput ?? 'unknown error' );
161
167
}
162
168
return await Isolate .spawnUri (p.toUri (compiledDill), [], message,
163
169
packageConfig: await packageConfigUri, checked: true );
164
170
}
165
- }
166
171
167
- Future <Isolate > _spawnDataIsolate (
168
- String path, SendPort message, Metadata suiteMetadata) async {
169
- return await dart.runInIsolate ('''
172
+ Future <Isolate > _spawnDataIsolate (
173
+ String path, SendPort message, Metadata suiteMetadata) async {
174
+ return await dart.runInIsolate ('''
170
175
${suiteMetadata .languageVersionComment ?? await rootPackageLanguageVersionComment }
171
176
import "dart:isolate";
172
177
import "package:test_core/src/bootstrap/vm.dart";
173
- import "${p . toUri ( p . absolute ( path ) )}" as test;
178
+ import "${_absolute ( path )}" as test;
174
179
void main(_, SendPort sendPort) {
175
180
internalBootstrapVmTest(() => test.main, sendPort);
176
181
}
177
182
''' , message);
178
- }
179
-
180
- Future <Isolate > _spawnPrecompiledIsolate (
181
- String testPath, SendPort message, String precompiledPath) async {
182
- testPath = p.absolute ('${p .join (precompiledPath , testPath )}.vm_test.dart' );
183
- var dillTestpath =
184
- '${testPath .substring (0 , testPath .length - '.dart' .length )}.vm.app.dill' ;
185
- if (await File (dillTestpath).exists ()) {
186
- testPath = dillTestpath;
187
183
}
188
- File ? packageConfig =
189
- File (p.join (precompiledPath, '.dart_tool/package_config.json' ));
190
- if (! (await packageConfig.exists ())) {
191
- packageConfig = File (p.join (precompiledPath, '.packages' ));
184
+
185
+ Future <Isolate > _spawnPrecompiledIsolate (
186
+ String testPath, SendPort message, String precompiledPath) async {
187
+ testPath =
188
+ _absolute ('${p .join (precompiledPath , testPath )}.vm_test.dart' ).path;
189
+ var dillTestpath =
190
+ '${testPath .substring (0 , testPath .length - '.dart' .length )}.vm.app.dill' ;
191
+ if (await File (dillTestpath).exists ()) {
192
+ testPath = dillTestpath;
193
+ }
194
+ File ? packageConfig =
195
+ File (p.join (precompiledPath, '.dart_tool/package_config.json' ));
192
196
if (! (await packageConfig.exists ())) {
193
- packageConfig = null ;
197
+ packageConfig = File (p.join (precompiledPath, '.packages' ));
198
+ if (! (await packageConfig.exists ())) {
199
+ packageConfig = null ;
200
+ }
194
201
}
202
+ return await Isolate .spawnUri (p.toUri (testPath), [], message,
203
+ packageConfig: packageConfig? .uri, checked: true );
195
204
}
196
- return await Isolate .spawnUri (p.toUri (testPath), [], message,
197
- packageConfig: packageConfig? .uri, checked: true );
198
205
}
199
206
200
207
Future <Map <String , dynamic >> _gatherCoverage (Environment environment) async {
0 commit comments