test: pps runtime libs reach melange compile rule#14608
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a black-box cram test ensuring that a melange.emit stanza preprocessed with a ppx whose ppx_runtime_libraries includes a melange library results in the melange compile rule depending (via globs) on the runtime library's .cmi/.cmj melange objdir, even when no melange source syntactically references that runtime library.
Changes:
- New cram test
melange-pps-runtime-libs.tthat sets up a melange runtime library, a ppx rewriter declaring it as appx_runtime_libraries, and amelange.emitconsumer, then asserts viadune rules --deps+jqthat the compile rule has the expected globs on the runtime lib's melange objdir.
466f6d2 to
7d7f9a2
Compare
A `(melange.emit ...)` stanza that preprocesses with a ppx declaring `(ppx_runtime_libraries hello)` must pull `hello` into the melange compile rule's dep set as globs over its `.cmi`/`.cmj` melange objdir, even though no source names `Hello` syntactically. Melange compile rules bypass per-module narrowing today (`can_filter = false` in `module_compilation.ml`), so the wide `cctx` glob still applies; this fixture pins the property as a forward-looking guard. Signed-off-by: Robin Bate Boerop <me@robinbb.com>
7d7f9a2 to
b40a6a5
Compare
|
I'm curious why the filtering doesn't apply to Melange? can i read about the limitations somewhere? |
|
@anmonteiro I don't think there was a technical reason other than being unfamiliar with the melange rules. @robinbb would it simplify the filtering if we extended it to melange? |
|
@anmonteiro @Alizter Yes, that's right. I would prefer not to have these special-case code paths for Melange, but since I do know of a test suite against which I can assert that I have not broken anything, and because I do not know the Melange special cases (or absence of special cases) myself, I am trying to carefully preserve the Melange behaviour. Also, there was already some Melange special-casing in the code prior to this work. I would love to partner with you, @anmonteiro, if you have some time for it, to improve the handling of Melange. (However, it can come after the 9-layer PR #14492, as we need not block on it, IMO.) |
|
@robinbb that sounds great! There might be some stuff around the |
|
@anmonteiro Okay, good start. What might break if we get it wrong? Is there a body of source code that we can build with the old/new Dune to check to see if we have the logic right? |
|
usually the melange repository itself can be pretty representative, since it builds its own runtime libs with cross-module optimizations and the entire runtime testsuite. Usually if i want to get more confidence, I'll run it through the entire package set in nix-overlays, which should have most publicly available packages. |
Pins that a
(melange.emit ...)stanza preprocessing with a ppx whose(ppx_runtime_libraries ...)is non-empty includes globs over the runtime lib's.cmi/.cmjmelange objdir in the compile-rule dep set — even though no source names the runtime lib syntactically.Melange compile rules bypass per-module narrowing today (
can_filter = falseinmodule_compilation.ml); the property holds via the wide cctx glob. Forward-looking guard if narrowing ever extends to melange.