Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring: Setting PATH in the testcases #196

Open
na4zagin3 opened this issue Oct 24, 2020 · 0 comments
Open

Refactoring: Setting PATH in the testcases #196

na4zagin3 opened this issue Oct 24, 2020 · 0 comments

Comments

@na4zagin3
Copy link
Owner

The current test implementation tries to update PATH in two locations. One is PrepareBin.prepare_bin and the other is `TestLib.with_bin_dir. They need to be unified.

(* PrepareBin *)
let prepare_bin bin log_file =
  let path = Unix.getenv "PATH" in
  let gen_bin name content =
    let path = FilePath.concat bin name in
    let open Shexp_process in
    let open Infix in
    mkdir ~p:() bin
    >> stdout_to path (content |> echo)
    >> chmod path ~perm:0o755
  in
  let open Shexp_process in
  let open Infix in
  Unix.putenv "PATH" (bin ^ ":" ^ path);
  gen_bin "satysfi" (satysfi log_file)
  >> gen_bin "opam" (opam log_file)
(* TestLib *)
let with_bin_dir bin_dir cmd =
  get_env "PATH"
  >>= fun path ->
  set_env "PATH" (bin_dir ^ ":" ^ Option.get path) cmd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant