This commit is contained in:
parent
aa2ff7b2f0
commit
2f3113f55d
11742 changed files with 1223940 additions and 0 deletions
|
|
@ -0,0 +1,132 @@
|
|||
; Too many drivers
|
||||
(library
|
||||
(name foo2)
|
||||
(public_name foo.2)
|
||||
(modules foo2)
|
||||
(preprocess (pps ppx1 ppx2)))
|
||||
|
||||
; Incompatible with Dune
|
||||
(library
|
||||
(name foo3)
|
||||
(public_name foo.3)
|
||||
(modules foo3)
|
||||
(preprocess (pps ppx_other)))
|
||||
|
||||
; Incompatible cookies
|
||||
(library
|
||||
(name foo4)
|
||||
(public_name foo.4)
|
||||
(modules foo4)
|
||||
(preprocess (pps ppx3 ppx4)))
|
||||
|
||||
(rule (with-stdout-to foo1.ml (echo "")))
|
||||
(rule (with-stdout-to foo2.ml (echo "")))
|
||||
(rule (with-stdout-to foo3.ml (echo "")))
|
||||
(rule (with-stdout-to foo4.ml (echo "")))
|
||||
|
||||
(library
|
||||
(name ppx1)
|
||||
(public_name foo.ppx1)
|
||||
(kind ppx_rewriter)
|
||||
(modules ())
|
||||
(libraries driver1))
|
||||
|
||||
(library
|
||||
(name ppx2)
|
||||
(public_name foo.ppx2)
|
||||
(kind ppx_rewriter)
|
||||
(modules ())
|
||||
(libraries driver2))
|
||||
|
||||
(library
|
||||
(name ppx3)
|
||||
(public_name foo.ppx3)
|
||||
(kind (ppx_rewriter (cookies (germany "spritzgeback"))))
|
||||
(modules ())
|
||||
(libraries driver2))
|
||||
|
||||
(library
|
||||
(name ppx4)
|
||||
(public_name foo.ppx4)
|
||||
(kind (ppx_rewriter (cookies (germany "lebkuchen") (library-name "%{library-name}"))))
|
||||
(modules ())
|
||||
(libraries driver2))
|
||||
|
||||
(library
|
||||
(name driver1)
|
||||
(public_name foo.driver1)
|
||||
(modules ())
|
||||
(ppx.driver (main "(fun () -> assert false)")))
|
||||
|
||||
(library
|
||||
(name driver2)
|
||||
(public_name foo.driver2)
|
||||
(modules ())
|
||||
(ppx.driver (main "(fun () -> assert false)")))
|
||||
|
||||
(library
|
||||
(name ppx_other)
|
||||
(public_name foo.ppx-other)
|
||||
(modules ())
|
||||
(kind ppx_rewriter))
|
||||
|
||||
(library
|
||||
(name driver_print_args)
|
||||
(modules ())
|
||||
(ppx.driver (main "(fun () -> Array.iter print_endline Sys.argv)")))
|
||||
|
||||
(rule (with-stdout-to test_ppx_args.ml (echo "")))
|
||||
|
||||
(library
|
||||
(name ppx_with_cookies_print_args)
|
||||
(kind (ppx_rewriter
|
||||
(cookies (italy "%{env:ITALY=undefined}")
|
||||
(france "%{env:FRANCE=undefined}"))))
|
||||
(modules ())
|
||||
(libraries driver_print_args))
|
||||
|
||||
(env
|
||||
(_
|
||||
(env-vars
|
||||
(ITALY "Biscotti")
|
||||
(FRANCE "Petit Beurre")
|
||||
(AMERICA "Oreo")
|
||||
(ENGLAND "Snickerdoodle"))))
|
||||
|
||||
(library
|
||||
(name test_ppx_args)
|
||||
(modules test_ppx_args)
|
||||
(preprocess
|
||||
(pps -arg1 driver_print_args ppx_with_cookies_print_args -arg2 -arg3=%{env:AMERICA=undefined} --
|
||||
-foo bar %{env:ENGLAND=undefined})))
|
||||
|
||||
(library
|
||||
(name driver_print_tool)
|
||||
(public_name foo.driver_print_tool)
|
||||
(kind ppx_rewriter)
|
||||
(modules ())
|
||||
(libraries compiler-libs.common)
|
||||
(ppx.driver (main "\| (fun () ->
|
||||
"\| Ast_mapper.run_main (fun argv ->
|
||||
"\| Printf.eprintf "tool name: %s\nargs:%s\n"
|
||||
"\| (Ast_mapper.tool_name ())
|
||||
"\| (String.concat " " argv);
|
||||
"\| Ast_mapper.default_mapper))
|
||||
)))
|
||||
|
||||
(library
|
||||
(name ppx_with_cookies_print_tool)
|
||||
(kind (ppx_rewriter
|
||||
(cookies (italy "%{env:ITALY=undefined}")
|
||||
(france "%{env:FRANCE=undefined}"))))
|
||||
(modules ())
|
||||
(libraries driver_print_tool))
|
||||
|
||||
(rule (with-stdout-to test_ppx_staged.ml (echo "")))
|
||||
|
||||
(library
|
||||
(name test_ppx_staged)
|
||||
(modules test_ppx_staged)
|
||||
(preprocess
|
||||
(staged_pps -arg1 driver_print_tool ppx_with_cookies_print_tool -arg2 -arg3=%{env:AMERICA=undefined} --
|
||||
-foo bar %{env:ENGLAND=undefined})))
|
||||
|
|
@ -0,0 +1 @@
|
|||
(lang dune 1.10)
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
Too many drivers
|
||||
|
||||
$ dune build foo2.cma
|
||||
File "dune", line 6, characters 13-28:
|
||||
6 | (preprocess (pps ppx1 ppx2)))
|
||||
^^^^^^^^^^^^^^^
|
||||
Error: Too many incompatible ppx drivers were found: foo.driver1 and
|
||||
foo.driver2.
|
||||
[1]
|
||||
|
||||
Not compatible with Dune
|
||||
|
||||
$ dune build foo3.cma
|
||||
File "dune", line 13, characters 13-28:
|
||||
13 | (preprocess (pps ppx_other)))
|
||||
^^^^^^^^^^^^^^^
|
||||
Error: No ppx driver were found. It seems that ppx_other is not compatible
|
||||
with Dune. Examples of ppx rewriters that are compatible with Dune are ones
|
||||
using ocaml-migrate-parsetree, ppxlib or ppx_driver.
|
||||
[1]
|
||||
|
||||
Incompatible Cookies
|
||||
|
||||
$ dune build foo4.cma
|
||||
File "dune", line 20, characters 13-28:
|
||||
20 | (preprocess (pps ppx3 ppx4)))
|
||||
^^^^^^^^^^^^^^^
|
||||
Error: foo.ppx3 and foo.ppx4 have inconsistent requests for cookie "germany";
|
||||
foo.ppx3 requests "spritzgeback" and foo.ppx4 requests "lebkuchen"
|
||||
[1]
|
||||
|
||||
Same, but with error pointing to .ppx
|
||||
|
||||
$ dune build .ppx/foo.ppx1+foo.ppx2/ppx.exe
|
||||
Error: invalid ppx key for _build/default/.ppx/foo.ppx1+foo.ppx2/ppx.exe
|
||||
[1]
|
||||
|
||||
$ dune build .ppx/foo.ppx-other/ppx.exe
|
||||
Error: invalid ppx key for _build/default/.ppx/foo.ppx-other/ppx.exe
|
||||
[1]
|
||||
|
||||
Test the argument syntax
|
||||
|
||||
$ dune build test_ppx_args.cma
|
||||
.ppx/7e2e4f08e99331b1c723b81d3aa870ba/ppx.exe
|
||||
-arg1
|
||||
-arg2
|
||||
-arg3=Oreo
|
||||
-foo
|
||||
bar
|
||||
Snickerdoodle
|
||||
--cookie
|
||||
france="Petit Beurre"
|
||||
--cookie
|
||||
italy="Biscotti"
|
||||
--cookie
|
||||
library-name="test_ppx_args"
|
||||
-o
|
||||
test_ppx_args.pp.ml
|
||||
--impl
|
||||
test_ppx_args.ml
|
||||
--as-ppx
|
||||
File "dune", lines 100-101, characters 2-136:
|
||||
100 | (pps -arg1 driver_print_args ppx_with_cookies_print_args -arg2 -arg3=%{env:AMERICA=undefined} --
|
||||
101 | -foo bar %{env:ENGLAND=undefined})))
|
||||
Error: Rule failed to generate the following targets:
|
||||
- test_ppx_args.pp.ml
|
||||
[1]
|
||||
|
||||
Test that going through the -ppx option of the compiler works
|
||||
|
||||
$ dune build test_ppx_staged.cma
|
||||
tool name: ocamlc
|
||||
args:--as-ppx -arg1 -arg2 -arg3=Oreo -foo bar Snickerdoodle --cookie france="Petit Beurre" --cookie italy="Biscotti" --cookie library-name="test_ppx_staged"
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
(library
|
||||
(public_name replacesdriver)
|
||||
(libraries compiler-libs.common)
|
||||
(modules ())
|
||||
(ppx.driver
|
||||
(main "(fun () -> print_endline \"replacesdriver\"; Array.iter print_endline Sys.argv)")
|
||||
(replaces testdriver)))
|
||||
|
|
@ -0,0 +1 @@
|
|||
(lang dune 1.1)
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
(library
|
||||
(public_name testdriver)
|
||||
(libraries compiler-libs.common)
|
||||
(ppx.driver (main "(fun () -> Array.iter print_endline Sys.argv)")))
|
||||
|
|
@ -0,0 +1 @@
|
|||
(lang dune 1.6)
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
(rule (with-stdout-to driveruser.ml (echo "")))
|
||||
|
||||
(library
|
||||
(name driveruser)
|
||||
(preprocess (pps -arg1 replacesdriver -arg2 -- -foo bar)))
|
||||
|
|
@ -0,0 +1 @@
|
|||
(lang dune 1.6)
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
(rule (with-stdout-to driveruser.ml (echo "")))
|
||||
|
||||
(library
|
||||
(public_name replacesdriver)
|
||||
(libraries compiler-libs.common)
|
||||
(modules ())
|
||||
(ppx.driver
|
||||
(main "(fun () -> print_endline \"replacesdriver\"; Array.iter print_endline Sys.argv)")
|
||||
(replaces testdriver)))
|
||||
|
||||
(library
|
||||
(name driveruser)
|
||||
(preprocess (pps -arg1 replacesdriver -arg2 -- -foo bar)))
|
||||
|
|
@ -0,0 +1 @@
|
|||
(lang dune 1.9)
|
||||
|
|
@ -0,0 +1,75 @@
|
|||
Test using installed drivers
|
||||
|
||||
$ dune build --root driver @install
|
||||
Entering directory 'driver'
|
||||
Leaving directory 'driver'
|
||||
$ OCAMLPATH=driver/_build/install/default/lib dune build --root use-external-driver driveruser.cma
|
||||
Entering directory 'use-external-driver'
|
||||
.ppx/d1c2c0cf2b61b462226db18f72732070/ppx.exe
|
||||
-arg1
|
||||
-arg2
|
||||
-foo
|
||||
bar
|
||||
--cookie
|
||||
library-name="driveruser"
|
||||
-o
|
||||
driveruser.pp.ml
|
||||
--impl
|
||||
driveruser.ml
|
||||
--as-ppx
|
||||
File "dune", line 6, characters 13-53:
|
||||
6 | (preprocess (pps -arg1 testdriver -arg2 -- -foo bar)))
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
Error: Rule failed to generate the following targets:
|
||||
- driveruser.pp.ml
|
||||
Leaving directory 'use-external-driver'
|
||||
[1]
|
||||
|
||||
$ OCAMLPATH=driver/_build/install/default/lib dune build --root replaces driveruser.cma
|
||||
Entering directory 'replaces'
|
||||
replacesdriver
|
||||
.ppx/5c2c5102d9f019e3d5eee93d6abe2029/ppx.exe
|
||||
-arg1
|
||||
-arg2
|
||||
-foo
|
||||
bar
|
||||
--cookie
|
||||
library-name="driveruser"
|
||||
-o
|
||||
driveruser.pp.ml
|
||||
--impl
|
||||
driveruser.ml
|
||||
--as-ppx
|
||||
File "dune", line 13, characters 13-57:
|
||||
13 | (preprocess (pps -arg1 replacesdriver -arg2 -- -foo bar)))
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
Error: Rule failed to generate the following targets:
|
||||
- driveruser.pp.ml
|
||||
Leaving directory 'replaces'
|
||||
[1]
|
||||
|
||||
$ OCAMLPATH=driver/_build/install/default/lib dune build --root driver-replaces @install
|
||||
Entering directory 'driver-replaces'
|
||||
Leaving directory 'driver-replaces'
|
||||
$ OCAMLPATH=driver/_build/install/default/lib:driver-replaces/_build/install/default/lib dune build --root replaces-external driveruser.cma
|
||||
Entering directory 'replaces-external'
|
||||
replacesdriver
|
||||
.ppx/5c2c5102d9f019e3d5eee93d6abe2029/ppx.exe
|
||||
-arg1
|
||||
-arg2
|
||||
-foo
|
||||
bar
|
||||
--cookie
|
||||
library-name="driveruser"
|
||||
-o
|
||||
driveruser.pp.ml
|
||||
--impl
|
||||
driveruser.ml
|
||||
--as-ppx
|
||||
File "dune", line 5, characters 13-57:
|
||||
5 | (preprocess (pps -arg1 replacesdriver -arg2 -- -foo bar)))
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
Error: Rule failed to generate the following targets:
|
||||
- driveruser.pp.ml
|
||||
Leaving directory 'replaces-external'
|
||||
[1]
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
(rule (with-stdout-to driveruser.ml (echo "")))
|
||||
|
||||
(library
|
||||
(name driveruser)
|
||||
(modules driveruser)
|
||||
(preprocess (pps -arg1 testdriver -arg2 -- -foo bar)))
|
||||
|
|
@ -0,0 +1 @@
|
|||
(lang dune 1.1)
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
(library
|
||||
(name driver_print_args)
|
||||
(kind ppx_rewriter)
|
||||
(modules ())
|
||||
(ppx.driver (main "(fun () -> Array.iter print_endline Sys.argv)")))
|
||||
|
||||
(rule (with-stdout-to test_ppx_args.ml (echo "")))
|
||||
|
||||
(library
|
||||
(name ppx_with_cookies_print_args)
|
||||
(kind (ppx_rewriter
|
||||
(cookies (italy "%{env:ITALY=undefined}")
|
||||
(france "%{env:FRANCE=undefined}"))))
|
||||
(modules ())
|
||||
(libraries driver_print_args))
|
||||
|
||||
(env (_ (env-vars (ITALY "Biscotti") (FRANCE "Petit Beurre") (AMERICA "Oreo") (ENGLAND "Snickerdoodle"))))
|
||||
|
||||
(library
|
||||
(name test_ppx_args)
|
||||
(modules test_ppx_args)
|
||||
(preprocess
|
||||
(pps -arg1 driver_print_args ppx_with_cookies_print_args -arg2 -arg3=%{env:AMERICA=undefined} --
|
||||
-foo bar %{env:ENGLAND=undefined} %{read-lines:ppx-args})))
|
||||
|
||||
(library
|
||||
(name driver_print_tool)
|
||||
(public_name foo.driver_print_tool)
|
||||
(kind ppx_rewriter)
|
||||
(modules ())
|
||||
(libraries compiler-libs.common)
|
||||
(ppx.driver (main "\| (fun () ->
|
||||
"\| Ast_mapper.run_main (fun argv ->
|
||||
"\| Printf.eprintf "tool name: %s\nargs:%s\n"
|
||||
"\| (Ast_mapper.tool_name ())
|
||||
"\| (String.concat " " argv);
|
||||
"\| Ast_mapper.default_mapper))
|
||||
)))
|
||||
|
||||
(library
|
||||
(name ppx_with_cookies_print_tool)
|
||||
(kind (ppx_rewriter
|
||||
(cookies (italy "%{env:ITALY=undefined}")
|
||||
(france "%{env:FRANCE=undefined}"))))
|
||||
(modules ())
|
||||
(libraries driver_print_tool))
|
||||
|
|
@ -0,0 +1 @@
|
|||
(lang dune 3.3)
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
Args
|
||||
From
|
||||
A
|
||||
File
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
Test the argument syntax with list expansion allowed (dune > 3.2)
|
||||
|
||||
$ dune build
|
||||
.ppx/7e2e4f08e99331b1c723b81d3aa870ba/ppx.exe
|
||||
-arg1
|
||||
-arg2
|
||||
-arg3=Oreo
|
||||
-foo
|
||||
bar
|
||||
Snickerdoodle
|
||||
Args
|
||||
From
|
||||
A
|
||||
File
|
||||
--cookie
|
||||
france="Petit Beurre"
|
||||
--cookie
|
||||
italy="Biscotti"
|
||||
--cookie
|
||||
library-name="test_ppx_args"
|
||||
-o
|
||||
test_ppx_args.pp.ml
|
||||
--impl
|
||||
test_ppx_args.ml
|
||||
--as-ppx
|
||||
File "dune", lines 23-24, characters 3-161:
|
||||
23 | (pps -arg1 driver_print_args ppx_with_cookies_print_args -arg2 -arg3=%{env:AMERICA=undefined} --
|
||||
24 | -foo bar %{env:ENGLAND=undefined} %{read-lines:ppx-args})))
|
||||
Error: Rule failed to generate the following targets:
|
||||
- test_ppx_args.pp.ml
|
||||
[1]
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
No ppx driver found
|
||||
|
||||
$ echo '(lang dune 2.8)' > dune-project
|
||||
$ cat >dune <<EOF
|
||||
> (library
|
||||
> (name foo1)
|
||||
> (public_name foo.1)
|
||||
> (modules foo1)
|
||||
> (preprocess (pps)))
|
||||
> EOF
|
||||
$ dune build
|
||||
File "dune", line 5, characters 13-18:
|
||||
5 | (preprocess (pps)))
|
||||
^^^^^
|
||||
Error: You must specify at least one ppx rewriter.
|
||||
[1]
|
||||
Loading…
Add table
Add a link
Reference in a new issue