Skip to content

Commit

Permalink
Clear console before running command in exec -w
Browse files Browse the repository at this point in the history
This fixes an issue where the build progress stays on the console after
the build completes, and the first line of the output of the command
being exec'd is printed on teh same line as the build progress.

A side effect of this change is that some of the "Build Successful"
messages in tests get truncated.

Signed-off-by: Stephen Sherratt <[email protected]>
  • Loading branch information
gridbugs authored and rgrinberg committed Oct 18, 2024
1 parent 1becc6e commit 763a085
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 12 deletions.
6 changes: 5 additions & 1 deletion bin/exec.ml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,11 @@ module Command_to_exec = struct
{ get_path_and_build_if_necessary; prog; args; env }
=
get_path_and_build_if_necessary prog
|> Fiber.map ~f:(Result.map ~f:(spawn_process ~root ~args ~env))
|> Fiber.map
~f:
(Result.map ~f:(fun prog ->
Console.reset ();
spawn_process ~root ~args ~env prog))
;;
end

Expand Down
2 changes: 1 addition & 1 deletion test/blackbox-tests/test-cases/exec-watch/exec-pwd.t/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ In watch mode, pwd is also the folder from which dune is launched.
$ cd bin
$ dune exec --root .. -w -- pwd > $OUTPUT &
Entering directory '..'
Success, waiting for filesystem changes...
changes...
Leaving directory '..'
$ PID=$!
$ until test -s $OUTPUT; do sleep 0.1; done;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ between each change to its code.
> EOF

$ dune exec --watch ./foo.exe &
Success, waiting for filesystem changes...
changes...
foo
Success, waiting for filesystem changes...
changes...
bar
File "foo.ml", line 1, characters 23-24:
1 | let () = print_endline "baz
^
Error: String literal not terminated
Had 1 error, waiting for filesystem changes...
Success, waiting for filesystem changes...
changes...
baz
$ PID=$!
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Test exec --watch with a program that ignores sigterm.

$ dune exec --watch ./foo.exe &
Success, waiting for filesystem changes...
changes...
1: before
Success, waiting for filesystem changes...
changes...
2: before
$ PID=$!

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ project root directory.
"dune 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...
changes...
foo
$ PID=$!

Expand All @@ -19,7 +19,7 @@ Perform the same test above but first enter the "bin" directory.
$ cd bin
$ dune exec --root .. --watch ./bin/main.exe ../$DONE_FLAG &
Entering directory '..'
Success, waiting for filesystem changes...
changes...
foo
Leaving directory '..'
$ PID=$!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ between each change to its code.
> EOF

$ dune exec --watch ./foo.exe &
Success, waiting for filesystem changes...
changes...
0: before
Success, waiting for filesystem changes...
changes...
1: before
1: after
Success, waiting for filesystem changes...
changes...
2: before
$ PID=$!

Expand Down

0 comments on commit 763a085

Please sign in to comment.