Skip to content

Commit 4da62ac

Browse files
authored
Add package config URI into VM test entrypoints (#2245)
Towards #2246 This will allow a client of the VM service to evaluate the top level variable and locate the package config used by the test runner. Add a public `testBootstapContents` function in `test_compiler.dart` which centralizes the bootstrap templates. Add an argument for the package config URI and a `VmTestType` which is either "Vm" or "Native". Add the first test case in `test_core`. Add the pub dependency and override for `package:test`, as well as the mono_repo configuration to run unit tests. Other tests for `test_core` code is under the `test` package but should be moved eventually.
1 parent 329c6df commit 4da62ac

File tree

7 files changed

+182
-72
lines changed

7 files changed

+182
-72
lines changed

.github/workflows/dart.yml

+97-25
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

+12-31
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,12 @@ stderr: ${processResult.stderr}''');
299299
if (!file.existsSync()) {
300300
file
301301
..createSync(recursive: true)
302-
..writeAsStringSync(_bootstrapIsolateTestContents(
303-
await absoluteUri(testPath), languageVersionComment));
302+
..writeAsStringSync(testBootstrapContents(
303+
testUri: await absoluteUri(testPath),
304+
languageVersionComment: languageVersionComment,
305+
packageConfigUri: await packageConfigUri,
306+
testType: VmTestType.isolate,
307+
));
304308
}
305309
return file.uri;
306310
}
@@ -316,40 +320,17 @@ stderr: ${processResult.stderr}''');
316320
if (!file.existsSync()) {
317321
file
318322
..createSync(recursive: true)
319-
..writeAsStringSync(_bootstrapNativeTestContents(
320-
await absoluteUri(testPath), languageVersionComment));
323+
..writeAsStringSync(testBootstrapContents(
324+
testUri: await absoluteUri(testPath),
325+
languageVersionComment: languageVersionComment,
326+
packageConfigUri: await packageConfigUri,
327+
testType: VmTestType.process,
328+
));
321329
}
322330
return file.path;
323331
}
324332
}
325333

326-
/// Creates bootstrap file contents for running [testUri] in a VM isolate.
327-
String _bootstrapIsolateTestContents(
328-
Uri testUri, String languageVersionComment) =>
329-
'''
330-
$languageVersionComment
331-
import "dart:isolate";
332-
import "package:test_core/src/bootstrap/vm.dart";
333-
import "$testUri" as test;
334-
void main(_, SendPort sendPort) {
335-
internalBootstrapVmTest(() => test.main, sendPort);
336-
}
337-
''';
338-
339-
/// Creates bootstrap file contents for running [testUri] as a native
340-
/// executable.
341-
String _bootstrapNativeTestContents(
342-
Uri testUri, String languageVersionComment) =>
343-
'''
344-
$languageVersionComment
345-
import "dart:isolate";
346-
import "package:test_core/src/bootstrap/vm.dart";
347-
import "$testUri" as test;
348-
void main(List<String> args) {
349-
internalBootstrapNativeTest(() => test.main, args);
350-
}
351-
''';
352-
353334
Future<Map<String, dynamic>> _gatherCoverage(Environment environment) async {
354335
final isolateId = Uri.parse(environment.observatoryUrl!.fragment)
355336
.queryParameters['isolateId'];

0 commit comments

Comments
 (0)