Fix type of Path.reach_for_running

It should return a string rather than a path. Also, make Process.run use it
rather than relying on the caller to do it.
This commit is contained in:
Rudi Grinberg 2018-05-17 20:23:48 +07:00
parent a834e6f6ba
commit 8cea102d3c
5 changed files with 12 additions and 12 deletions

View File

@ -741,7 +741,7 @@ let exec_run_direct ~ectx ~dir ~env ~stdout_to ~stderr_to prog args =
Process.run Strict ~dir ~env
~stdout_to ~stderr_to
~purpose:ectx.purpose
(Path.reach_for_running ~from:dir prog) args
prog args
let exec_run ~stdout_to ~stderr_to =
let stdout_to = get_std_output stdout_to in

View File

@ -232,7 +232,7 @@ let run_internal ?dir ?(stdout_to=Terminal) ?(stderr_to=Terminal) ~env ~purpose
if display = Verbose then
Format.eprintf "@{<kwd>Running@}[@{<id>%d@}]: %s@." id
(Colors.strip_colors_for_stderr command_line);
let prog = Path.to_string prog in
let prog = Path.reach_for_running prog ~from:(Option.value ~default:Path.build_dir dir) in
let argv = Array.of_list (prog :: args) in
let output_filename, stdout_fd, stderr_fd, to_close =
match stdout_to, stderr_to with
@ -347,11 +347,11 @@ let run_capture_line ?dir ~env ?(purpose=Internal_job) fail_mode prog args =
| [x] -> x
| l ->
let cmdline =
let prog = Path.to_string prog in
let s = String.concat (prog :: args) ~sep:" " in
let prog_display p = String.concat (p :: args) ~sep:" " in
match dir with
| None -> s
| Some dir -> sprintf "cd %s && %s" (Path.to_string dir) s
| None -> prog_display (Path.to_string prog)
| Some dir -> sprintf "cd %s && %s" (Path.to_string dir)
(prog_display (Path.reach_for_running prog ~from:dir))
in
match l with
| [] ->

View File

@ -70,7 +70,7 @@ val absolute : string -> t
val to_absolute_filename : t -> root:string -> string
val reach : t -> from:t -> string
val reach_for_running : t -> from:t -> t
val reach_for_running : t -> from:t -> string
val descendant : t -> of_:t -> t option
val is_descendant : t -> of_:t -> bool

View File

@ -1,6 +1,6 @@
$ env -u OCAMLRUNPARAM jbuilder runtest simple
run alias simple/runtest (exit 2)
(cd _build/default/simple && ./.foo_simple.inline-tests/run.exe)
(cd _build/default/simple && _build/default/simple/.foo_simple.inline-tests/run.exe)
Fatal error: exception File "simple/.foo_simple.inline-tests/run.ml", line 1, characters 10-16: Assertion failed
[1]

View File

@ -287,19 +287,19 @@ Path.is_in_build_dir Path.build_dir
Path.reach_for_running Path.build_dir ~from:Path.root
[%%expect{|
- : Stdune.Path.t = ./_build
- : string = "./_build"
|}]
Path.(reach_for_running (relative build_dir "foo/baz")
~from:(relative build_dir "foo/bar/baz"))
[%%expect{|
- : Stdune.Path.t = ../../baz
- : string = "../../baz"
|}]
Path.(reach_for_running (Path.absolute "/fake/path")
~from:(relative build_dir "foo/bar/baz"))
[%%expect{|
- : Stdune.Path.t = /fake/path
- : string = "/fake/path"
|}]
Path.(reach_for_running (relative build_dir "foo/baz")
@ -310,5 +310,5 @@ Exception: Stdune__Exn.Code_error <abstr>.
Path.(reach_for_running (relative root "foo") ~from:(Path.relative root "foo"))
[%%expect{|
- : Stdune.Path.t = ./.
- : string = "./."
|}]