I don’t know to which component to report this bug, so I thought I’d report it here.
TL;DR mandatory quotation-marks in arguments to PPX rewriter ppx_expect (due to ppxlib’s use of Ocaml’s AST parser to parse command-line arguments) breaks ability to invoke ppx_expect rewriter via ocamlfind/make/ocamlc (unless the user is willing to double-quote-then-single-quote-then-single-quote, escaping all the way).
Here’s a Git repo that repros the problem: https://github.com/chetmurthy/dune-ocaml-ppx-bug
In the repro, you (a) run with dune, then (b)run a script that directly invokes the PPX rewriters, then © run a script that does what should work using ocamlfind (but does not). I haven’t bothered to figure out how to do the dq/sq/sq-escaping I describe above, b/c I use camlp5-based PPX rewriters, but I figured I should report this bug, nonetheless.
Also, thank you to @Kakadu for testing out this repro and finding a number of environmental defects.
You may add another level of quotation around the arguments: -ppxopt ppx_expect,\''library-name="foo"'\'
.
Well, yes, that’s my point though, isn’t it? Requiring three layers of quotation-marks in something that goes thru multiple passes of shell-interpretation is … not a great idea.
And it’s not necessary, is it?
- ppx_inline_test doesn’t require this – the “library token” is an unquoted string for that PPX rewriter.
- As a generic rule, such arguments could be provided in a “response file”.
- In
ppxlib
it appears that command-line arguments are being parsed with the Ocaml AST parser: this seems like not such a great idea, since those command-line arguments are also parsed by the shell, and (as in this case) those two languages are sometimes incompatible.
- Another way of looking at it: why aren’t arguments like these provided as extension-nodes in the code itself? It seems like
[%ppx_expect { library_name = "foo" }]
should be preferable to passing it as a command-line argument? This has the advantage that you get precisely the syntax you want (Ocaml syntax) with no interference from the shell or other UNIX tools.