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,4 @@
(library
(name a1)
(public_name a.1)
(libraries b))

View file

@ -0,0 +1,3 @@
(library
(name a2)
(public_name a.2))

View file

@ -0,0 +1,4 @@
(library
(name b)
(public_name b)
(libraries a.2))

View file

@ -0,0 +1,32 @@
(alias
(name package-cycle)
(deps (package a) (package b)))
(alias
(name simple-repro-case)
(deps x y))
(rule (copy %{read:u} y))
(rule (copy %{read:v} x))
(rule (with-stdout-to u (system "printf x")))
(rule (with-stdout-to v (system "printf y")))
(rule (progn (copy x2 x1) (cat x4)))
(rule (copy x3 x2))
(rule (copy %{read:x3-x2-dyn-dep} x3))
(rule (copy x3 x4))
(rule (with-stdout-to x3-x2-dyn-dep (system "printf x2")))
(alias
(name complex-repro-case)
(deps cd1 cd3))
(rule (copy cd2 cd1))
(rule (copy cd4 cd3))
(rule (copy %{read:dcd3} cd2))
(rule (copy %{read:dcd1} cd4))
(rule (with-stdout-to dcd3 (system "printf cd3")))
(rule (with-stdout-to dcd1 (system "printf cd1")))

View file

@ -0,0 +1,3 @@
let x = A.x
let () = B.y

View file

@ -0,0 +1,8 @@
; a.ml -> c.mli -> b.mli
(executable
(name a))
(alias
(name indirect-deps)
(deps a.exe))

View file

@ -0,0 +1,69 @@
These tests is a regression test for the detection of dynamic cycles.
In all tests, we have a cycle that only becomes apparent after we
start running things. In the past, the error was only reported during
the second run of dune.
$ dune build @package-cycle
Error: Dependency cycle between:
alias a/.a-files
-> alias b/.b-files
-> alias a/.a-files
-> required by alias package-cycle in dune:1
[1]
$ dune build @simple-repro-case
Error: Dependency cycle between:
_build/default/y
-> _build/default/x
-> _build/default/y
-> required by alias simple-repro-case in dune:5
[1]
$ dune build x1
Error: Dependency cycle between:
_build/default/x2
-> _build/default/x3
-> _build/default/x2
-> required by _build/default/x1
[1]
$ dune build @complex-repro-case
Error: Dependency cycle between:
_build/default/cd3
-> _build/default/cd2
-> _build/default/cd1
-> _build/default/cd4
-> _build/default/cd3
-> required by alias complex-repro-case in dune:22
[1]
In some cases the dependencies are indirect (#666, #2818).
They can make the error message worse.
For the simple case, dependencies are enough to detect a cycle with a nice
error message.
$ echo 'val x : unit' > indirect/c.mli
$ dune build @indirect-deps
Error: dependency cycle between modules in _build/default/indirect:
A
-> C
-> A
-> required by _build/default/indirect/a.exe
-> required by alias indirect/indirect-deps in indirect/dune:6
[1]
But when the cycle is due to the cmi files themselves, the message becomes
cryptic and can involve unrelated files:
$ echo 'val xx : B.t' >> indirect/c.mli
$ dune build @indirect-deps
Error: Dependency cycle between:
_build/default/indirect/.a.eobjs/a.impl.all-deps
-> _build/default/indirect/.a.eobjs/b.impl.all-deps
-> _build/default/indirect/.a.eobjs/c.intf.all-deps
-> _build/default/indirect/.a.eobjs/a.impl.all-deps
-> required by _build/default/indirect/a.exe
-> required by alias indirect/indirect-deps in indirect/dune:6
[1]