Skip to content

Commit 8a220af

Browse files
authored
Merge pull request #11879 from Alizter/revert-dune-exec
fix: revert dune exec back to spawn
2 parents abe7db6 + 79898df commit 8a220af

15 files changed

Lines changed: 41 additions & 25 deletions

File tree

bin/exec.ml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,20 @@ let term : unit Term.t =
193193
@@ fun () ->
194194
let open Fiber.O in
195195
let* setup = Import.Main.setup () in
196-
build_exn @@ step ~setup ~prog ~args ~common ~no_rebuild ~context ~on_exit:exit
196+
build_exn (fun () ->
197+
let open Memo.O in
198+
let* sctx = setup >>| Import.Main.find_scontext_exn ~name:context in
199+
let* env = Super_context.context_env sctx in
200+
let expand = Cmd_arg.expand ~root:(Common.root common) ~sctx in
201+
let* prog =
202+
let dir =
203+
let context = Dune_rules.Super_context.context sctx in
204+
Path.Build.relative (Context.build_dir context) (Common.prefix_target common "")
205+
in
206+
let* prog = expand prog in
207+
get_path_and_build_if_necessary sctx ~no_rebuild ~dir ~prog >>| Path.to_string
208+
and* args = Memo.parallel_map ~f:expand args in
209+
restore_cwd_and_execve (Common.root common) prog args env)
197210
;;
198211

199212
let command = Cmd.v info term

doc/changes/11876.md

Lines changed: 0 additions & 2 deletions
This file was deleted.

doc/changes/11879.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
- Revert changes in `dune exec` behaviour introduced in 3.19.0. (#11879, fixes
2+
#11870, #11867 and #11881, @Alizter)
3+

otherlibs/dune-site/test/run_2_9.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,7 @@ Test compiling an external plugin
343343

344344
$ OCAMLPATH=$PWD/_install/lib:$OCAMLPATH PATH=$PWD/_install/bin:$PATH dune exec --root=e -- c
345345
Entering directory 'e'
346+
Leaving directory 'e'
346347
run a
347348
a: $TESTCASE_ROOT/_install/share/a/data
348349
run c: a linked registered:.
@@ -356,7 +357,6 @@ Test compiling an external plugin
356357
e: $TESTCASE_ROOT/e/_build/install/default/share/e/data
357358
info.txt is found: true
358359
run c: registered:e,b.
359-
Leaving directory 'e'
360360

361361
$ OCAMLPATH=$PWD/_install/lib:$OCAMLPATH dune install --root=e --prefix $PWD/_install
362362

test/blackbox-tests/test-cases/dune-init.t/run.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,8 +409,8 @@ We can build and run the resulting executable:
409409

410410
$ dune exec --root new_exec_proj ./bin/main.exe
411411
Entering directory 'new_exec_proj'
412-
Hello, World!
413412
Leaving directory 'new_exec_proj'
413+
Hello, World!
414414

415415
We can build and run the project's tests:
416416

test/blackbox-tests/test-cases/exec-watch/exec-watch-multi-levels.t/run.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,5 @@ Perform the same test above but first enter the "bin" directory.
3030
Test that the behaviour is the same when not running with "--watch"
3131
$ cd bin && dune exec --root .. ./bin/main.exe
3232
Entering directory '..'
33-
foo
3433
Leaving directory '..'
34+
foo

test/blackbox-tests/test-cases/exec/exec-bin.t

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ By default, e is executed with the program name and arguments in argv.
2323

2424
$ dune exec ./e.exe a b c
2525
Hello
26-
argv[0] = $TESTCASE_ROOT/_build/default/e.exe
26+
argv[0] = ./_build/default/e.exe
2727
argv[1] = a
2828
argv[2] = b
2929
argv[3] = c
@@ -32,7 +32,7 @@ The special form %{bin:public_name} is supported.
3232

3333
$ dune exec %{bin:e} a b c
3434
Hello
35-
argv[0] = $TESTCASE_ROOT/_build/install/default/bin/e
35+
argv[0] = ./_build/install/default/bin/e
3636
argv[1] = a
3737
argv[2] = b
3838
argv[3] = c

test/blackbox-tests/test-cases/exec/exec-cmd.t/run.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323

2424
$ (cd test; dune exec --root .. -- dunetestbar)
2525
Entering directory '..'
26-
Bar
2726
Leaving directory '..'
27+
Bar
2828

2929
$ ls -a test/_build
3030
.

test/blackbox-tests/test-cases/exec/exec-fail.t

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ If a program encounters an exception, we should return a non-zero exit code.
3434
Fatal error: exception Failure("oh no!")
3535
[2]
3636

37+
Disable shell monitoring (of jobs) so that we do not get spurious messages
38+
about signals.
39+
$ set +m
40+
3741
If a program segfaults, we should return a non-zero exit code.
3842

3943
$ cat > foo.ml <<EOF
@@ -45,9 +49,8 @@ If a program segfaults, we should return a non-zero exit code.
4549
> EOF
4650

4751
Note that 128 + 11 (SEGV) = 139
48-
$ $(dune exec -- ./foo.exe)
49-
Command got signal SEGV.
50-
[1]
52+
$ { dune exec -- ./foo.exe; } 2> /dev/null
53+
[139]
5154

5255
If a program is killed by a signal before it terminates, we should return a non-zero exit
5356
code.
@@ -66,6 +69,5 @@ code.
6669
> ;;
6770
> EOF
6871

69-
$ $(dune exec -- ./foo.exe)
70-
Command got signal KILL.
71-
[1]
72+
$ { dune exec -- ./foo.exe; } 2> /dev/null
73+
[137]

test/blackbox-tests/test-cases/foreign-stubs/foreign-library.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -740,8 +740,8 @@ Testsuite for the (foreign_library ...) stanza.
740740

741741
$ export OCAMLPATH=$PWD/external/install/lib; dune exec ./main.exe --root=some/dir
742742
Entering directory 'some/dir'
743-
Answer = 42
744743
Leaving directory 'some/dir'
744+
Answer = 42
745745

746746
----------------------------------------------------------------------------------
747747
* External library directories in (include_dir ...)

0 commit comments

Comments
 (0)