Skip to content

Commit b0d33fe

Browse files
committed
test: regression guard for [(root_module ...)] + [(libraries ...)]
Adds [test-cases/per-module-lib-deps/root-module-tight-deps.t]. Asserts that a library declaring [(root_module ...)] alongside [(libraries ...)] builds correctly when its modules reference the dep library through the Root alias. Root modules carry their own dep-rule shape: dune synthesises the [.d] file for the Root module (no [.all-deps], to avoid the cycle that would arise from a Root that references itself transitively). Any future change to inter-library dep handling that misses the synthesised-[.d] path would regress this scenario. Forward-looking guard. The build path on current main uses a broad-glob over the dep library's objdir, so the test passes trivially today. The synthesised-[.d] path is still exercised by rule generation, and that is what the test pins. Signed-off-by: Robin Bate Boerop <me@robinbb.com>
1 parent 824816b commit b0d33fe

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
A library declaring [(root_module ...)] alongside [(libraries
2+
...)] must build correctly when its modules reference the dep
3+
library through the Root alias.
4+
5+
Root modules carry their own dep-rule shape: dune synthesises the
6+
[.d] file for the Root module (no [.all-deps], to avoid the cycle
7+
that would arise from a Root that references itself transitively).
8+
Any future change to inter-library dep handling that misses the
9+
synthesised-[.d] path would regress this scenario.
10+
11+
$ cat > dune-project <<EOF
12+
> (lang dune 3.23)
13+
> EOF
14+
15+
[dep_lib]: an unwrapped dep library.
16+
17+
$ mkdir dep_lib
18+
$ cat > dep_lib/dune <<EOF
19+
> (library (name dep_lib))
20+
> EOF
21+
$ cat > dep_lib/dep_lib.ml <<EOF
22+
> let v = 1
23+
> EOF
24+
$ cat > dep_lib/dep_lib.mli <<EOF
25+
> val v : int
26+
> EOF
27+
28+
[consumer_lib]: declares [(root_module root) (libraries dep_lib)]
29+
and references [Dep_lib] through [Root].
30+
31+
$ mkdir consumer_lib
32+
$ cat > consumer_lib/dune <<EOF
33+
> (library
34+
> (name consumer_lib)
35+
> (libraries dep_lib)
36+
> (root_module root))
37+
> EOF
38+
$ cat > consumer_lib/m.ml <<EOF
39+
> let _ = Root.Dep_lib.v
40+
> EOF
41+
42+
$ dune build @check

0 commit comments

Comments
 (0)