diff --git a/src/opamWrapper.ml b/src/opamWrapper.ml index 49eb52f..f0dfe9d 100644 --- a/src/opamWrapper.ml +++ b/src/opamWrapper.ml @@ -25,7 +25,7 @@ let exists_switch_at_dir dir = let switch_config_file = OpamPath.Switch.switch_config root switch in OpamFile.exists switch_config_file -let get_satysfi_opam_registry switch = +let get_satysfi_opam_registry ~outf switch = let get_reg_from_root switch = let root = OpamStateConfig.(!r.root_dir) in let switch_config_file = OpamPath.Switch.switch_config root switch in @@ -34,19 +34,24 @@ let get_satysfi_opam_registry switch = in let get_reg () = OpamGlobalState.with_ `Lock_none @@ fun gt -> - let global_switch = OpamFile.Config.switch gt.config in + let global_switch = + OpamFile.Config.switch gt.config + (* OpamStateConfig.get_switch_opt () *) + in match switch, global_switch with | Some switch, _ -> + Format.fprintf outf "Switch specified: %s@." (OpamSwitch.to_string switch); get_reg_from_root switch | None, Some switch -> + Format.fprintf outf "Global switch found: %s@." (OpamSwitch.to_string switch); get_reg_from_root switch | None, None -> failwith "get_reg: No switch is specified" in Result.try_with get_reg -let get_satysfi_opam_registry_exc switch = - get_satysfi_opam_registry switch +let get_satysfi_opam_registry_exc ~outf switch = + get_satysfi_opam_registry ~outf switch |> Result.ok_exn let dune_cache_envs = [ @@ -84,7 +89,7 @@ let opam_switch_arg opam_switch = let read_opam_environment ~outf ?opam_switch env = let satysfi_opam_registry () = - get_satysfi_opam_registry opam_switch + get_satysfi_opam_registry ~outf opam_switch |> Result.map ~f:OpamFilename.Dir.to_string in diff --git a/test/testcases/command_lockdown_save__invalid_opam_response.expected b/test/testcases/command_lockdown_save__invalid_opam_response.expected index 734fcdc..dcdd03b 100644 --- a/test/testcases/command_lockdown_save__invalid_opam_response.expected +++ b/test/testcases/command_lockdown_save__invalid_opam_response.expected @@ -121,10 +121,10 @@ diff -Nr @@empty_dir@@/satysfi-grcnum.opam @@temp_dir@@/pkg/satysfi-grcnum.opam ------------------------------------------------------------ Command invoked: opam list -i --color=never --columns name,repository,installed-version --separator=, --recursive --required-by satysfi-fonts-theano,satysfi-grcnum -Installing packages + -------------------------------------------+------------------ -Gathering OPAM package information... + -Exception: + +Installing packages +------------------------------------------------------------ +Gathering OPAM package information... +Exception: (Failure "BUG: Unrecognizable package information from OPAM: \"***,invalid,response,!!!\"") ------------------------------------------------------------ diff --git a/test/testlib/testLib.ml b/test/testlib/testLib.ml index 5889ebb..4901d52 100644 --- a/test/testlib/testLib.ml +++ b/test/testlib/testLib.ml @@ -131,8 +131,10 @@ let test_install ?(replacements=[]) ?(post_dump_dirs=default_post_dump_dirs) set post_dump_dirs ~dest_dir ~temp_dir in let opam_prefix = Unix.open_process_in "opam var prefix" |> input_line (* Assume a path does not contain line breaks*) in + let working_dir = Unix.getcwd () in let replacements = [ opam_prefix, "@@opam_prefix@@"; + working_dir, "@@working_dir@@"; dest_dir, "@@dest_dir@@"; temp_dir, "@@temp_dir@@"; Unix.getenv "HOME", "@@home_dir@@";