[test] isVmAotConfiguration in custom configurations take 2

https://dart-review.googlesource.com/c/sdk/+/372260 fixed `dartkp`
invocations, but did not fix `dartk` due to conflicts with the
`dart2analyzer` compiler. (Patchset 3 of that CL.)

Try to land the same heuristic but guarded on if `compiler` is null.

Closes: https://github.com/dart-lang/sdk/issues/56041
Change-Id: Ieba182d74cb0d1d846a3073f1a02ee9f958ef36d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/372360
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
This commit is contained in:
Daco Harkes 2024-06-27 18:31:35 +00:00 committed by Commit Queue
parent 00eac588c2
commit 7958fe1a15
2 changed files with 11 additions and 4 deletions

View file

@ -245,17 +245,17 @@ class Configuration {
nnbdMode ??= NnbdMode.strong;
sanitizer ??= Sanitizer.none;
// Infer runtime from executable.
if (runtime == null) {
// Infer runtime from executable if we don't know runtime and compiler.
if (runtime == null && compiler == null && words.contains("custom")) {
final executableName = Uri.file(Platform.executable)
.pathSegments
.lastWhere((e) => e.isNotEmpty);
final executableNoExtension = executableName.split('.').first;
if (executableNoExtension == 'dart_precompiled_runtime') {
runtime = Runtime.dartPrecompiled;
} else if (executableNoExtension == 'dart') {
runtime = Runtime.vm;
}
// Don't infer anything from the `dart` executable. As multiple runtimes
// use that as executable.
}
// Infer from compiler from runtime or vice versa.

View file

@ -238,6 +238,13 @@ void main() {
'configuration name.');
});
test("custom configuration", () {
final result = Configuration.parse("custom-configuration-1", {});
// Succeeds. Since this test runs in JIT mode, should be dartk and vm.
expect(result.compiler, Compiler.dartk);
expect(result.runtime, Runtime.vm);
});
test("empty string", () {
expectParseError("", {}, 'Name must not be empty.');
});