Skip to content

Commit ed7214c

Browse files
rgrinbergAlizter
authored andcommitted
test: demonstrate pointless running of ocamldep on the root module
Signed-off-by: Rudi Grinberg <[email protected]> <!-- ps-id: 0e596563-4448-4087-b051-1eef7a4c9848 -->
1 parent 7777d3f commit ed7214c

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
Demonstrate if we're running ocamldep for the root module. There should be no
2+
need to do so since this module cannot depend on any other module in the same
3+
compilation unit.
4+
5+
$ cat >dune-project <<EOF
6+
> (lang dune 3.20)
7+
> EOF
8+
9+
$ mkdir lib/
10+
$ cat >lib/dune <<EOF
11+
> (library
12+
> (name bar))
13+
> EOF
14+
$ touch lib/bar.ml
15+
16+
$ cat >dune <<EOF
17+
> (library
18+
> (name foo)
19+
> (libraries bar)
20+
> (root_module root))
21+
> EOF
22+
23+
$ dune build foo.cma
24+
25+
$ find _build/default/.foo.objs | grep -i root | sort -u
26+
_build/default/.foo.objs/byte/foo__Root.cmi
27+
_build/default/.foo.objs/byte/foo__Root.cmo
28+
_build/default/.foo.objs/byte/foo__Root.cmt
29+
_build/default/.foo.objs/foo__Root.impl.all-deps
30+
_build/default/.foo.objs/foo__Root.impl.d
31+
32+
Not only is running ocamldep wasteful, but it can also lead to cycles:
33+
34+
$ cat >bar.ml <<EOF
35+
> module X = Root.Bar
36+
> EOF
37+
38+
$ dune build foo.cma
39+
Error: Dependency cycle between:
40+
_build/default/.foo.objs/foo__Bar.impl.all-deps
41+
-> _build/default/.foo.objs/foo__Root.impl.all-deps
42+
-> _build/default/.foo.objs/foo__Bar.impl.all-deps
43+
-> required by _build/default/.foo.objs/byte/foo__Bar.cmo
44+
-> required by _build/default/foo.cma
45+
[1]

0 commit comments

Comments
 (0)