Skip to content

Commit

Permalink
Support for OCaml 4.09.
Browse files Browse the repository at this point in the history
  • Loading branch information
xclerc committed Sep 20, 2019
1 parent 63ade67 commit ac01449
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/dune
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(library (name toplevel_expect_test) (public_name toplevel_expect_test)
(modes byte)
(libraries toplevel_expect_test_types ppxlib ppxlib.print_diff
(libraries toplevel_expect_test_types ppxlib ppxlib.print_diff core
ppx_here.expander core_kernel ppx_expect.common ppx_expect.matcher
mlt_parser ocaml-compiler-libs.common compiler-libs.common
compiler-libs.toplevel findlib.top unix threads ppx_inline_test.runner.lib)
Expand Down
18 changes: 8 additions & 10 deletions src/main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -448,14 +448,6 @@ let process_expect_file fname ~use_color ~in_place ~sexp_output ~use_absolute_pa
true
;;

let override_sys_argv args =
let len = Array.length args in
assert (len <= Array.length Sys.argv);
Array.blit ~src:args ~src_pos:0 ~dst:Sys.argv ~dst_pos:0 ~len;
Obj.truncate (Obj.repr Sys.argv) len;
Arg.current := 0;
;;

let setup_env () =
(* Same as what run-tests.py does, to get repeatable output *)
List.iter ~f:(fun (k, v) -> Unix.putenv k v)
Expand Down Expand Up @@ -493,15 +485,21 @@ let sexp_output = ref false
let use_absolute_path = ref false
let allow_output_patterns = ref false

[%%if ocaml_version < (4, 09, 0)]
let init_path () = Compmisc.init_path true
[%%else]
let init_path () = Compmisc.init_path ()
[%%endif]

let main fname =
let cmd_line =
Array.sub Sys.argv ~pos:!Arg.current ~len:(Array.length Sys.argv - !Arg.current)
in
setup_env ();
setup_config ();
override_sys_argv cmd_line;
Core.Sys.override_argv cmd_line;
Toploop.set_paths ();
Compmisc.init_path true;
init_path ();
Toploop.toplevel_env := Compmisc.initial_env ();
Sys.interactive := false;
Backend.init ();
Expand Down
1 change: 1 addition & 0 deletions toplevel_expect_test.opam
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ build: [
]
depends: [
"ocaml" {>= "4.07.0"}
"core" {>= "v0.12.4" & < "v0.13"}
"core_kernel" {>= "v0.12" & < "v0.13"}
"mlt_parser" {>= "v0.12" & < "v0.13"}
"ppx_expect" {>= "v0.12" & < "v0.13"}
Expand Down

0 comments on commit ac01449

Please sign in to comment.