Skip to content

Commit

Permalink
repro exec + watch issue
Browse files Browse the repository at this point in the history
Signed-off-by: Corentin Leruth <[email protected]>
  • Loading branch information
tatchi authored and gridbugs committed Apr 4, 2024
1 parent 893b5e3 commit 30f542d
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 3 deletions.
4 changes: 2 additions & 2 deletions test/blackbox-tests/test-cases/exec-watch/dune
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
;; sometimes go undetected. Adding a delay (e.g. `sleep 1`) before modifying the
;; program seems to guarantee a rebuild will be triggered, but that is too
;; unreliable to depend on in a test so these tests are disabled on macos.
;; (<> "macosx" %{ocaml-config:system})
(<> "macosx" %{ocaml-config:system})
;; disabled until it works in CI
false))
))

(cram
(deps wait-for-file.sh))
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ between each change to its code.
1 | let () = print_endline "baz
^
Error: String literal not terminated
Had errors, waiting for filesystem changes...
Had 1 error, waiting for filesystem changes...
Success, waiting for filesystem changes...
baz
$ PID=$!
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(executable
(name main)
(libraries unix))
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
let () =
let touch path =
let fd = Unix.openfile path [ Unix.O_CREAT ] 777 in
Unix.close fd
in
print_endline "foo";
match Sys.argv.(1) with
| exception _ -> ()
| path -> touch path
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(lang dune 3.6)
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

exec + watch works fine when invoked at the root level
$ DONE_FLAG=_build/done_flag
$ dune exec --watch ./bin/main.exe $DONE_FLAG &
Success, waiting for filesystem changes...
foo
$ PID=$!

Wait for the $DONE_FLAG file to exist, then delete the file. This file is
created by the program being exec'd, so when it exists we know that it's safe to
change the code and proceed with the test.
$ ../wait-for-file.sh $DONE_FLAG
$ kill $PID


It's broken when invoked in a child folder
$ cd bin && dune exec --root .. --watch ./bin/main.exe &
Entering directory '..'
Error: posix_spawn(): No such file or directory
Leaving directory '..'
$ wait

But it works fine without watch mode
$ cd bin && dune exec --root .. ./bin/main.exe
Entering directory '..'
Leaving directory '..'
foo

0 comments on commit 30f542d

Please sign in to comment.