Tests for running ppx rewriters
Testing changing and interacting with drivers by passing arguments.
This commit is contained in:
parent
3cae475486
commit
1793827d0b
|
@ -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))))))
|
||||
|
|
|
@ -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)))))
|
|
@ -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
|
||||
)
|
|
@ -0,0 +1,4 @@
|
|||
(library
|
||||
((name fooppx)
|
||||
(kind ppx_rewriter)
|
||||
(libraries (ocaml-migrate-parsetree))))
|
|
@ -0,0 +1,63 @@
|
|||
$ $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
|
||||
$ $JBUILDER build ./w_ppx_driver_flags.exe -j1 --root .
|
||||
ocamlopt .ppx/fooppx+ppx_driver.runner/ppx.exe
|
||||
ppx w_ppx_driver_flags.pp.ml (exit 2)
|
||||
(cd _build/default && ./.ppx/fooppx+ppx_driver.runner/ppx.exe -flag -arg omp --dump-ast -o w_ppx_driver_flags.pp.ml --impl w_ppx_driver_flags.ml)
|
||||
./.ppx/fooppx+ppx_driver.runner/ppx.exe: unknown option '-flag'.
|
||||
ppx.exe [extra_args] [<files>]
|
||||
-loc-filename <string> File name to use in locations
|
||||
-reserve-namespace <string> Mark the given namespace as reserved
|
||||
-no-check Disable checks (unsafe)
|
||||
-do-check Enable checks
|
||||
-apply <names> Apply these transformations in order (comma-separated list)
|
||||
-dont-apply <names> Exclude these transformations
|
||||
-no-merge Do not merge context free transformations (better for debugging rewriters)
|
||||
-as-ppx Run as a -ppx rewriter (must be the first argument)
|
||||
--as-ppx Same as -as-ppx
|
||||
-as-pp Shorthand for: -dump-ast -embed-errors
|
||||
--as-pp Same as -as-pp
|
||||
-o <filename> Output file (use '-' for stdout)
|
||||
- Read input from stdin
|
||||
-no-optcomp Do not use optcomp (default if the input or output of -pp is a binary AST)
|
||||
-dump-ast Dump the marshaled ast to the output file instead of pretty-printing it
|
||||
--dump-ast Same as -dump-ast
|
||||
-dparsetree Print the parsetree (same as ocamlc -dparsetree)
|
||||
-embed-errors Embed errors in the output AST (default: true when -dump-ast, false otherwise)
|
||||
-null Produce no output, except for errors
|
||||
-impl <file> Treat the input as a .ml file
|
||||
--impl <file> Same as -impl
|
||||
-intf <file> Treat the input as a .mli file
|
||||
--intf <file> Same as -intf
|
||||
-debug-attribute-drop Debug attribute dropping
|
||||
-print-transformations Print linked-in code transformations, in the order they are applied
|
||||
-print-passes Print the actual passes over the whole AST in the order they are applied
|
||||
-ite-check Enforce that "complex" if branches are delimited (disabled if -pp is given)
|
||||
-pp <command> Pipe sources through preprocessor <command> (incompatible with -as-ppx)
|
||||
-reconcile (WIP) Pretty print the output using a mix of the input source and the generated code
|
||||
-reconcile-with-comments (WIP) same as -reconcile but uses comments to enclose the generated code
|
||||
-no-color Don't use colors when printing errors
|
||||
-diff-cmd Diff command when using code expectations
|
||||
-pretty Instruct code generators to improve the prettiness of the generated code
|
||||
-styler Code styler
|
||||
-cookie NAME=EXPR Set the cookie NAME to EXPR
|
||||
--cookie Same as -cookie
|
||||
-help Display this list of options
|
||||
--help Display this list of options
|
||||
[1]
|
Loading…
Reference in New Issue