This commit is contained in:
swrup 2025-11-11 02:07:51 +01:00
parent aa2ff7b2f0
commit 2f3113f55d
11742 changed files with 1223940 additions and 0 deletions

View file

@ -0,0 +1 @@
(lang dune 3.1)

View file

@ -0,0 +1,36 @@
When compiling vendored code, all alerts should be disabled
$ cat > dune << EOF
> (rule
> (alias no-alerts-please)
> (deps vendored/lib.cmxa)
> (action (echo "There should be no OCaml alerts!")))
> EOF
$ dune build @no-alerts-please
File "vendored/lib.ml", line 1, characters 8-24:
1 | let x = Trigger_alerts.x
^^^^^^^^^^^^^^^^
Alert alertx: Lib__.Trigger_alerts.x
You should not use x
File "vendored/lib.ml", line 3, characters 8-24:
3 | let y = Trigger_alerts.y
^^^^^^^^^^^^^^^^
Alert alerty: Lib__.Trigger_alerts.y
You should not use y
File "vendored/lib.ml", line 1, characters 8-24:
1 | let x = Trigger_alerts.x
^^^^^^^^^^^^^^^^
Alert alertx: Lib__.Trigger_alerts.x
You should not use x
File "vendored/lib.ml", line 3, characters 8-24:
3 | let y = Trigger_alerts.y
^^^^^^^^^^^^^^^^
Alert alerty: Lib__.Trigger_alerts.y
You should not use y
There should be no OCaml alerts!
$ echo '(vendored_dirs vendored)' >> dune
$ dune clean
$ dune build @no-alerts-please
There should be no OCaml alerts!

View file

@ -0,0 +1,2 @@
(library
(name lib))

View file

@ -0,0 +1 @@
(lang dune 3.1)

View file

@ -0,0 +1,3 @@
let x = Trigger_alerts.x
let y = Trigger_alerts.y

View file

@ -0,0 +1,3 @@
let x = 0
let y = 0

View file

@ -0,0 +1,5 @@
val x : int
[@@alert alertx "You should not use x"]
val y : int
[@@alert alerty "You should not use y"]

View file

@ -0,0 +1,3 @@
(vendored_dirs *)
(data_only_dirs *)

View file

@ -0,0 +1,6 @@
The same directory cannot be marked as both vendored and data-only
$ dune build
Error: Directory dir was marked as data_only and vendored, it can't be marked
as both.
[1]

View file

@ -0,0 +1,53 @@
Make sure that vendored packages are kept by -p.
In the following test the package "bar" is vendored. We make sure that
"-p" never masks it.
$ mkdir -p vendor/bar
$ cat >dune-project <<EOF
> (lang dune 2.1)
> (package (name foo))
> EOF
$ cat >dune <<EOF
> (executable
> (name foo)
> (libraries bar))
> (vendored_dirs vendor)
> EOF
$ cat >foo.ml<<EOF
> print_endline Bar.message
> EOF
$ cat >vendor/bar/dune-project <<EOF
> (lang dune 2.1)
> (package (name bar))
> EOF
$ cat >vendor/bar/dune <<EOF
> (library
> (public_name bar))
> EOF
$ cat >vendor/bar/bar.ml <<EOF
> let message = "Hello from the bar!"
> EOF
Without filtering anything:
$ dune exec ./foo.exe
Hello from the bar!
Keeping only "foo" via "-p" shouldn't mask "bar" since it is vendored:
$ dune exec -p foo ./foo.exe
Hello from the bar!
Asking to keep "bar" makes no sense since it is vendored:
$ dune exec -p foo,bar ./foo.exe
Error: Package bar is vendored and so will never be masked. It is redundant
to pass it to --only-packages.
[1]

View file

@ -0,0 +1 @@
(data_only_dirs a/b/c)

View file

@ -0,0 +1,9 @@
Only direct subdirectories can be marked as data-only
$ dune build
File "dune", line 1, characters 16-21:
1 | (data_only_dirs a/b/c)
^^^^^
Error: only immediate sub-directories may be specified.
Hint: to ignore a/b/c, write "(data_only_dirs c)" in a/b/dune
[1]

View file

@ -0,0 +1 @@
(vendored_dirs a/b)

View file

@ -0,0 +1,10 @@
Only direct subdirectories can be marked as vendored
$ dune build
File "dune", line 1, characters 15-18:
1 | (vendored_dirs a/b)
^^^
Error: only immediate sub-directories may be specified.
Hint: to ignore a/b, write "(vendored_dirs b)" in a/dune
[1]

View file

@ -0,0 +1,34 @@
Make sure that `dune install` does not install vendored packages.
In the following example, the main package is "foo" and "bar" is a
vendored package that shouldn't be installed.
$ mkdir -p vendor/bar
$ touch file
$ touch vendor/bar/file
$ cat >dune-project <<EOF
> (lang dune 2.1)
> (package (name foo))
> EOF
$ cat >dune <<EOF
> (install (section lib) (files file))
> (vendored_dirs vendor)
> EOF
$ cat >vendor/bar/dune-project <<EOF
> (lang dune 2.1)
> (package (name bar))
> EOF
$ cat >vendor/bar/dune <<EOF
> (install (section lib) (files file))
> EOF
$ dune build @install
The following command should produce no output:
$ dune install --prefix _install --display short 2>&1 | grep bar
[1]

View file

@ -0,0 +1 @@
(lang dune 2.0)

View file

@ -0,0 +1 @@
(vendored_dirs *)

View file

@ -0,0 +1,2 @@
(lang dune 2.0)
(name vendored)

View file

@ -0,0 +1,2 @@
(library
(public_name vendored))

View file

@ -0,0 +1 @@
let say_hello () = Printf.printf "Hello from vendored lib!\n"

View file

@ -0,0 +1,3 @@
(test
(name test)
(libraries vendored))

View file

@ -0,0 +1 @@
let () = Vendored.say_hello ()

View file

@ -0,0 +1,3 @@
(library
(public_name main)
(libraries vendored))

View file

@ -0,0 +1,3 @@
let _ = Vendored.say_hello
let say_hello () = Printf.printf "Hello from main lib!\n"

View file

@ -0,0 +1,9 @@
Vendored directories should be traversed to find targets so that they are built
when they are depend upon
$ dune build --debug-dependency-path
Aliases should not be resolved in vendored sub directories
$ dune runtest
Hello from main lib!

View file

@ -0,0 +1,3 @@
(test
(name test)
(libraries main))

View file

@ -0,0 +1 @@
let () = Main.say_hello ()

View file

@ -0,0 +1,24 @@
This test verifies dune's behavior with respect to duplicate packages
First we verify that packages alone do not cause duplication errors:
$ mkdir -p vendor/pkg/vendor/duped/
$ mkdir -p vendor/duped/
$ touch vendor/pkg/vendor/duped/duped.opam
$ touch vendor/duped/duped.opam
$ cat >dune-project <<EOF
> (lang dune 2.8)
> EOF
$ cat >dune <<EOF
> (vendored_dirs vendor)
> EOF
$ cat >vendor/pkg/dune <<EOF
> (vendored_dirs vendor)
> EOF
$ dune build @all
However, adding dune-project files causes the duplicate detection to fire:
$ cp dune-project ./vendor/duped/
$ cp dune-project ./vendor/pkg/vendor/duped/
$ dune build @all
Error: The package "duped" is defined more than once:
- vendor/pkg/vendor/duped/duped.opam:1
- vendor/duped/duped.opam:1
[1]

View file

@ -0,0 +1 @@
(vendored_dirs *)

View file

@ -0,0 +1 @@
(lang dune 1.10)

View file

@ -0,0 +1,9 @@
The vendored_dirs stanza is available from version 1.11 of the dune language
$ dune build
File "dune", line 1, characters 0-17:
1 | (vendored_dirs *)
^^^^^^^^^^^^^^^^^
Error: 'vendored_dirs' is only available since version 1.11 of the dune
language. Please update your dune-project file to have (lang dune 1.11).
[1]

View file

@ -0,0 +1,2 @@
(data_only_dirs a b)
(vendored_dirs c d)

View file

@ -0,0 +1 @@
(lang dune 2.1)

View file

@ -0,0 +1,3 @@
Multiple direct subdirectories can be marked as data-only or vendored
$ dune build

View file

@ -0,0 +1,30 @@
A public library shouldn't be allowed to depend on a vendored library.
A public library that depends on a vendored library is impossible to install,
since we cannot install the vendored artifacts.
$ cat >dune-project <<EOF
> (lang dune 3.7)
> (package (name foo))
> EOF
$ mkdir -p vendor/mypkg
$ cat >vendor/mypkg/dune-project <<EOF
> (lang dune 3.8)
> (package (name mypkg))
> EOF
$ cat >vendor/mypkg/dune <<EOF
> (library
> (name invendor)
> (public_name mypkg.invendor))
> EOF
$ cat >dune <<EOF
> (vendored_dirs vendor)
> (library
> (libraries mypkg.invendor)
> (public_name foo))
> EOF
$ dune build foo.cma

View file

@ -0,0 +1 @@
(data_only_dirs .)

View file

@ -0,0 +1 @@
(lang dune 2.1)

View file

@ -0,0 +1,9 @@
The current directory cannot be marked as data-only
$ dune build
File "dune", line 1, characters 16-17:
1 | (data_only_dirs .)
^
Error: invalid sub-directory name "."
Hint: did you mean (data_only_dirs *)?
[1]

View file

@ -0,0 +1 @@
(vendored_dirs .)

View file

@ -0,0 +1 @@
(lang dune 2.1)

View file

@ -0,0 +1,9 @@
The current directory cannot be marked as vendored
$ dune build
File "dune", line 1, characters 15-16:
1 | (vendored_dirs .)
^
Error: invalid sub-directory name "."
Hint: did you mean (vendored_dirs *)?
[1]

View file

@ -0,0 +1,10 @@
(alias
(name no-warnings-please)
(deps vendored/lib.cmxa))
(alias
(name no-warnings-please)
(deps vendored-two/lib2.cmxa)
(action (echo "There should be no OCaml warning!")))
(vendored_dirs vendored vendored-two)

View file

@ -0,0 +1 @@
(lang dune 1.11)

View file

@ -0,0 +1,4 @@
When compiling vendored code, all warnings should be disabled
$ dune build @no-warnings-please
There should be no OCaml warning!

View file

@ -0,0 +1,2 @@
(library
(name lib2))

View file

@ -0,0 +1,2 @@
let do_something = function
| [] -> ()

View file

@ -0,0 +1,2 @@
(library
(name lib))

View file

@ -0,0 +1,2 @@
let do_something = function
| [] -> ()