Automatic generation of PPX debug artifacts

That’s an interesting idea, but I’m finding some friction there too. This is as far as I got:

(executable
 (name my_parsetree_dumper)
 (public_name my_parsetree_dumper)
 (modules my_parsetree_dumper)
 (preprocess (pps my_ppx))
 (flags (:standard -dparsetree)))

(rule
 (deps %{bin:dune})
 (action
  (with-stderr-to parsetree.txt
    (chdir %{workspace_root}
           (run dune
                build test/my_parsetree_dumper.ml))))
 (mode promote))

This uses a rule instead of a CRAM test since the latter is sandboxed, with no easy way to access the workspace directory (as far as I know).

During dune build, I do observe a parsetree dump on stderr if the executable is being rebuilt. I’ve also confirmed that my rule is executing, but the captured parsetree.txt is empty every time. Maybe it has something to do with Dune caching the executable’s build result and refusing to re-build it, but I haven’t found a good way to disable caching or invalidate the cached result. Using another action to touch the source file has no effect, for example.