Skip to content

Commit e511ed8

Browse files
committed
test: lock in incremental-rebuild for root_module-aliased deps
Add a regression test asserting that a consumer using [(root_module ...)] to alias a dependency rebuilds when the dependency's [.mli] changes, and does not rebuild when only the dependency's [.ml] changes. The property holds today via dune's existing glob-over-objdir mechanism; the test guards it as a specification against future inter-library-dependency-tracking changes (notably the per-module filter being developed in Signed-off-by: Robin Bate Boerop <me@robinbb.com> ocaml#14116).
1 parent b08e79a commit e511ed8

1 file changed

Lines changed: 53 additions & 0 deletions

File tree

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
A consumer library that uses [(root_module ...)] to alias one of
2+
its dependencies is rebuilt when the dependency's interface
3+
changes, and not rebuilt when only the dependency's
4+
implementation changes. This locks in the incremental-rebuild
5+
property for [Root]-aliased dependencies that any future change
6+
to dune's inter-library-dependency tracking must preserve.
7+
8+
$ cat > dune-project <<EOF
9+
> (lang dune 3.0)
10+
> EOF
11+
12+
$ mkdir lib1 lib2
13+
$ cat > lib1/dune <<EOF
14+
> (library (name lib1))
15+
> EOF
16+
$ cat > lib1/lib1.ml <<EOF
17+
> let extra = 0
18+
> let greeting = "hello-" ^ string_of_int extra
19+
> EOF
20+
$ cat > lib1/lib1.mli <<EOF
21+
> val greeting : string
22+
> EOF
23+
24+
$ cat > lib2/dune <<EOF
25+
> (library (name lib2) (libraries lib1) (root_module root))
26+
> EOF
27+
$ cat > lib2/lib2.ml <<EOF
28+
> let () = print_endline Root.Lib1.greeting
29+
> EOF
30+
31+
$ dune build @check
32+
33+
Editing only [lib1.mli] (the [.ml] is unchanged) changes
34+
[lib1.cmi] and must invalidate [lib2]:
35+
36+
$ cat > lib1/lib1.mli <<EOF
37+
> val greeting : string
38+
> val extra : int
39+
> EOF
40+
$ dune build @check
41+
$ dune trace cat | jq -s 'include "dune"; [.[] | targetsMatchingFilter(test("\\.lib2\\.objs/"))] | length > 0'
42+
true
43+
44+
Editing only [lib1.ml] (no [.mli] change) leaves [lib1.cmi]
45+
untouched, so [lib2] is not rebuilt:
46+
47+
$ cat > lib1/lib1.ml <<EOF
48+
> let extra = 1
49+
> let greeting = "hello-" ^ string_of_int extra
50+
> EOF
51+
$ dune build @check
52+
$ dune trace cat | jq -s 'include "dune"; [.[] | targetsMatchingFilter(test("\\.lib2\\.objs/"))] | length'
53+
0

0 commit comments

Comments
 (0)