Skip to content

Commit

Permalink
Update the installation test for enable-relative
Browse files Browse the repository at this point in the history
  • Loading branch information
dra27 committed Oct 18, 2024
1 parent 6e8337a commit eaeb2ca
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
1 change: 1 addition & 0 deletions testsuite/in_prefix/Makefile.test
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ endif
$(call bool_to_with, shared, $(SUPPORTS_SHARED_LIBRARIES)) \
$(call bool_to_with, ocamlnat, $(INSTALL_OCAMLNAT)) \
$(call bool_to_with, ocamlopt, $(NATIVE_COMPILER)) \
$(call bool_to_with, relative-libdir, $(RELATIVE_LIBDIR)) \
$(ALL_OTHERLIBS)

SCRUB_ENV = \
Expand Down
18 changes: 15 additions & 3 deletions testsuite/tools/test_in_prefix.ml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ type config = {
(* $(INSTALL_OCAMLNAT) - Makefile.build_config *)
has_ocamlopt: bool;
(* $(NATIVE_COMPILER) - Makefile.config *)
has_relative_libdir: bool;
(* $(RELATIVE_LIBDIR) - Makefile.build_config *)
libraries: string list
(* Sorted basenames of libraries to test.
Derived from $(OTHERLIBRARIES) - Makefile.config *)
Expand Down Expand Up @@ -51,8 +53,8 @@ let bindir, libdir, prefix, bindir_suffix, libdir_suffix,
let bindir = ref "" in
let libdir = ref "" in
let config =
ref {supports_shared_libraries = false;
has_ocamlnat = false; has_ocamlopt = false; libraries = []}
ref {supports_shared_libraries = false; has_ocamlnat = false;
has_ocamlopt = false; has_relative_libdir = false; libraries = []}
in
let check_exists r dir =
if Sys.file_exists dir then
Expand All @@ -71,6 +73,9 @@ let bindir, libdir, prefix, bindir_suffix, libdir_suffix,
in
let has_ocamlnat has_ocamlnat () = config := {!config with has_ocamlnat} in
let has_ocamlopt has_ocamlopt () = config := {!config with has_ocamlopt} in
let has_relative_libdir has_relative_libdir () =
config := {!config with has_relative_libdir}
in
let args = Arg.align [
"--bindir", Arg.String (check_exists bindir), "\
<bindir>\tDirectory containing programs (must share a prefix with --libdir)";
Expand All @@ -85,6 +90,9 @@ let bindir, libdir, prefix, bindir_suffix, libdir_suffix,
"--with-ocamlopt", Arg.Unit (has_ocamlopt true), "\
\tNative compiler (ocamlopt) is installed in the directory given in --bindir";
"--without-ocamlopt", Arg.Unit (has_ocamlopt false), "";
"--with-relative-libdir", Arg.Unit (has_relative_libdir true), "\
\tCompiler was configured with --enable-relative";
"--without-relative-libdir", Arg.Unit (has_relative_libdir false), "";
] in
let libraries lib =
config := {!config with libraries = lib::config.contents.libraries}
Expand Down Expand Up @@ -950,6 +958,9 @@ let compile_test ~original env bindir =
else
None
in
let arg =
(config.has_relative_libdir && test = Default C_ocamlc) || arg
in
run_program env ?runtime test_program ~arg;
if original then
Some (run ~original:false)
Expand Down Expand Up @@ -1064,7 +1075,8 @@ let () =
let runtime = Some (Filename.concat bindir (exe "ocamlrun")) in
List.iter (fun f -> assert (f ?runtime env ~arg:false = None)) programs;
let env =
Environment.make ~caml_ld_library_path:true ~ocamllib:true bindir libdir
Environment.make ~caml_ld_library_path:true
~ocamllib:(not config.has_relative_libdir) bindir libdir
in
Compmisc.reinit_path ~standard_library:libdir ();
let programs = run_tests ~original:false env bindir libdir config.libraries in
Expand Down

0 comments on commit eaeb2ca

Please sign in to comment.