-
Notifications
You must be signed in to change notification settings - Fork 475
test(top-module): reproduce over-rebuild on unreferenced lib's .mli change #14476
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
ElectreAAS
merged 8 commits into
ocaml:main
from
robinbb:robinbb-test-topmod-over-invalidation
May 19, 2026
+104
−0
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
3192443
test: observational baseline for top-module cctx-wide cmi-dep over-in…
robinbb a107885
test(top-module): use [make_dune_project] helper
robinbb e6d5874
test(top-module): drop [head -5] pipe on initial build line
robinbb a9207cf
test(top-module): isolate the over-invalidation premise from real refs
robinbb 09ca706
test(top-module): replace [stat -c] mtime checks with trace-based ass…
robinbb b255fc0
test(top-module): adopt "Reproduction:" framing per review
robinbb 8573e05
test(top-module): incorporate review feedback
robinbb a90d023
test(top-module): pre-implement deps; edit only the .mli
robinbb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
104 changes: 104 additions & 0 deletions
104
test/blackbox-tests/test-cases/top-module/over-rebuild-from-intf-only-dep.t
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| Reproduction: `dune ocaml top-module` over-rebuilds when an | ||
| unreferenced library's interface changes. The test passes while | ||
| the bug is present; promote when fixed. | ||
|
|
||
| `dune ocaml top-module` synthesises a compile for `m.ml` with the | ||
| `.mli` dropped, so only `m.ml`'s actual references should drive | ||
| the cmi-deps. Instead, the cmi-deps come from the parent library's | ||
| full `(libraries ...)` closure, so editing any of those deps' | ||
| interfaces triggers a rebuild — even libraries referenced ONLY | ||
| from the (dropped) `.mli`. | ||
|
|
||
| Code under test: `src/dune_rules/top_module.ml`. | ||
|
|
||
| $ make_dune_project 3.24 | ||
|
|
||
| `dep_for_intf` is referenced from `m.mli` only. `m.ml` never | ||
| mentions `Dep_for_intf`. | ||
|
|
||
| $ mkdir dep_for_intf | ||
| $ cat > dep_for_intf/dune <<EOF | ||
| > (library (name dep_for_intf)) | ||
| > EOF | ||
| $ cat > dep_for_intf/dep_for_intf.ml <<EOF | ||
| > type t = int | ||
| > let zero = 0 | ||
| > EOF | ||
| $ cat > dep_for_intf/dep_for_intf.mli <<EOF | ||
| > type t = int | ||
| > EOF | ||
|
|
||
| `dep_for_impl` is referenced from `m.ml` only. `m.mli` never | ||
| mentions `Dep_for_impl`. | ||
|
|
||
| $ mkdir dep_for_impl | ||
| $ cat > dep_for_impl/dune <<EOF | ||
| > (library (name dep_for_impl)) | ||
| > EOF | ||
| $ cat > dep_for_impl/dep_for_impl.ml <<EOF | ||
| > let value = 7 | ||
| > let extra = "x" | ||
| > EOF | ||
| $ cat > dep_for_impl/dep_for_impl.mli <<EOF | ||
| > val value : int | ||
| > EOF | ||
|
|
||
| `mylib` declares both libraries in `(libraries ...)` but module | ||
| `m` splits them: `.ml` uses only `Dep_for_impl`; `.mli` uses only | ||
| `Dep_for_intf`. | ||
|
|
||
| $ mkdir mylib | ||
| $ cat > mylib/dune <<EOF | ||
| > (library | ||
| > (name mylib) | ||
| > (libraries dep_for_intf dep_for_impl)) | ||
| > EOF | ||
| $ cat > mylib/m.mli <<EOF | ||
| > val tag : Dep_for_intf.t | ||
| > EOF | ||
| $ cat > mylib/m.ml <<EOF | ||
| > let tag = Dep_for_impl.value | ||
| > EOF | ||
|
|
||
| Initial regular build, then `dune ocaml top-module mylib/m.ml`: | ||
|
|
||
| $ dune build @check | ||
| $ dune ocaml top-module mylib/m.ml > /dev/null 2>&1 | ||
|
|
||
|
robinbb marked this conversation as resolved.
|
||
| Control: edit `dep_for_impl`'s `.mli` to expose `extra`. `m.ml` | ||
| references `Dep_for_impl.value`, so its top-module compile depends | ||
| on `dep_for_impl.cmi`. Rebuild expected. The trace contains the | ||
| `mylib__M.cmo` build action. | ||
|
|
||
| $ cat > dep_for_impl/dep_for_impl.mli <<EOF | ||
| > val value : int | ||
| > val extra : string | ||
| > EOF | ||
| $ dune ocaml top-module mylib/m.ml --trace-file=_build/trace-impl.csexp > /dev/null 2>&1 | ||
| $ dune trace cat --trace-file=_build/trace-impl.csexp | jq -s 'include "dune"; [.[] | targetsMatchingFilter(test("\\.topmod/mylib/m\\.ml/mylib__M\\.cmo$"))]' | ||
| [ | ||
| { | ||
| "target_files": [ | ||
| "_build/default/.topmod/mylib/m.ml/mylib__M.cmo" | ||
| ] | ||
| } | ||
| ] | ||
|
robinbb marked this conversation as resolved.
|
||
|
|
||
| Probe: edit `dep_for_intf`'s `.mli` to expose `zero`. `m.ml` never | ||
| references `Dep_for_intf` — the only reference was in the | ||
| discarded `m.mli`. The top-module compile rebuilds anyway; this is | ||
| the over-invalidation. | ||
|
|
||
| $ cat > dep_for_intf/dep_for_intf.mli <<EOF | ||
| > type t = int | ||
| > val zero : t | ||
| > EOF | ||
| $ dune ocaml top-module mylib/m.ml --trace-file=_build/trace-intf.csexp > /dev/null 2>&1 | ||
| $ dune trace cat --trace-file=_build/trace-intf.csexp | jq -s 'include "dune"; [.[] | targetsMatchingFilter(test("\\.topmod/mylib/m\\.ml/mylib__M\\.cmo$"))]' | ||
| [ | ||
| { | ||
| "target_files": [ | ||
|
robinbb marked this conversation as resolved.
|
||
| "_build/default/.topmod/mylib/m.ml/mylib__M.cmo" | ||
| ] | ||
| } | ||
| ] | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.