[Tests] Pass VM options (Platform.executableArguments) to sub-processes

When testing runs with certain set of VM options and tests launch
new Dart processes, VM options should be also forwarded to child
processes.

Change-Id: I7207fe87672cd61fd50d7ac77ef1da67744af183
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/97169
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Reviewed-by: RĂ©gis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
diff --git a/tests/standalone_2/http_launch_test.dart b/tests/standalone_2/http_launch_test.dart
index 9717974..cb97f84 100644
--- a/tests/standalone_2/http_launch_test.dart
+++ b/tests/standalone_2/http_launch_test.dart
@@ -24,6 +24,9 @@
 import 'package:expect/expect.dart';
 
 String pathToExecutable = Platform.executable;
+List<String> executableArguments = Platform.executableArguments
+    .where((arg) => !arg.startsWith('--packages='))
+    .toList();
 Uri pathOfData = Platform.script.resolve('http_launch_data/');
 int port;
 
@@ -50,16 +53,29 @@
 serverRunning(HttpServer server) {
   port = server.port;
   server.listen(handleRequest);
-  Future<ProcessResult> no_http_run = Process.run(pathToExecutable,
-      [pathOfData.resolve('http_launch_main.dart').toFilePath()]);
-  Future<ProcessResult> http_run = Process
-      .run(pathToExecutable, ['http://127.0.0.1:$port/http_launch_main.dart']);
-  Future<ProcessResult> http_pkg_root_run = Process.run(pathToExecutable, [
-    '--package-root=http://127.0.0.1:$port/the_packages/',
-    'http://127.0.0.1:$port/http_launch_main.dart'
-  ]);
-  Future<ProcessResult> isolate_run = Process.run(pathToExecutable,
-      ['http://127.0.0.1:$port/http_spawn_main.dart', '$port']);
+  Future<ProcessResult> no_http_run = Process.run(
+      pathToExecutable,
+      []
+        ..addAll(executableArguments)
+        ..add(pathOfData.resolve('http_launch_main.dart').toFilePath()));
+  Future<ProcessResult> http_run = Process.run(
+      pathToExecutable,
+      []
+        ..addAll(executableArguments)
+        ..add('http://127.0.0.1:$port/http_launch_main.dart'));
+  Future<ProcessResult> http_pkg_root_run = Process.run(
+      pathToExecutable,
+      []
+        ..addAll(executableArguments)
+        ..addAll([
+          '--package-root=http://127.0.0.1:$port/the_packages/',
+          'http://127.0.0.1:$port/http_launch_main.dart'
+        ]));
+  Future<ProcessResult> isolate_run = Process.run(
+      pathToExecutable,
+      []
+        ..addAll(executableArguments)
+        ..addAll(['http://127.0.0.1:$port/http_spawn_main.dart', '$port']));
   Future<List<ProcessResult>> results =
       Future.wait([no_http_run, http_run, http_pkg_root_run, isolate_run]);
   results.then((results) {
diff --git a/tests/standalone_2/io/addlatexhash_test.dart b/tests/standalone_2/io/addlatexhash_test.dart
index 6465852..fe8c166 100755
--- a/tests/standalone_2/io/addlatexhash_test.dart
+++ b/tests/standalone_2/io/addlatexhash_test.dart
@@ -92,7 +92,7 @@
 
   // actions to take
   runAddHash() {
-    var args = packageOptions();
+    var args = <String>[]..addAll(Platform.executableArguments);
     args.addAll([
       path.join(dartRootPath, "tools", "addlatexhash.dart"),
       tmpPar8timesPath,
diff --git a/tests/standalone_2/io/dart_std_io_pipe_test.dart b/tests/standalone_2/io/dart_std_io_pipe_test.dart
index 474e5a8..82ffa31 100644
--- a/tests/standalone_2/io/dart_std_io_pipe_test.dart
+++ b/tests/standalone_2/io/dart_std_io_pipe_test.dart
@@ -39,7 +39,7 @@
   String redirectOutFile = "${dir.path}/redirect";
   String executable = Platform.executable;
   List<String> args = [
-    executable,
+    ([executable]..addAll(Platform.executableArguments)).join(' '),
     dartScript,
     type,
     pipeOutFile,
diff --git a/tests/standalone_2/io/file_read_special_device_test.dart b/tests/standalone_2/io/file_read_special_device_test.dart
index ca6b870..fcfd9cb 100644
--- a/tests/standalone_2/io/file_read_special_device_test.dart
+++ b/tests/standalone_2/io/file_read_special_device_test.dart
@@ -12,7 +12,10 @@
   script = Platform.script.resolve(script).toFilePath();
   var executable = Platform.executable;
   var file = script; // Use script as file.
-  Process.start("bash", ["-c", "$executable $script < $file"]).then((process) {
+  Process.start("bash", [
+    "-c",
+    "$executable ${Platform.executableArguments.join(' ')} $script < $file"
+  ]).then((process) {
     process.exitCode.then((exitCode) {
       Expect.equals(0, exitCode);
     });
diff --git a/tests/standalone_2/io/http_client_stays_alive_test.dart b/tests/standalone_2/io/http_client_stays_alive_test.dart
index 8666bb8..37af33a 100644
--- a/tests/standalone_2/io/http_client_stays_alive_test.dart
+++ b/tests/standalone_2/io/http_client_stays_alive_test.dart
@@ -20,16 +20,6 @@
 const SECONDS = 4;
 const SLACK = 60;
 
-List<String> packageOptions() {
-  if (Platform.packageRoot != null) {
-    return <String>['--package-root=${Platform.packageRoot}'];
-  } else if (Platform.packageConfig != null) {
-    return <String>['--packages=${Platform.packageConfig}'];
-  } else {
-    return <String>[];
-  }
-}
-
 void runServerProcess() {
   asyncStart();
   HttpServer.bind('127.0.0.1', 0).then((server) {
@@ -47,7 +37,10 @@
     var script = Platform.script
         .resolve('http_client_stays_alive_test.dart')
         .toFilePath();
-    var arguments = packageOptions()..add(script)..add(url);
+    var arguments = <String>[]
+      ..addAll(Platform.executableArguments)
+      ..add(script)
+      ..add(url);
     Process.run(Platform.executable, arguments).then((res) {
       subscription.cancel();
       if (res.exitCode != 0) {
diff --git a/tests/standalone_2/io/http_server_close_response_after_error_test.dart b/tests/standalone_2/io/http_server_close_response_after_error_test.dart
index 9230177..eb45423a 100644
--- a/tests/standalone_2/io/http_server_close_response_after_error_test.dart
+++ b/tests/standalone_2/io/http_server_close_response_after_error_test.dart
@@ -20,10 +20,15 @@
         request.response.close();
       });
     });
-    Process.run(Platform.executable, [
-      Platform.script.resolve(CLIENT_SCRIPT).toString(),
-      server.port.toString()
-    ]).then((result) {
+    Process.run(
+            Platform.executable,
+            []
+              ..addAll(Platform.executableArguments)
+              ..addAll([
+                Platform.script.resolve(CLIENT_SCRIPT).toString(),
+                server.port.toString()
+              ]))
+        .then((result) {
       if (result.exitCode != 0) throw "Bad exit code";
       server.close();
     });
diff --git a/tests/standalone_2/io/https_unauthorized_test.dart b/tests/standalone_2/io/https_unauthorized_test.dart
index 2952afd..ea172be 100644
--- a/tests/standalone_2/io/https_unauthorized_test.dart
+++ b/tests/standalone_2/io/https_unauthorized_test.dart
@@ -31,8 +31,7 @@
   ..setTrustedCertificates(localFile('certificates/trusted_certs.pem'));
 
 Future<HttpServer> runServer() {
-  return HttpServer
-      .bindSecure(HOST_NAME, 0, untrustedServerContext, backlog: 5)
+  return HttpServer.bindSecure(HOST_NAME, 0, untrustedServerContext, backlog: 5)
       .then((server) {
     server.listen((HttpRequest request) {
       request.listen((_) {}, onDone: () {
@@ -48,9 +47,12 @@
 void main() {
   var clientScript = localFile('https_unauthorized_client.dart');
   Future clientProcess(int port) {
-    return Process
-        .run(Platform.executable, [clientScript, port.toString()]).then(
-            (ProcessResult result) {
+    return Process.run(
+            Platform.executable,
+            []
+              ..addAll(Platform.executableArguments)
+              ..addAll([clientScript, port.toString()]))
+        .then((ProcessResult result) {
       if (result.exitCode != 0 || !result.stdout.contains('SUCCESS')) {
         print("Client failed");
         print("  stdout:");
diff --git a/tests/standalone_2/io/named_pipe_script_test.dart b/tests/standalone_2/io/named_pipe_script_test.dart
index 8232581..932b46c 100644
--- a/tests/standalone_2/io/named_pipe_script_test.dart
+++ b/tests/standalone_2/io/named_pipe_script_test.dart
@@ -30,7 +30,11 @@
   }
 
   StringBuffer output = new StringBuffer();
-  Process process = await Process.start(Platform.executable, [stdinPipePath]);
+  Process process = await Process.start(
+      Platform.executable,
+      []
+        ..addAll(Platform.executableArguments)
+        ..add(stdinPipePath));
   bool stdinWriteFailed = false;
   process.stdout.transform(utf8.decoder).listen(output.write);
   process.stderr.transform(utf8.decoder).listen((data) {
diff --git a/tests/standalone_2/io/namespace_test.dart b/tests/standalone_2/io/namespace_test.dart
index 73ab607..601278f 100644
--- a/tests/standalone_2/io/namespace_test.dart
+++ b/tests/standalone_2/io/namespace_test.dart
@@ -180,16 +180,6 @@
   Expect.equals(FileSystemEntityType.directory, dirstat.type);
 }
 
-List<String> packageOptions() {
-  if (Platform.packageRoot != null) {
-    return <String>["--package-root=${Platform.packageRoot}"];
-  } else if (Platform.packageConfig != null) {
-    return <String>["--packages=${Platform.packageConfig}"];
-  } else {
-    return <String>[];
-  }
-}
-
 void setupTest() {
   // Create a namespace in /tmp.
   Directory namespace = Directory.systemTemp.createTempSync("namespace");
@@ -202,7 +192,7 @@
       ..writeAsStringSync(file1str);
 
     // Run the test and capture stdout.
-    var args = packageOptions();
+    var args = <String>[]..addAll(Platform.executableArguments);
     args.addAll([
       "--namespace=${namespace.path}",
       Platform.script.toFilePath(),
diff --git a/tests/standalone_2/io/print_sync_test.dart b/tests/standalone_2/io/print_sync_test.dart
index c195431..c23df59 100644
--- a/tests/standalone_2/io/print_sync_test.dart
+++ b/tests/standalone_2/io/print_sync_test.dart
@@ -11,9 +11,13 @@
 
 void main() {
   asyncStart();
-  Process.run(Platform.executable, [
-    Platform.script.resolve('print_sync_script.dart').toFilePath()
-  ]).then((out) {
+  Process.run(
+          Platform.executable,
+          []
+            ..addAll(Platform.executableArguments)
+            ..add(
+                Platform.script.resolve('print_sync_script.dart').toFilePath()))
+      .then((out) {
     asyncEnd();
     Expect.equals(1002, out.stdout.split('\n').length);
   });
diff --git a/tests/standalone_2/io/process_check_arguments_test.dart b/tests/standalone_2/io/process_check_arguments_test.dart
index d0e2c9b..c79c00e 100644
--- a/tests/standalone_2/io/process_check_arguments_test.dart
+++ b/tests/standalone_2/io/process_check_arguments_test.dart
@@ -7,7 +7,8 @@
 import "process_test_util.dart";
 
 test(args) {
-  var future = Process.start(Platform.executable, args);
+  var future = Process.start(Platform.executable,
+      []..addAll(Platform.executableArguments)..addAll(args));
   future.then((process) {
     process.exitCode.then((exitCode) {
       Expect.equals(0, exitCode);
diff --git a/tests/standalone_2/io/process_detached_test.dart b/tests/standalone_2/io/process_detached_test.dart
index ee093b3..b6b59e7 100644
--- a/tests/standalone_2/io/process_detached_test.dart
+++ b/tests/standalone_2/io/process_detached_test.dart
@@ -18,7 +18,11 @@
   asyncStart();
   var script =
       Platform.script.resolve('process_detached_script.dart').toFilePath();
-  var future = Process.start(Platform.executable, [script],
+  var future = Process.start(
+      Platform.executable,
+      []
+        ..addAll(Platform.executableArguments)
+        ..add(script),
       mode: ProcessStartMode.detached);
   future.then((process) {
     Expect.isNotNull(process.pid);
@@ -37,7 +41,8 @@
   asyncStart();
   var script =
       Platform.script.resolve('process_detached_script.dart').toFilePath();
-  var future = Process.start(Platform.executable, [script, 'echo'],
+  var future = Process.start(Platform.executable,
+      []..addAll(Platform.executableArguments)..addAll([script, 'echo']),
       mode: ProcessStartMode.detachedWithStdio);
   future.then((process) {
     Expect.isNotNull(process.pid);
diff --git a/tests/standalone_2/io/process_environment_test.dart b/tests/standalone_2/io/process_environment_test.dart
index dd656b2..ca56130 100644
--- a/tests/standalone_2/io/process_environment_test.dart
+++ b/tests/standalone_2/io/process_environment_test.dart
@@ -16,8 +16,8 @@
   if (!new File(printEnv).existsSync()) {
     printEnv = '../$printEnv';
   }
-  Process
-      .run(dartExecutable, [printEnv, name],
+  Process.run(dartExecutable,
+          []..addAll(Platform.executableArguments)..addAll([printEnv, name]),
           environment: environment, includeParentEnvironment: includeParent)
       .then((result) {
     if (result.exitCode != 0) {
diff --git a/tests/standalone_2/io/process_inherit_stdio_test.dart b/tests/standalone_2/io/process_inherit_stdio_test.dart
index 090132a..964440f 100644
--- a/tests/standalone_2/io/process_inherit_stdio_test.dart
+++ b/tests/standalone_2/io/process_inherit_stdio_test.dart
@@ -22,7 +22,8 @@
   // of the process spawned here, we should see it.
   var script =
       Platform.script.resolve('process_inherit_stdio_script.dart').toFilePath();
-  var future = Process.start(Platform.executable, [script, "foo"]);
+  var future = Process.start(Platform.executable,
+      []..addAll(Platform.executableArguments)..addAll([script, "foo"]));
   Completer<String> s = new Completer();
   future.then((process) {
     StringBuffer buf = new StringBuffer();
diff --git a/tests/standalone_2/io/process_non_ascii_test.dart b/tests/standalone_2/io/process_non_ascii_test.dart
index 0f1a592..fd08f06 100644
--- a/tests/standalone_2/io/process_non_ascii_test.dart
+++ b/tests/standalone_2/io/process_non_ascii_test.dart
@@ -28,7 +28,11 @@
   var script = nonAsciiFile.path;
   // Note: we prevent this child process from using Crashpad handler because
   // this introduces an issue with deleting the temporary directory.
-  Process.run(executable, [script],
+  Process.run(
+      executable,
+      []
+        ..addAll(Platform.executableArguments)
+        ..add(script),
       workingDirectory: nonAsciiDir.path,
       environment: {'DART_CRASHPAD_HANDLER': ''}).then((result) {
     Expect.equals(0, result.exitCode);
diff --git a/tests/standalone_2/io/process_run_output_test.dart b/tests/standalone_2/io/process_run_output_test.dart
index e5466c2..11b111a 100644
--- a/tests/standalone_2/io/process_run_output_test.dart
+++ b/tests/standalone_2/io/process_run_output_test.dart
@@ -35,20 +35,18 @@
     enc = null;
   }
 
+  var args = <String>[]
+    ..addAll(Platform.executableArguments)
+    ..addAll([scriptFile, encoding, stream]);
+
   if (stream == 'stdout') {
-    Process
-        .run(Platform.executable, [scriptFile, encoding, stream],
-            stdoutEncoding: enc)
-        .then((result) {
+    Process.run(Platform.executable, args, stdoutEncoding: enc).then((result) {
       Expect.equals(result.exitCode, 0);
       Expect.equals(result.stderr, '');
       checkOutput(encoding, result.stdout);
     });
   } else {
-    Process
-        .run(Platform.executable, [scriptFile, encoding, stream],
-            stderrEncoding: enc)
-        .then((result) {
+    Process.run(Platform.executable, args, stderrEncoding: enc).then((result) {
       Expect.equals(result.exitCode, 0);
       Expect.equals(result.stdout, '');
       checkOutput(encoding, result.stderr);
diff --git a/tests/standalone_2/io/process_set_exit_code_test.dart b/tests/standalone_2/io/process_set_exit_code_test.dart
index e8d9e45..b8c7e12 100644
--- a/tests/standalone_2/io/process_set_exit_code_test.dart
+++ b/tests/standalone_2/io/process_set_exit_code_test.dart
@@ -16,7 +16,12 @@
   var executable = Platform.executable;
   var exitCodeScript =
       Platform.script.resolve('process_set_exit_code_script.dart').toFilePath();
-  Process.run(executable, [exitCodeScript]).then((result) {
+  Process.run(
+          executable,
+          []
+            ..addAll(Platform.executableArguments)
+            ..add(exitCodeScript))
+      .then((result) {
     Expect.equals("standard out", result.stdout);
     Expect.equals("standard error", result.stderr);
     Expect.equals(25, result.exitCode);
diff --git a/tests/standalone_2/io/process_shell_test.dart b/tests/standalone_2/io/process_shell_test.dart
index e9113d8..5c766b0 100644
--- a/tests/standalone_2/io/process_shell_test.dart
+++ b/tests/standalone_2/io/process_shell_test.dart
@@ -14,8 +14,13 @@
   test(args) {
     asyncStart();
     var script = Platform.script.resolve("process_echo_util.dart").toFilePath();
-    Process
-        .run(Platform.executable, [script]..addAll(args), runInShell: true)
+    Process.run(
+            Platform.executable,
+            []
+              ..addAll(Platform.executableArguments)
+              ..add(script)
+              ..addAll(args),
+            runInShell: true)
         .then((process_result) {
       var result;
       if (Platform.operatingSystem == "windows") {
diff --git a/tests/standalone_2/io/process_stderr_test.dart b/tests/standalone_2/io/process_stderr_test.dart
index 3ea157a..0492fe2 100644
--- a/tests/standalone_2/io/process_stderr_test.dart
+++ b/tests/standalone_2/io/process_stderr_test.dart
@@ -67,5 +67,11 @@
         new File("../tests/standalone_2/io/process_std_io_script.dart");
   }
   Expect.isTrue(scriptFile.existsSync());
-  test(Process.start(Platform.executable, [scriptFile.path, "1"]), 0);
+  test(
+      Process.start(
+          Platform.executable,
+          []
+            ..addAll(Platform.executableArguments)
+            ..addAll([scriptFile.path, "1"])),
+      0);
 }
diff --git a/tests/standalone_2/io/process_stdin_transform_unsubscribe_test.dart b/tests/standalone_2/io/process_stdin_transform_unsubscribe_test.dart
index f52f9e0..fa36a06 100644
--- a/tests/standalone_2/io/process_stdin_transform_unsubscribe_test.dart
+++ b/tests/standalone_2/io/process_stdin_transform_unsubscribe_test.dart
@@ -38,5 +38,11 @@
     scriptFile = new File("../tests/standalone_2/io/$scriptName");
   }
   Expect.isTrue(scriptFile.existsSync());
-  test(Process.start(Platform.executable, [scriptFile.path]), 0);
+  test(
+      Process.start(
+          Platform.executable,
+          []
+            ..addAll(Platform.executableArguments)
+            ..add(scriptFile.path)),
+      0);
 }
diff --git a/tests/standalone_2/io/process_stdout_test.dart b/tests/standalone_2/io/process_stdout_test.dart
index d492996..7d3bc7f 100644
--- a/tests/standalone_2/io/process_stdout_test.dart
+++ b/tests/standalone_2/io/process_stdout_test.dart
@@ -65,5 +65,11 @@
         new File("../tests/standalone_2/io/process_std_io_script.dart");
   }
   Expect.isTrue(scriptFile.existsSync());
-  test(Process.start(Platform.executable, [scriptFile.path, "0"]), 0);
+  test(
+      Process.start(
+          Platform.executable,
+          []
+            ..addAll(Platform.executableArguments)
+            ..addAll([scriptFile.path, "0"])),
+      0);
 }
diff --git a/tests/standalone_2/io/process_sync_test.dart b/tests/standalone_2/io/process_sync_test.dart
index e4fc82a..1d91dfc 100644
--- a/tests/standalone_2/io/process_sync_test.dart
+++ b/tests/standalone_2/io/process_sync_test.dart
@@ -13,13 +13,15 @@
   // Get the Dart script file that generates output.
   var scriptFile = new File(
       Platform.script.resolve("process_sync_script.dart").toFilePath());
-  var args = [
-    scriptFile.path,
-    blockCount.toString(),
-    stdoutBlockSize.toString(),
-    stderrBlockSize.toString(),
-    exitCode.toString()
-  ];
+  var args = <String>[]
+    ..addAll(Platform.executableArguments)
+    ..addAll([
+      scriptFile.path,
+      blockCount.toString(),
+      stdoutBlockSize.toString(),
+      stderrBlockSize.toString(),
+      exitCode.toString()
+    ]);
   ProcessResult syncResult = Process.runSync(Platform.executable, args);
   Expect.equals(blockCount * stdoutBlockSize, syncResult.stdout.length);
   Expect.equals(blockCount * stderrBlockSize, syncResult.stderr.length);
diff --git a/tests/standalone_2/io/regress_7191_test.dart b/tests/standalone_2/io/regress_7191_test.dart
index a68a800..8477956 100644
--- a/tests/standalone_2/io/regress_7191_test.dart
+++ b/tests/standalone_2/io/regress_7191_test.dart
@@ -21,7 +21,12 @@
   asyncStart();
   var executable = Platform.executable;
   var script = Platform.script.resolve('regress_7191_script.dart').toFilePath();
-  Process.start(executable, [script]).then((process) {
+  Process.start(
+          executable,
+          []
+            ..addAll(Platform.executableArguments)
+            ..add(script))
+      .then((process) {
     process.stdin.add([0]);
     process.stdout.listen((_) {}, onDone: () {
       process.stdin.add([0]);
diff --git a/tests/standalone_2/io/regress_7679_test.dart b/tests/standalone_2/io/regress_7679_test.dart
index 3577a8b..720e607 100644
--- a/tests/standalone_2/io/regress_7679_test.dart
+++ b/tests/standalone_2/io/regress_7679_test.dart
@@ -37,7 +37,11 @@
   String executable = new File(Platform.executable).resolveSymbolicLinksSync();
   // Note: we prevent this child process from using Crashpad handler because
   // this introduces an issue with deleting the temporary directory.
-  Process.run(executable, ['script.dart'],
+  Process.run(
+      executable,
+      []
+        ..addAll(Platform.executableArguments)
+        ..add('script.dart'),
       workingDirectory: temp.path,
       environment: {'DART_CRASHPAD_HANDLER': ''}).then((result) {
     temp.deleteSync(recursive: true);
diff --git a/tests/standalone_2/io/signals_test.dart b/tests/standalone_2/io/signals_test.dart
index 79e0ddf..13e0448 100644
--- a/tests/standalone_2/io/signals_test.dart
+++ b/tests/standalone_2/io/signals_test.dart
@@ -16,11 +16,16 @@
   if (usr1Send == null) usr1Send = usr1Expect;
   if (usr2Send == null) usr2Send = usr2Expect;
   asyncStart();
-  Process.start(Platform.executable, [
-    Platform.script.resolve('signals_test_script.dart').toFilePath(),
-    usr1Expect.toString(),
-    usr2Expect.toString()
-  ]).then((process) {
+  Process.start(
+          Platform.executable,
+          []
+            ..addAll(Platform.executableArguments)
+            ..addAll([
+              Platform.script.resolve('signals_test_script.dart').toFilePath(),
+              usr1Expect.toString(),
+              usr2Expect.toString()
+            ]))
+      .then((process) {
     process.stdin.close();
     process.stderr.drain();
     int v = 0;
@@ -45,10 +50,15 @@
 
 void testSignal(ProcessSignal signal) {
   asyncStart();
-  Process.start(Platform.executable, [
-    Platform.script.resolve('signal_test_script.dart').toFilePath(),
-    signal.toString()
-  ]).then((process) {
+  Process.start(
+          Platform.executable,
+          []
+            ..addAll(Platform.executableArguments)
+            ..addAll([
+              Platform.script.resolve('signal_test_script.dart').toFilePath(),
+              signal.toString()
+            ]))
+      .then((process) {
     process.stdin.close();
     process.stderr.drain();
 
@@ -71,10 +81,13 @@
 void testMultipleSignals(List<ProcessSignal> signals) {
   for (var signal in signals) {
     asyncStart();
-    Process
-        .start(
+    Process.start(
             Platform.executable,
-            [Platform.script.resolve('signal_test_script.dart').toFilePath()]
+            []
+              ..addAll(Platform.executableArguments)
+              ..add(Platform.script
+                  .resolve('signal_test_script.dart')
+                  .toFilePath())
               ..addAll(signals.map((s) => s.toString())))
         .then((process) {
       process.stdin.close();
diff --git a/tests/standalone_2/io/skipping_dart2js_compilations_test.dart b/tests/standalone_2/io/skipping_dart2js_compilations_test.dart
index 96649d1..4ddd934 100644
--- a/tests/standalone_2/io/skipping_dart2js_compilations_test.dart
+++ b/tests/standalone_2/io/skipping_dart2js_compilations_test.dart
@@ -148,7 +148,10 @@
       .resolve('skipping_dart2js_compilations_helper.dart')
       .toFilePath();
   var executable = Platform.executable;
-  var arguments = [createFileScript, fileUtils.scriptOutputPath.toNativePath()];
+  var arguments = <String>[]
+    ..addAll(Platform.executableArguments)
+    ..add(createFileScript)
+    ..add(fileUtils.scriptOutputPath.toNativePath());
   var bootstrapDeps = [Uri.parse("file://${fileUtils.testSnapshotFilePath}")];
   return Command.compilation('dart2js', fileUtils.testJsFilePath.toNativePath(),
       bootstrapDeps, executable, arguments, {},
diff --git a/tests/standalone_2/io/stdin_sync_test.dart b/tests/standalone_2/io/stdin_sync_test.dart
index 431f735..30f1e33 100644
--- a/tests/standalone_2/io/stdin_sync_test.dart
+++ b/tests/standalone_2/io/stdin_sync_test.dart
@@ -13,8 +13,12 @@
 void testReadByte() {
   void test(String line, List<String> expected) {
     var script = Platform.script.resolve("stdin_sync_script.dart").toFilePath();
-    Process
-        .start(Platform.executable, [script]..addAll(expected.map(json.encode)))
+    Process.start(
+            Platform.executable,
+            []
+              ..addAll(Platform.executableArguments)
+              ..add(script)
+              ..addAll(expected.map(json.encode)))
         .then((process) {
       process.stdin.write(line);
       process.stdin.flush().then((_) => process.stdin.close());
diff --git a/tests/standalone_2/io/stdio_implicit_close_test.dart b/tests/standalone_2/io/stdio_implicit_close_test.dart
index 0df0e04..f283417 100644
--- a/tests/standalone_2/io/stdio_implicit_close_test.dart
+++ b/tests/standalone_2/io/stdio_implicit_close_test.dart
@@ -13,15 +13,14 @@
   var scriptFile = "stdio_implicit_close_script.dart";
   var script = Platform.script.resolve(scriptFile).toFilePath();
 
-  var arguments = [
-    script,
-  ];
+  var arguments = <String>[]
+    ..addAll(Platform.executableArguments)
+    ..add(script);
   if (closeStdout) arguments.add("stdout");
   if (closeStderr) arguments.add("stderr");
 
   asyncStart();
-  Process
-      .run(Platform.executable, arguments,
+  Process.run(Platform.executable, arguments,
           stdoutEncoding: ascii, stderrEncoding: ascii)
       .then((result) {
     print(result.stdout);
diff --git a/tests/standalone_2/io/stdio_nonblocking_test.dart b/tests/standalone_2/io/stdio_nonblocking_test.dart
index b344a0c..1eab14e 100644
--- a/tests/standalone_2/io/stdio_nonblocking_test.dart
+++ b/tests/standalone_2/io/stdio_nonblocking_test.dart
@@ -12,9 +12,13 @@
 void main() {
   var script =
       Platform.script.resolve("stdio_nonblocking_script.dart").toFilePath();
-  Process
-      .run(Platform.executable, [script],
-          stdoutEncoding: ascii, stderrEncoding: ascii)
+  Process.run(
+          Platform.executable,
+          []
+            ..addAll(Platform.executableArguments)
+            ..add(script),
+          stdoutEncoding: ascii,
+          stderrEncoding: ascii)
       .then((result) {
     print(result.stdout);
     print(result.stderr);