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

Setup github actions for ocamlbuild #328

Merged
merged 11 commits into from
May 17, 2024
Merged
38 changes: 35 additions & 3 deletions testsuite/ocamlbuild_test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -435,19 +435,51 @@ let print_colored header_color header name body_color body =
(color_code header_color) header name
(color_code body_color) body


let run ~root =
let dir = Sys.getcwd () in
let root = dir ^ "/" ^ root in
rm root;
Unix.mkdir root 0o750;
let install_lib_dir = Filename.concat root "install-lib" in
let install_bin_dir = Filename.concat root "install-bin" in

let test_tree = Filename.dirname (Sys.argv.(0)) in
let test_tree = if test_tree = "." then Sys.getcwd () else test_tree in
let build_tree = Filename.dirname test_tree in
let ocamlbuild = Filename.concat build_tree "ocamlbuild.byte" in

let copy l dest =
ignore(Sys.command (Printf.sprintf "mkdir -p %s" dest));
List.iter (fun f -> ignore(Sys.command (Printf.sprintf "cp %s/%s %s" build_tree f dest))) l
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you write these with Sys.command @@ Filename.quote_command ...? It is good practice to protect ourselves against spaces in the build path.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Filename.quote_command was introduced in OCaml 4.10. I could use Filename.quote but I don't really understand the implication of its documentation

    Warning: under Windows, the output is only suitable for use
    with programs that follow the standard Windows quoting
    conventions.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gasp, are we still trying to support OCaml releases older than 4.10? Okay for the current code then.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Debian stable has 4.13, oldstable has 4.11.)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably need to bump the constraint in the opam file. It's currently 4.03, I think

in
let ocamlbuild = Printf.sprintf "%s/ocamlbuild.byte" install_bin_dir in
copy
[ "plugin-lib/ocamlbuildlib.cma";
"plugin-lib/ocamlbuildlib.cmxa";
"plugin-lib/ocamlbuildlib.a";
"bin/ocamlbuild.cmo";
"bin/ocamlbuild.cmx";
"bin/ocamlbuild.o";
"src/ocamlbuild_pack.cmi";
"src/ocamlbuild_pack.cmx";
"src/ocamlbuild_pack.o";
"plugin-lib/ocamlbuild_plugin.cmi";
"plugin-lib/ocamlbuild_plugin.cmx";
"plugin-lib/ocamlbuild_plugin.o";
"plugin-lib/ocamlbuild_executor.cmi";
"plugin-lib/ocamlbuild_executor.cmx";
"plugin-lib/ocamlbuild_executor.o";
"plugin-lib/ocamlbuild_unix_plugin.cmi";
"plugin-lib/ocamlbuild_unix_plugin.cmx";
"plugin-lib/ocamlbuild_unix_plugin.o"]
install_lib_dir;
copy
[ "ocamlbuild.byte";
"ocamlbuild.native" ]
install_bin_dir;
let testsuite_opts = [
(`install_bin_dir build_tree);
(`install_lib_dir (Filename.concat build_tree "src"));
(`install_bin_dir install_bin_dir);
(`install_lib_dir install_lib_dir);
] in

let verbose =
Expand Down