Add .merlin tests (#508)
These require post-processing all the absolute paths out of the .merlin
This commit is contained in:
parent
807251c931
commit
7e1300ab95
|
@ -308,7 +308,6 @@
|
|||
(run ${exe:cram.exe} run.t)
|
||||
(diff? run.t run.t.corrected)))))))
|
||||
|
||||
|
||||
(alias
|
||||
((name runtest)
|
||||
(deps ((files_recursively_in test-cases/byte-code-only)))
|
||||
|
@ -319,6 +318,16 @@
|
|||
(run ${exe:cram.exe} run.t)
|
||||
(diff? run.t run.t.corrected)))))))
|
||||
|
||||
(alias
|
||||
((name runtest)
|
||||
(deps ((files_recursively_in test-cases/merlin-tests)))
|
||||
(action
|
||||
(chdir test-cases/merlin-tests
|
||||
(setenv JBUILDER ${bin:jbuilder}
|
||||
(progn
|
||||
(run ${exe:cram.exe} run.t)
|
||||
(diff? run.t run.t.corrected)))))))
|
||||
|
||||
(alias
|
||||
((name runtest)
|
||||
(deps ((files_recursively_in test-cases/findlib)))
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
(jbuild_version 1)
|
||||
|
||||
(executable
|
||||
((name x)
|
||||
(libraries (foo))))
|
|
@ -0,0 +1,6 @@
|
|||
(jbuild_version 1)
|
||||
|
||||
(alias
|
||||
((name print-merlins)
|
||||
(deps (lib/.merlin exe/.merlin))
|
||||
(action (run ./sanitize-dot-merlin/sanitize_dot_merlin.exe ${^}))))
|
|
@ -0,0 +1,4 @@
|
|||
(library
|
||||
((name foo)
|
||||
(libraries (bytes unix findlib))
|
||||
(preprocess (pps (fooppx)))))
|
|
@ -0,0 +1,5 @@
|
|||
(jbuild_version 1)
|
||||
|
||||
(library
|
||||
((name fooppx)
|
||||
(kind ppx_rewriter)))
|
|
@ -0,0 +1,29 @@
|
|||
$ $JBUILDER build @print-merlins -j1 --display short --root .
|
||||
ocamldep sanitize-dot-merlin/sanitize_dot_merlin.ml.d
|
||||
ocamlc sanitize-dot-merlin/.sanitize_dot_merlin.eobjs/sanitize_dot_merlin.{cmi,cmo,cmt}
|
||||
ocamlopt sanitize-dot-merlin/.sanitize_dot_merlin.eobjs/sanitize_dot_merlin.{cmx,o}
|
||||
ocamlopt sanitize-dot-merlin/sanitize_dot_merlin.exe
|
||||
sanitize_dot_merlin alias print-merlins
|
||||
# Processing exe/.merlin
|
||||
B ../_build/default/exe/.x.eobjs
|
||||
B ../_build/default/lib/.foo.objs
|
||||
B $LIB_PREFIX/lib/bytes
|
||||
B $LIB_PREFIX/lib/findlib
|
||||
B $LIB_PREFIX/lib/ocaml
|
||||
FLG -w -40
|
||||
S .
|
||||
S ../lib
|
||||
S $LIB_PREFIX/lib/bytes
|
||||
S $LIB_PREFIX/lib/findlib
|
||||
S $LIB_PREFIX/lib/ocaml
|
||||
# Processing lib/.merlin
|
||||
B ../_build/default/lib/.foo.objs
|
||||
B $LIB_PREFIX/lib/bytes
|
||||
B $LIB_PREFIX/lib/findlib
|
||||
B $LIB_PREFIX/lib/ocaml
|
||||
FLG -open Foo -w -40
|
||||
FLG -ppx '$PPX/fooppx@/ppx.exe --as-ppx --cookie '\''library-name="foo"'\'''
|
||||
S .
|
||||
S $LIB_PREFIX/lib/bytes
|
||||
S $LIB_PREFIX/lib/findlib
|
||||
S $LIB_PREFIX/lib/ocaml
|
|
@ -0,0 +1,5 @@
|
|||
(jbuild_version 1)
|
||||
|
||||
(executable
|
||||
((name sanitize_dot_merlin)
|
||||
(libraries (str))))
|
|
@ -0,0 +1,25 @@
|
|||
open Printf
|
||||
|
||||
let process_line =
|
||||
let path_re = Str.regexp {|^\([SB]\) /.+/lib/\(.+\)$|} in
|
||||
let ppx_re = Str.regexp {|^FLG -ppx '/.+/\.ppx/\(.+\)$|} in
|
||||
fun line ->
|
||||
line
|
||||
|> Str.replace_first path_re {|\1 $LIB_PREFIX/lib/\2|}
|
||||
|> Str.global_replace ppx_re {|FLG -ppx '$PPX/\1|}
|
||||
|
||||
let () =
|
||||
let files = ref [] in
|
||||
let anon s = files := s :: !files in
|
||||
let usage = sprintf "%s [FILES]" (Filename.basename Sys.executable_name) in
|
||||
Arg.parse [] anon usage;
|
||||
List.iter (fun f ->
|
||||
Printf.printf "# Processing %s\n" f;
|
||||
let ch = open_in f in
|
||||
let rec loop () =
|
||||
match input_line ch with
|
||||
| exception End_of_file -> ()
|
||||
| line -> print_endline (process_line line); loop () in
|
||||
loop ();
|
||||
close_in ch
|
||||
) !files
|
Loading…
Reference in New Issue