Report exits from the toplevel correctly#382
Report exits from the toplevel correctly#382Leonidas-from-XIV merged 8 commits intorealworldocaml:mainfrom
Conversation
Previously, you just got:
ocaml-mdx-test: internal error, uncaught exception:
Compenv.Exit_with_status(125)
|
Looks like there is a multi-version incompatibility:
It's quite hard to build a compatibility wrapper in I looked a bit around in the source code of 4.12 vs 4.14 and it seems like |
|
I played around a bit in #384 to get it to compile on older versions, which is not too difficult. Two issues remain:
|
They have to be redirected because by default they write to stdout, but we capture stderr (and in 4.14 they write to stderr). Unfortunately, just overwriting them in the directives Hashtbl does not work, since the ordering of additions is somewhat undefined so they might be overwritten. A safer way is to create new directives and rewrite those to be evaluated to them. Also, `"use"` is a builtin directive, not from findlib so needs to be excluded to get the error message printed.
`use_output` was added in 4.11, whereas the `use_trace` was removed in 4.13.
67c85e8 to
cfedb20
Compare
The stdlib pre-4.14 defines them to be `ignore`d but they can be made to throw the error like in 4.14. At least some of them, for which the underlying functions are exposed in the interface.
OCaml 4.13 introduces a few deprecations that we need to work around.
|
Okay, I looked into this and I think I resolved all the issues here:
The directives are all implemented as custom This was a fun challenge, teaching me a thing or two how the directives in the toplevel work. |
|
Thanks - I hadn't realised how much work it would be to support older versions! |
NathanReb
left a comment
There was a problem hiding this comment.
Thanks to both of you for fixing this!
It looks good to me. My only concern is that the Compat_top module is a tiny bit hard to follow at the moment but I'm not sure how to exactly improve it so don't consider this a blocker.
|
I could move stuff out of Thanks for finding the issues with the constraints, looks like I copypasted exactly the one line that had a problem. |
CHANGES: #### Added - Report all parsing errors in Markdown files (realworldocaml/mdx#389, @NathanReb) #### Changed - Preserve indentation in multiline OCaml blocks in .mli files (realworldocaml/mdx#395, @panglesd) #### Fixed - Fixed compatibility with Cmdliner 1.1.0 (realworldocaml/mdx#371, @Leonidas-from-XIV) - Report errors and exit codes of toplevel directives (realworldocaml/mdx#382, @talex5, @Leonidas-from-XIV) - Fix block locations in error reporting (realworldocaml/mdx#389, @NathanReb) - Include the content of the line that features the `part-end` MDX directive in the output, before that line would've been dropped (realworldocaml/mdx#374, realworldocaml/mdx#387, @Leonidas-from-XIV) - Handle EINTR signal on waitpid call by restarting the syscall. (realworldocaml/mdx#409, @tmcgilchrist) - Fix parsing of multiline toplevel phrases in .mli files (realworldocaml/mdx#394, realworldocaml/mdx#397, @Leonidas-from-XIV) #### Removed - Removed warning about missing semicolons added in MDX 1.11.0 and the automatic insertion of semicolons in the corrected files introduced in MDX 2.0.0. (realworldocaml/mdx#398, @Leonidas-from-XIV)
Previously, you just got: