Skip to content

Commit

Permalink
Add test for standalone driver support of old binary ASTs
Browse files Browse the repository at this point in the history
Signed-off-by: Nathan Rebours <[email protected]>
  • Loading branch information
NathanReb committed Feb 19, 2024
1 parent 18c14b6 commit 3b7af3f
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/driver/standalone-supports-old-binary-ast/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
(executable
(name identity_standalone)
(libraries ppxlib)
(modules identity_standalone))

(executable
(name print_magic_number)
(libraries astlib)
(modules print_magic_number))

(cram
(enabled_if
(or
(= %{system} linux)
(= %{system} linux_elf)
(= %{system} elf)
(= %{system} linux_eabihf)
(= %{system} linux_eabi)))
(deps identity_standalone.exe print_magic_number.exe))
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
let () = Ppxlib.Driver.standalone ()
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
let magic_length = String.length Astlib.Config.ast_impl_magic_number
let buf = Bytes.create magic_length
let len = input stdin buf 0 magic_length
let s = Bytes.sub_string buf 0 len
let () = Printf.printf "Magic number: %s" s
Binary file not shown.
14 changes: 14 additions & 0 deletions test/driver/standalone-supports-old-binary-ast/test.t/run.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Binary AST's of any by ppxlib supported OCaml version are supported.
The version is preserved.

$ cat 406_binary_ast | ../print_magic_number.exe
Magic number: Caml1999N022

$ ../identity_standalone.exe --intf 406_binary_ast -o transformed --dump-ast
File "_none_", line 1:
Error: Internal error: invalid [@@ocaml.ppx.context { load_path }] pair syntax
[1]

$ ../print_magic_number.exe < transformed
cannot open transformed: No such file
[2]

0 comments on commit 3b7af3f

Please sign in to comment.