Skip to content

Commit

Permalink
more compat
Browse files Browse the repository at this point in the history
  • Loading branch information
Hugo Heuzard committed Mar 2, 2023
1 parent 96850de commit a5090bc
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
9 changes: 8 additions & 1 deletion libname/ppx_inline_test_libname.ml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,11 @@ let () =
| Some lib -> libname := Some lib)
;;

let get () = !libname;;
let get () =
match !libname with
| None -> None
| Some lib ->
(match String.index lib ':' with
| exception Not_found -> Some (lib, None)
| i -> Some (String.sub lib 0 i, (Some (String.sub lib (i + 1) (String.length lib - i - 1)))))
;;
2 changes: 1 addition & 1 deletion libname/ppx_inline_test_libname.mli
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
(** This library defines the command line argument -libname, shared by both ppx_bench
and ppx_inline_test. *)
val get : unit -> string option
val get : unit -> (string * string option) option
13 changes: 10 additions & 3 deletions src/ppx_inline_test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -304,10 +304,17 @@ let tags = E.tags

let () =
Driver.V2.register_transformation "inline-test" ~extensions:E.all ~enclose_impl:(fun ctxt loc ->
let partition = Stdlib.Filename.basename (Expansion_context.Base.input_name ctxt) in
match loc, Ppx_inline_test_libname.get () with
let libname_and_partition =
match Ppx_inline_test_libname.get () with
| None -> None
| Some (libname, Some partition) -> Some (libname, partition)
| Some (libname, None) ->
let partition = Stdlib.Filename.basename (Expansion_context.Base.input_name ctxt) in
Some (libname, partition)
in
match loc, libname_and_partition with
| None, _ | _, None -> [], []
| Some loc, Some libname ->
| Some loc, Some (libname, partition) ->
let loc = { loc with loc_ghost = true } in
(* See comment in benchmark_accumulator.ml *)
let header =
Expand Down

0 comments on commit a5090bc

Please sign in to comment.