ocaml-ppx / ocaml-migrate-parsetree

DEPRECATED. See https://ocaml.org/changelog/2023-10-23-omp-deprecation. Convert OCaml parsetrees between different major versions
Other
86 stars 43 forks source link

Add Reason flags --re-intf and --re-impl #74

Open jchavarri opened 5 years ago

jchavarri commented 5 years ago

I'm working on a ppx where the test cases are written in Reason. Right now I have to manually run these test cases through refmt and write .ml files, that I feed to the omp driver with --impl flag.

But I'm curious if it'd be possible to add some new flags to omp for this?

My current Dune rule:

(rule
 (targets pp.result)
 (deps test.ml)
 (action (run ./main.exe --impl %{deps} -o %{targets})))

What would be ideal:

(rule
 (targets pp.result)
 (deps test.re)
 (action (run ./main.exe --re-impl %{deps} -o %{targets})))
hhugo commented 5 years ago

Wouldn't that create circle deps between omp and reason?

jchavarri commented 5 years ago

Right, I hadn't thought about that 😕

Is there a way to pipe the result of refmt, in ast or ml format, to the omp ppx executable?

hhugo commented 5 years ago

Note that you can pass both source files and ast files with --impl. I don't think there is any support for reading stdin at the moment.

ghost commented 5 years ago

@jchavarri could you describe your test framework? I'm wondering if it could be an inline test backend.

jchavarri commented 5 years ago

@diml I have a basic config that reads an ml file and uses diff from dune to compare the results: https://github.com/jchavarri/rroo/blob/master/ppx/test/dune

It's based on http://rgrinberg.com/posts/extension-points-3-years-later/. I know the setup is a bit dated, but the article helped me get up and running thanks to how specific and accessible it is. :)

It seems inline tests support Reason syntax, is there some place with an example to write inline tests against a ppx?