Parse and accumulate VM options only for the 'run' and 'test' commands.

TEST=ci

Change-Id: I50a4c7e12d5b212723ce6b17e0c1882b172a3a7d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/437128
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
This commit is contained in:
asiva
2025-06-27 10:01:02 -07:00
committed by Commit Queue
parent 593da80b8b
commit b0838eac58
4 changed files with 33 additions and 9 deletions
@@ -77,10 +77,18 @@ void defineLanguageServerTests() {
return runWithLsp(['language-server', '--use-aot-snapshot']);
});
test('--use-aot-snapshot --enable-experiment=foo', () async {
return runWithLsp(['language-server', '--use-aot-snapshot', '--enable-experiment=foo']);
});
test('--no-use-aot-snapshot', () async {
return runWithLsp(['language-server', '--no-use-aot-snapshot']);
});
test('--no-use-aot-snapshot --enable-experiment=foo', () async {
return runWithLsp(['language-server', '--no-use-aot-snapshot', '--enable-experiment=foo']);
});
test('protocol analyzer', () async {
project = utils.project();
+6
View File
@@ -81,6 +81,12 @@ bool DartDevIsolate::ShouldParseCommand(const char* script_uri) {
(strncmp(script_uri, "google3://", 10) != 0)));
}
bool DartDevIsolate::ShouldParseVMOptions(const char* command) {
// If command is 'run' or 'test' parse the VM options as we need to pass
// it down to the VM that executes these commands.
return (strcmp(command, "run") == 0) || (strcmp(command, "test") == 0);
}
CStringUniquePtr DartDevIsolate::TryResolveArtifactPath(const char* filename) {
auto try_resolve_path = [&](CStringUniquePtr dir_prefix) {
// First assume we're in dart-sdk/bin.
+5
View File
@@ -36,6 +36,11 @@ class DartDevIsolate {
// not an HTTP resource.
static bool ShouldParseCommand(const char* script_uri);
// Returns true if VM options need to be recorded and passed to the VM
// that executes the command (this is true only for dart CL commands like
// 'run' and 'test'.
static bool ShouldParseVMOptions(const char* command);
static void set_should_run_dart_dev(bool enable) {
should_run_dart_dev_ = enable;
}
+14 -9
View File
@@ -719,11 +719,14 @@ bool Options::ParseArguments(int argc,
ASSERT(i == argc);
return true;
}
#endif // !defined(DART_PRECOMPILED_RUNTIME)
// If running with dartdev, attempt to parse VM flags which are part of the
// dartdev command (e.g., --enable-vm-service, --observe, etc).
if (!run_script) {
bool record_vm_options = false;
if ((i < argc) && DartDevIsolate::ShouldParseVMOptions(argv[i])) {
record_vm_options = true;
}
if (!run_script && record_vm_options) {
// Skip the command.
int tmp_i = i + 1;
while (tmp_i < argc) {
@@ -736,14 +739,9 @@ bool Options::ParseArguments(int argc,
OptionProcessor::TryProcess(argv[tmp_i], vm_options);
tmp_i++;
}
#if !defined(DART_PRECOMPILED_RUNTIME)
if (Options::disable_dart_dev()) {
Syslog::PrintErr(
"Attempted to use --disable-dart-dev with a Dart CLI command.\n");
Platform::Exit(kErrorExitCode);
}
#endif // !defined(DART_PRECOMIPLED_RUNTIME)
}
#endif // !defined(DART_PRECOMPILED_RUNTIME)
bool first_option = true;
// Parse out options to be passed to dart main.
while (i < argc) {
@@ -754,6 +752,13 @@ bool Options::ParseArguments(int argc,
!IsOption(argv[i], "enable-vm-service")) {
dart_options->AddArgument(argv[i]);
}
#if !defined(DART_PRECOMPILED_RUNTIME)
if (IsOption(argv[i], "disable-dart-dev")) {
Syslog::PrintErr(
"Attempted to use --disable-dart-dev with a Dart CLI command.\n");
Platform::Exit(kErrorExitCode);
}
#endif // !defined(DART_PRECOMIPLED_RUNTIME)
i++;
// Add DDS specific flags immediately after the dartdev command.
if (first_option) {