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:
parent
a834e6f6ba
commit
8cea102d3c
|
@ -741,7 +741,7 @@ let exec_run_direct ~ectx ~dir ~env ~stdout_to ~stderr_to prog args =
|
||||||
Process.run Strict ~dir ~env
|
Process.run Strict ~dir ~env
|
||||||
~stdout_to ~stderr_to
|
~stdout_to ~stderr_to
|
||||||
~purpose:ectx.purpose
|
~purpose:ectx.purpose
|
||||||
(Path.reach_for_running ~from:dir prog) args
|
prog args
|
||||||
|
|
||||||
let exec_run ~stdout_to ~stderr_to =
|
let exec_run ~stdout_to ~stderr_to =
|
||||||
let stdout_to = get_std_output stdout_to in
|
let stdout_to = get_std_output stdout_to in
|
||||||
|
|
|
@ -232,7 +232,7 @@ let run_internal ?dir ?(stdout_to=Terminal) ?(stderr_to=Terminal) ~env ~purpose
|
||||||
if display = Verbose then
|
if display = Verbose then
|
||||||
Format.eprintf "@{<kwd>Running@}[@{<id>%d@}]: %s@." id
|
Format.eprintf "@{<kwd>Running@}[@{<id>%d@}]: %s@." id
|
||||||
(Colors.strip_colors_for_stderr command_line);
|
(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 argv = Array.of_list (prog :: args) in
|
||||||
let output_filename, stdout_fd, stderr_fd, to_close =
|
let output_filename, stdout_fd, stderr_fd, to_close =
|
||||||
match stdout_to, stderr_to with
|
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
|
| [x] -> x
|
||||||
| l ->
|
| l ->
|
||||||
let cmdline =
|
let cmdline =
|
||||||
let prog = Path.to_string prog in
|
let prog_display p = String.concat (p :: args) ~sep:" " in
|
||||||
let s = String.concat (prog :: args) ~sep:" " in
|
|
||||||
match dir with
|
match dir with
|
||||||
| None -> s
|
| None -> prog_display (Path.to_string prog)
|
||||||
| Some dir -> sprintf "cd %s && %s" (Path.to_string dir) s
|
| Some dir -> sprintf "cd %s && %s" (Path.to_string dir)
|
||||||
|
(prog_display (Path.reach_for_running prog ~from:dir))
|
||||||
in
|
in
|
||||||
match l with
|
match l with
|
||||||
| [] ->
|
| [] ->
|
||||||
|
|
|
@ -70,7 +70,7 @@ val absolute : string -> t
|
||||||
val to_absolute_filename : t -> root:string -> string
|
val to_absolute_filename : t -> root:string -> string
|
||||||
|
|
||||||
val reach : t -> from:t -> 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 descendant : t -> of_:t -> t option
|
||||||
val is_descendant : t -> of_:t -> bool
|
val is_descendant : t -> of_:t -> bool
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
$ env -u OCAMLRUNPARAM jbuilder runtest simple
|
$ env -u OCAMLRUNPARAM jbuilder runtest simple
|
||||||
run alias simple/runtest (exit 2)
|
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
|
Fatal error: exception File "simple/.foo_simple.inline-tests/run.ml", line 1, characters 10-16: Assertion failed
|
||||||
[1]
|
[1]
|
||||||
|
|
||||||
|
|
|
@ -287,19 +287,19 @@ Path.is_in_build_dir Path.build_dir
|
||||||
|
|
||||||
Path.reach_for_running Path.build_dir ~from:Path.root
|
Path.reach_for_running Path.build_dir ~from:Path.root
|
||||||
[%%expect{|
|
[%%expect{|
|
||||||
- : Stdune.Path.t = ./_build
|
- : string = "./_build"
|
||||||
|}]
|
|}]
|
||||||
|
|
||||||
Path.(reach_for_running (relative build_dir "foo/baz")
|
Path.(reach_for_running (relative build_dir "foo/baz")
|
||||||
~from:(relative build_dir "foo/bar/baz"))
|
~from:(relative build_dir "foo/bar/baz"))
|
||||||
[%%expect{|
|
[%%expect{|
|
||||||
- : Stdune.Path.t = ../../baz
|
- : string = "../../baz"
|
||||||
|}]
|
|}]
|
||||||
|
|
||||||
Path.(reach_for_running (Path.absolute "/fake/path")
|
Path.(reach_for_running (Path.absolute "/fake/path")
|
||||||
~from:(relative build_dir "foo/bar/baz"))
|
~from:(relative build_dir "foo/bar/baz"))
|
||||||
[%%expect{|
|
[%%expect{|
|
||||||
- : Stdune.Path.t = /fake/path
|
- : string = "/fake/path"
|
||||||
|}]
|
|}]
|
||||||
|
|
||||||
Path.(reach_for_running (relative build_dir "foo/baz")
|
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"))
|
Path.(reach_for_running (relative root "foo") ~from:(Path.relative root "foo"))
|
||||||
[%%expect{|
|
[%%expect{|
|
||||||
- : Stdune.Path.t = ./.
|
- : string = "./."
|
||||||
|}]
|
|}]
|
||||||
|
|
Loading…
Reference in New Issue