Merge pull request #374 from rgrinberg/ppx-rewriter-tests

Ppx rewriter tests
This commit is contained in:
Rudi Grinberg 2017-12-20 12:27:07 +07:00 committed by GitHub
commit feaca3058b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 71 additions and 2 deletions

View File

@ -46,7 +46,7 @@ case "$TARGET" in
rm -rf ~/.opam
opam init --yes
eval $(opam config env)
opam install odoc reason menhir ocaml-migrate-parsetree js_of_ocaml-ppx --yes
opam install ppx_driver odoc reason menhir ocaml-migrate-parsetree js_of_ocaml-ppx --yes
opam remove jbuilder `opam list --depends-on jbuilder --installed --short` --yes
fi
cp -a ~/.opam ~/.opam-start
@ -73,7 +73,7 @@ case "$TARGET" in
opam list
echo "version: \"1.0+dev$DATE\"" >> jbuilder.opam
opam pin add jbuilder . --no-action --yes
opam install odoc reason ocaml-migrate-parsetree js_of_ocaml-ppx --yes
opam install ppx_driver odoc reason ocaml-migrate-parsetree js_of_ocaml-ppx --yes
echo -en "travis_fold:end:opam.deps\r"
fi
echo -en "travis_fold:start:jbuilder.bootstrap\r"

View File

@ -24,6 +24,7 @@ depends: [
"menhir" {test}
"reason" {test}
"ocaml-migrate-parsetree" {test}
"ppx_driver" {test}
"odoc" {test}
"js_of_ocaml-compiler" {test}
]

View File

@ -141,3 +141,10 @@
(action
(chdir test-cases/multiple-private-libs
(setenv JBUILDER ${bin:jbuilder} (run ${exe:cram.exe} -ocamlv ${ocaml_version} -skip-versions 4.02.3 run.t))))))
(alias
((name runtest)
(deps ((files_recursively_in test-cases/ppx-rewriter)))
(action
(chdir test-cases/ppx-rewriter
(setenv JBUILDER ${bin:jbuilder} (run ${exe:cram.exe} -ocamlv ${ocaml_version} -skip-versions 4.02.3 run.t))))))

View File

@ -0,0 +1,16 @@
(jbuild_version 1)
(executable
((name w_omp_driver)
(modules (w_omp_driver))
(preprocess (pps (fooppx -flag (-arg omp))))))
(executable
((name w_ppx_driver)
(modules (w_ppx_driver))
(preprocess (pps (ppx_driver.runner)))))
(executable
((name w_ppx_driver_flags)
(modules (w_ppx_driver_flags))
(preprocess (pps (fooppx -flag (-arg omp) ppx_driver.runner)))))

View File

@ -0,0 +1,21 @@
let flag = ref false
let arg = ref ""
let () =
Migrate_parsetree.Driver.register
~name:"linter"
~args:([ "-flag", Arg.Set flag, ""
; "-arg", Arg.Set_string arg, ""
])
Migrate_parsetree.Versions.ocaml_405
(fun _ cookies ->
if not !flag then (
Format.eprintf "pass -flag to fooppx@.%!";
exit 1
);
if !arg = "" then (
Format.eprintf "pass -arg to fooppx@.%!"
);
Format.eprintf "-arg: %s%@." !arg;
Migrate_parsetree.Ast_405.shallow_identity
)

View File

@ -0,0 +1,4 @@
(library
((name fooppx)
(kind ppx_rewriter)
(libraries (ocaml-migrate-parsetree))))

View File

@ -0,0 +1,20 @@
$ $JBUILDER build ./w_omp_driver.exe -j1 --root .
ocamldep ppx/fooppx.depends.ocamldep-output
ocamlc ppx/fooppx.{cmi,cmo,cmt}
ocamlopt ppx/fooppx.{cmx,o}
ocamlopt ppx/fooppx.{a,cmxa}
ocamlopt .ppx/fooppx/ppx.exe
ppx w_omp_driver.pp.ml
ocamldep w_omp_driver.depends.ocamldep-output
ocamlc w_omp_driver.{cmi,cmo,cmt}
ocamlopt w_omp_driver.{cmx,o}
ocamlopt w_omp_driver.exe
$ $JBUILDER build ./w_ppx_driver.exe -j1 --root .
ocamlopt .ppx/ppx_driver.runner/ppx.exe
ppx w_ppx_driver.pp.ml
ocamldep w_ppx_driver.depends.ocamldep-output
ocamlc w_ppx_driver.{cmi,cmo,cmt}
ocamlopt w_ppx_driver.{cmx,o}
ocamlopt w_ppx_driver.exe
This test is broken because ppx_driver doesn't support migrate custom arguments
# $ $JBUILDER build ./w_ppx_driver_flags.exe -j1 --root .