ocaml-migrate-parsetree icon indicating copy to clipboard operation
ocaml-migrate-parsetree copied to clipboard

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

Open jchavarri opened this issue 6 years ago • 5 comments
trafficstars

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})))

jchavarri avatar May 26 '19 12:05 jchavarri

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

hhugo avatar May 26 '19 13:05 hhugo

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?

jchavarri avatar May 26 '19 17:05 jchavarri

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.

hhugo avatar May 27 '19 00:05 hhugo

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

ghost avatar May 30 '19 07:05 ghost

@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?

jchavarri avatar May 30 '19 14:05 jchavarri