This commit is contained in:
parent
aa2ff7b2f0
commit
2f3113f55d
11742 changed files with 1223940 additions and 0 deletions
|
|
@ -0,0 +1,7 @@
|
|||
(executables
|
||||
(names raiser pp)
|
||||
(libraries ppxlib))
|
||||
|
||||
(cram
|
||||
(package ppxlib)
|
||||
(deps raiser.exe pp.exe))
|
||||
|
|
@ -0,0 +1 @@
|
|||
let () = Ppxlib.Location.raise_errorf "Raising inside the preprocessor"
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
open Ppxlib
|
||||
|
||||
let rule =
|
||||
let expand ~loc ~path:_ =
|
||||
Location.raise_errorf ~loc "Raising inside the rewriter"
|
||||
in
|
||||
Extension.declare "raise" Extension.Context.expression
|
||||
Ast_pattern.(pstr nil)
|
||||
expand
|
||||
|> Context_free.Rule.extension
|
||||
|
||||
let () = Driver.register_transformation ~rules:[ rule ] "test"
|
||||
let () = Driver.standalone ()
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
Keep the error output short in order to avoid different error output between
|
||||
different compiler versions in the subsequent tests
|
||||
|
||||
$ export OCAML_ERROR_STYLE=short
|
||||
|
||||
With the `-embed-errors` options, if a PPX raises, the first such exception
|
||||
is caught and prepended to the last valid AST
|
||||
|
||||
$ echo "let _ = [%raise]" > impl.ml
|
||||
$ ../raiser.exe -embed-errors impl.ml
|
||||
let _ = [%ocaml.error "Raising inside the rewriter"]
|
||||
|
||||
The same is true when using the `-as-ppx` mode (note that the error is reported
|
||||
by ocaml itself)
|
||||
|
||||
$ ocaml -ppx '../raiser.exe -as-ppx' impl.ml
|
||||
File "./impl.ml", line 1, characters 8-16:
|
||||
Error: Raising inside the rewriter
|
||||
[2]
|
||||
|
||||
Also exceptions raised in a preprocessor get embedded into an AST(while the
|
||||
error from the preprocessor's stderr also gets reported on the driver's stderr)
|
||||
|
||||
$ touch file.ml
|
||||
$ ../raiser.exe -embed-errors -pp ../pp.exe file.ml | sed "s/> '.*'/> tmpfile/"
|
||||
Fatal error: exception Raising inside the preprocessor
|
||||
[%%ocaml.error
|
||||
"Error while running external preprocessor\nCommand line: ../pp.exe 'file.ml' > tmpfile\n"]
|
||||
|
||||
Also `unknown version` errors are embedded into an AST when using the
|
||||
main standalone
|
||||
|
||||
$ ../raiser.exe -embed-errors -intf unknown_version_binary_ast
|
||||
[%%ocaml.error
|
||||
"File is a binary ast for an unknown version of OCaml with magic number 'Caml1999N012'"]
|
||||
|
||||
... but the `-as-ppx` standalone raises them
|
||||
|
||||
$ ../raiser.exe -as-ppx unknown_version_binary_ast output
|
||||
File "unknown_version_binary_ast", line 1:
|
||||
Error: The input is a binary ast for an unknown version of OCaml with magic number 'Caml1999N012'
|
||||
[1]
|
||||
|
||||
Similar for 'input doesn't exist' errors: they get embedded by the main standalone...
|
||||
|
||||
$ ../raiser.exe -embed-errors -impl non_existing_file
|
||||
[%%ocaml.error "I/O error: non_existing_file: No such file or directory"]
|
||||
|
||||
... but not by the `-as-ppx` standalone
|
||||
|
||||
$ ../raiser.exe -as-ppx non_existing_file output
|
||||
File "non_existing_file", line 1:
|
||||
Error: I/O error: non_existing_file: No such file or directory
|
||||
[1]
|
||||
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue