@@ -390,6 +390,27 @@ def main() : int {
390390 // Without this, the post-`--` slice in the child loses --headless and any
391391 // playwright/harness that depends on it reverts to windowed mode.
392392 let headlessFlag = find_index (raw_args , "--headless" ) > = 0 ? " --headless" : ""
393+ // Preserve EVERY pre-`--` arg (daslang flags + script path), not just
394+ // raw_args[0..1]. With raw_args = [daslang, -load_module, <path>,
395+ // dastest.das, --, ...], the old "raw_args[0] raw_args[1]" reconstruction
396+ // produced "daslang -load_module" — losing the flag value, breaking
397+ // local runs that point dastest at an external module via -load_module.
398+ // Find index of `--` ≥ 0 always (dastest was invoked with `--` to receive
399+ // its own args); fall back to all raw_args if not, matching the old
400+ // 2-arg implicit assumption. Quote any arg containing a space so paths
401+ // like `C:/Program Files/...` survive popen's shell-split on the other
402+ // side; both cmd.exe and /bin/sh honor double-quote-wrapped args.
403+ let dashdash = find_index (raw_args , "--" )
404+ let launchPrefix = build_string () $ (var w ) {
405+ let n = dashdash > 0 ? dashdash : length (raw_args )
406+ for (i in range (n )) {
407+ if (i > 0 ) w | > write (" " )
408+ let needs_quote = raw_args [i ] | > contains (" " )
409+ if (needs_quote ) w | > write ("\" " )
410+ w | > write (raw_args [i ])
411+ if (needs_quote ) w | > write ("\" " )
412+ }
413+ }
393414 log::info ("Running { totalFiles } tests in isolated mode with { totalThreads } threads\n " )
394415 with_channel (totalFiles ) $ (inputChannel) {
395416 with_channel (totalFiles ) $ (outputChannel) {
@@ -458,7 +479,7 @@ def main() : int {
458479 let jitstr = jit_enabled () ? "-jit" : ""
459480 let aotstr = is_in_aot () ? "-use-aot" : ""
460481 let benchstr = ctx .bench_enabled ? "--bench" : ""
461- let singleTest = "{ raw_args [0] } { raw_args [1] } { jitstr } { aotstr } -- --run { file } { benchstr } { log ::useTtyColors ? " --color" : "" } { headlessFlag } "
482+ let singleTest = "{ launchPrefix } { jitstr } { aotstr } -- --run { file } { benchstr } { log ::useTtyColors ? " --color" : "" } { headlessFlag } "
462483 inputChannel | > push_clone (IsoInput (uri = clone_string (uri ), cmd = clone_string (singleTest )))
463484 inputChannel | > notify ()
464485 }
0 commit comments