Skip to content

test: opaque profile coverage for inter-library dep tracking#14331

Merged
Alizter merged 5 commits into
ocaml:mainfrom
robinbb:robinbb-opaque-coverage
Apr 29, 2026
Merged

test: opaque profile coverage for inter-library dep tracking#14331
Alizter merged 5 commits into
ocaml:mainfrom
robinbb:robinbb-opaque-coverage

Conversation

@robinbb
Copy link
Copy Markdown
Collaborator

@robinbb robinbb commented Apr 25, 2026

Three new cram tests under test/blackbox-tests/test-cases/per-module-lib-deps/:

  • opaque-cmx-deps-local.t — a local lib appears in the consumer's .cmx dep set as *.cmi only under dev (opaque=true), and as both *.cmi and *.cmx under release (opaque=false).
  • opaque-cmx-deps-external.t — an external library (findlib-resolved unix) appears as both globs under both profiles, pinning that the Lib.is_local lib guard in groups_for_cm_kind is the intended behaviour.
  • opaque-mli-change.t — a .mli change in a dep triggers a consumer rebuild under both profiles; pins that the dev-mode optimisation is about cmx propagation, not cmi propagation.

Together with the existing opaque.t (which covers .ml-only-change rebuild behaviour) these document the four directly-observable consequences of -opaque. Future regressions in any of the four code paths will fail a self-explanatory test rather than slipping through.

Test plan

  • dune runtest test/blackbox-tests/test-cases/per-module-lib-deps/opaque-cmx-deps-local.t passes.
  • dune runtest test/blackbox-tests/test-cases/per-module-lib-deps/opaque-cmx-deps-external.t passes.
  • dune runtest test/blackbox-tests/test-cases/per-module-lib-deps/opaque-mli-change.t passes.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds blackbox cram coverage for how -opaque affects per-module inter-library dependency tracking across dev/release profiles, ensuring future regressions show up as targeted, self-explanatory test failures.

Changes:

  • Add a test that pins .cmx dep glob differences for local libraries between release (tracks *.cmx) and dev (tracks only *.cmi).
  • Add a test that pins .cmx deps for an external library (unix) remain tracked in both profiles.
  • Add a test that pins .mli changes still trigger consumer rebuilds in both profiles (i.e., opaque only affects .cmx propagation).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
test/blackbox-tests/test-cases/per-module-lib-deps/opaque-cmx-deps-local.t Verifies local-lib .cmx glob deps are present in release but omitted in dev.
test/blackbox-tests/test-cases/per-module-lib-deps/opaque-cmx-deps-external.t Verifies external-lib (unix) .cmx glob deps remain present in both profiles.
test/blackbox-tests/test-cases/per-module-lib-deps/opaque-mli-change.t Verifies .mli changes force consumer rebuilds under both dev and release profiles.

Comment thread test/blackbox-tests/test-cases/per-module-lib-deps/opaque-mli-change.t Outdated
Comment thread test/blackbox-tests/test-cases/per-module-lib-deps/opaque-mli-change.t Outdated
robinbb added a commit to robinbb/dune that referenced this pull request Apr 25, 2026
The [length > 0] assertions were too permissive and would mask a
spurious extra rebuild. Replace with the exact count under each
profile (which happens to be 2 in both cases).

Addresses Copilot's review feedback:
ocaml#14331 (comment)

Signed-off-by: Robin Bate Boerop <me@robinbb.com>
@robinbb robinbb requested a review from Copilot April 25, 2026 17:51
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comment thread test/blackbox-tests/test-cases/per-module-lib-deps/opaque-cmx-deps-external.t Outdated
@robinbb robinbb self-assigned this Apr 25, 2026
robinbb added a commit to robinbb/dune that referenced this pull request Apr 25, 2026
[unix] is a separate library bundled with the OCaml distribution
and resolved through findlib; it isn't part of [Stdlib] proper.

Addresses Copilot's review feedback:
ocaml#14331 (comment)

Signed-off-by: Robin Bate Boerop <me@robinbb.com>
@robinbb robinbb requested a review from Copilot April 25, 2026 18:26
robinbb added a commit to robinbb/dune that referenced this pull request Apr 25, 2026
The exact-count assertions inherited from ocaml#14331 ([2] under both
profiles) now observe [1] under both, because this PR's per-module
filter narrows the consumer's dep set enough that one of the
post-edit rebuild events the previous (glob-only) deps would have
recorded no longer fires.

Promote the assertions to [1] so the test continues to pass and
documents the tighter behaviour produced by this PR.

Signed-off-by: Robin Bate Boerop <me@robinbb.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

@robinbb robinbb marked this pull request as ready for review April 25, 2026 18:39
robinbb added a commit to robinbb/dune that referenced this pull request Apr 26, 2026
The [length > 0] assertions were too permissive and would mask a
spurious extra rebuild. Replace with the exact count under each
profile (which happens to be 2 in both cases).

Addresses Copilot's review feedback:
ocaml#14331 (comment)

Signed-off-by: Robin Bate Boerop <me@robinbb.com>
robinbb added a commit to robinbb/dune that referenced this pull request Apr 26, 2026
[unix] is a separate library bundled with the OCaml distribution
and resolved through findlib; it isn't part of [Stdlib] proper.

Addresses Copilot's review feedback:
ocaml#14331 (comment)

Signed-off-by: Robin Bate Boerop <me@robinbb.com>
robinbb added a commit to robinbb/dune that referenced this pull request Apr 26, 2026
The exact-count assertions inherited from ocaml#14331 ([2] under both
profiles) now observe [1] under both, because this PR's per-module
filter narrows the consumer's dep set enough that one of the
post-edit rebuild events the previous (glob-only) deps would have
recorded no longer fires.

Promote the assertions to [1] so the test continues to pass and
documents the tighter behaviour produced by this PR.

Signed-off-by: Robin Bate Boerop <me@robinbb.com>
robinbb added a commit to robinbb/dune that referenced this pull request Apr 27, 2026
The [length > 0] assertions were too permissive and would mask a
spurious extra rebuild. Replace with the exact count under each
profile (which happens to be 2 in both cases).

Addresses Copilot's review feedback:
ocaml#14331 (comment)

Signed-off-by: Robin Bate Boerop <me@robinbb.com>
robinbb added a commit to robinbb/dune that referenced this pull request Apr 27, 2026
[unix] is a separate library bundled with the OCaml distribution
and resolved through findlib; it isn't part of [Stdlib] proper.

Addresses Copilot's review feedback:
ocaml#14331 (comment)

Signed-off-by: Robin Bate Boerop <me@robinbb.com>
robinbb added a commit to robinbb/dune that referenced this pull request Apr 27, 2026
The exact-count assertions inherited from ocaml#14331 ([2] under both
profiles) now observe [1] under both, because this PR's per-module
filter narrows the consumer's dep set enough that one of the
post-edit rebuild events the previous (glob-only) deps would have
recorded no longer fires.

Promote the assertions to [1] so the test continues to pass and
documents the tighter behaviour produced by this PR.

Signed-off-by: Robin Bate Boerop <me@robinbb.com>
robinbb added 4 commits April 27, 2026 07:22
Three observational tests pinning the visible consequences of dune's
[-opaque] handling in [groups_for_cm_kind]. Together with the
existing [opaque.t] (which covers the [.ml]-only-change rebuild
behaviour) they document the four directly-observable code paths
that depend on the [-opaque] flag.

- [opaque-cmx-deps-local.t]: a local lib's [.cmx] is in the
  consumer's dep set under release; only [.cmi] under dev.
- [opaque-cmx-deps-external.t]: an external (findlib-resolved) lib's
  [.cmx] is in the dep set under both profiles. Pins that the
  [Lib.is_local lib] guard in [groups_for_cm_kind] is intentional.
- [opaque-mli-change.t]: a [.mli] change in a dep rebuilds consumers
  under both profiles. Pins that opaque mode is purely about [.cmx]
  propagation, not [.cmi] propagation.

Future regressions in any of those four code paths fail a specific
test with a self-explanatory name.

Signed-off-by: Robin Bate Boerop <me@robinbb.com>
The preamble comments referenced internal names ([groups_for_cm_kind],
[lib_file_deps.ml], [Lib.is_local lib]). Replace with descriptions
phrased entirely in terms of externally observable behaviour: file
extensions, profile names, and consumer/dep relationships.

Signed-off-by: Robin Bate Boerop <me@robinbb.com>
The [length > 0] assertions were too permissive and would mask a
spurious extra rebuild. Replace with the exact count under each
profile (which happens to be 2 in both cases).

Addresses Copilot's review feedback:
ocaml#14331 (comment)

Signed-off-by: Robin Bate Boerop <me@robinbb.com>
[unix] is a separate library bundled with the OCaml distribution
and resolved through findlib; it isn't part of [Stdlib] proper.

Addresses Copilot's review feedback:
ocaml#14331 (comment)

Signed-off-by: Robin Bate Boerop <me@robinbb.com>
@robinbb robinbb force-pushed the robinbb-opaque-coverage branch from f45d971 to 3500103 Compare April 27, 2026 15:41
robinbb added a commit to robinbb/dune that referenced this pull request Apr 27, 2026
Each of the dep PRs supplying a test in
[per-module-lib-deps/] was renamed per Leonidas's review on
ocaml#14309: generic [libA]/[modA1]-style names replaced by
role-bearing names like [dep_lib]/[spurious_rebuild]. This commit
applies the same renames to this PR's local copies of those tests
so they stay convergent with the dep PRs' canonical versions.

Touches:
- single-module-unreferenced-lib.t (ocaml#14308)
- sibling-unreferenced-lib.t (ocaml#14309)
- unwrapped-tight-deps.t (ocaml#14310)
- lib-vs-lib-name-collision.t (ocaml#14324)
- opaque-mli-change.t, opaque-cmx-deps-local.t (ocaml#14331)
- transitive-unreferenced-lib.t (ocaml#14332)
- wrapped-reexport-via-open-flag.t (ocaml#14346)
- auto-wrapped-child-reexport.t (ocaml#14347)

Pure rename + path/dir adjustments. Count assertions preserved
(this PR's promotions to the post-fix counts are unchanged).
Test suite passes.

Signed-off-by: Robin Bate Boerop <me@robinbb.com>
robinbb added a commit to robinbb/dune that referenced this pull request Apr 27, 2026
The [length > 0] assertions were too permissive and would mask a
spurious extra rebuild. Replace with the exact count under each
profile (which happens to be 2 in both cases).

Addresses Copilot's review feedback:
ocaml#14331 (comment)

Signed-off-by: Robin Bate Boerop <me@robinbb.com>
robinbb added a commit to robinbb/dune that referenced this pull request Apr 27, 2026
[unix] is a separate library bundled with the OCaml distribution
and resolved through findlib; it isn't part of [Stdlib] proper.

Addresses Copilot's review feedback:
ocaml#14331 (comment)

Signed-off-by: Robin Bate Boerop <me@robinbb.com>
robinbb added a commit to robinbb/dune that referenced this pull request Apr 27, 2026
The exact-count assertions inherited from ocaml#14331 ([2] under both
profiles) now observe [1] under both, because this PR's per-module
filter narrows the consumer's dep set enough that one of the
post-edit rebuild events the previous (glob-only) deps would have
recorded no longer fires.

Promote the assertions to [1] so the test continues to pass and
documents the tighter behaviour produced by this PR.

Signed-off-by: Robin Bate Boerop <me@robinbb.com>
robinbb added a commit to robinbb/dune that referenced this pull request Apr 29, 2026
The [length > 0] assertions were too permissive and would mask a
spurious extra rebuild. Replace with the exact count under each
profile (which happens to be 2 in both cases).

Addresses Copilot's review feedback:
ocaml#14331 (comment)

Signed-off-by: Robin Bate Boerop <me@robinbb.com>
robinbb added a commit to robinbb/dune that referenced this pull request Apr 29, 2026
[unix] is a separate library bundled with the OCaml distribution
and resolved through findlib; it isn't part of [Stdlib] proper.

Addresses Copilot's review feedback:
ocaml#14331 (comment)

Signed-off-by: Robin Bate Boerop <me@robinbb.com>
robinbb added a commit to robinbb/dune that referenced this pull request Apr 29, 2026
The exact-count assertions inherited from ocaml#14331 ([2] under both
profiles) now observe [1] under both, because this PR's per-module
filter narrows the consumer's dep set enough that one of the
post-edit rebuild events the previous (glob-only) deps would have
recorded no longer fires.

Promote the assertions to [1] so the test continues to pass and
documents the tighter behaviour produced by this PR.

Signed-off-by: Robin Bate Boerop <me@robinbb.com>
@robinbb robinbb requested a review from Copilot April 29, 2026 00:25
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

Comment thread test/blackbox-tests/test-cases/per-module-lib-deps/opaque-mli-change.t Outdated
Comment thread test/blackbox-tests/test-cases/per-module-lib-deps/opaque-mli-change.t Outdated
Copy link
Copy Markdown
Collaborator

@Alizter Alizter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with copilot, printing the list of rebuilt targets would be better.

@Alizter Alizter self-assigned this Apr 29, 2026
Replace [| length] with the actual list of [target_files] arrays,
matching the pattern used elsewhere in the cluster (e.g.
[single-module-lib.t]). The list spells out which build artifacts
get rebuilt when a dep's [.mli] changes — currently the [.cmi]/
[.cmti] byte rule and the [.cmx]/[.o] native rule for the consumer
[Main] module — so a future regression that adds, removes, or
renames a target produces a self-explanatory diff instead of a
bare numeric mismatch.

Addresses Copilot's review feedback:
ocaml#14331 (comment)

Signed-off-by: Robin Bate Boerop <me@robinbb.com>
@Alizter Alizter merged commit 660552d into ocaml:main Apr 29, 2026
30 of 31 checks passed
robinbb added a commit to robinbb/dune that referenced this pull request Apr 29, 2026
The [length > 0] assertions were too permissive and would mask a
spurious extra rebuild. Replace with the exact count under each
profile (which happens to be 2 in both cases).

Addresses Copilot's review feedback:
ocaml#14331 (comment)

Signed-off-by: Robin Bate Boerop <me@robinbb.com>
robinbb added a commit to robinbb/dune that referenced this pull request Apr 29, 2026
[unix] is a separate library bundled with the OCaml distribution
and resolved through findlib; it isn't part of [Stdlib] proper.

Addresses Copilot's review feedback:
ocaml#14331 (comment)

Signed-off-by: Robin Bate Boerop <me@robinbb.com>
robinbb added a commit to robinbb/dune that referenced this pull request Apr 29, 2026
The exact-count assertions inherited from ocaml#14331 ([2] under both
profiles) now observe [1] under both, because this PR's per-module
filter narrows the consumer's dep set enough that one of the
post-edit rebuild events the previous (glob-only) deps would have
recorded no longer fires.

Promote the assertions to [1] so the test continues to pass and
documents the tighter behaviour produced by this PR.

Signed-off-by: Robin Bate Boerop <me@robinbb.com>
robinbb added a commit to robinbb/dune that referenced this pull request Apr 29, 2026
Replace [| length] with the actual list of [target_files] arrays,
matching the pattern used elsewhere in the cluster (e.g.
[single-module-lib.t]). Under this PR's per-module filter, only
the consumer's native [.cmx]/[.o] rule rebuilds when a dep's
[.mli] changes — the [.cmi]/[.cmti] byte rule is no longer
invalidated.

Mirror of the [opaque-mli-change.t] fix on PR ocaml#14331's branch
[robinbb-opaque-coverage]; the file is shared between the two PRs
since ocaml#14331 is pulled into this branch's base. There the rebuild
list shows two rules ([.cmi]/[.cmti] byte + [.cmx]/[.o] native)
because that PR doesn't apply the per-module filter; here it
shows one because this PR's filter narrows the deps.

Addresses Copilot's review feedback:
ocaml#14331 (comment)

Signed-off-by: Robin Bate Boerop <me@robinbb.com>
@robinbb robinbb deleted the robinbb-opaque-coverage branch April 29, 2026 18:02
robinbb added a commit to robinbb/dune that referenced this pull request Apr 29, 2026
Three cluster tests landed on main as observational baselines
(via PRs ocaml#14308, ocaml#14331, ocaml#14350) recording the trunk-today
rebuild list. With this PR's per-module filter applied, the
[.cmi]/[.cmti] byte rule no longer globs over a dep lib's
objdir for unreferenced sibling modules, so:

- [single-module-unreferenced-lib.t]: [spurious_rebuild]'s
  rebuild count drops from 1 to 0.
- [opaque-mli-change.t]: only the [.cmx]/[.o] native rule
  re-runs (release and dev profile both); the byte rule's deps
  no longer include the changed dep lib's [.cmi].
- [implicit-transitive-deps-false.t]: same — the [.cmx]/[.o]
  native rule re-runs, the byte rule does not.

Promote the asserted [target_files] arrays accordingly. No
behavioural surprise here — all three drops match the design
of the per-module filter; the upstream baselines exist
specifically to be flipped by this PR.

Signed-off-by: Robin Bate Boerop <me@robinbb.com>
robinbb added a commit to robinbb/dune that referenced this pull request Apr 29, 2026
Cluster tests landed on main as observational baselines (via PRs
ocaml#14308, ocaml#14331, ocaml#14350, and the transitive-unreferenced-module
follow-up) recording the trunk rebuild list. With this PR's
per-module filter applied, the [.cmi]/[.cmti] byte rule no longer
globs over a dep lib's objdir for unreferenced sibling modules,
so:

- [single-module-unreferenced-lib.t]: [spurious_rebuild]'s
  rebuild count drops from 1 to 0.
- [opaque-mli-change.t]: only the [.cmx]/[.o] native rule
  re-runs (release and dev profile both); the byte rule's deps
  no longer include the changed dep lib's [.cmi].
- [implicit-transitive-deps-false.t]: same — the [.cmx]/[.o]
  native rule re-runs, the byte rule does not.
- [transitive-unreferenced-module.t]: the consumer doesn't even
  directly reference the transitive lib, so the filter drops it
  entirely; both rules are skipped, [target_files] becomes [[]].

Promote the asserted [target_files] arrays accordingly. No
behavioural surprise here — all four drops match the design of
the per-module filter; the upstream baselines exist specifically
to be flipped by this PR.

Signed-off-by: Robin Bate Boerop <me@robinbb.com>
robinbb added a commit to robinbb/dune that referenced this pull request Apr 29, 2026
Cluster tests landed on main as observational baselines (via PRs
ocaml#14308, ocaml#14331, ocaml#14350, and the transitive-unreferenced-module
follow-up) recording the trunk rebuild list. With this PR's
per-module filter applied, the [.cmi]/[.cmti] byte rule no longer
globs over a dep lib's objdir for unreferenced sibling modules,
so:

- [single-module-unreferenced-lib.t]: [spurious_rebuild]'s
  rebuild count drops from 1 to 0.
- [opaque-mli-change.t]: only the [.cmx]/[.o] native rule
  re-runs (release and dev profile both); the byte rule's deps
  no longer include the changed dep lib's [.cmi].
- [implicit-transitive-deps-false.t]: same — the [.cmx]/[.o]
  native rule re-runs, the byte rule does not.
- [transitive-unreferenced-module.t]: the consumer doesn't even
  directly reference the transitive lib, so the filter drops it
  entirely; both rules are skipped, [target_files] becomes [[]].

Promote the asserted [target_files] arrays accordingly. No
behavioural surprise here — all four drops match the design of
the per-module filter; the upstream baselines exist specifically
to be flipped by this PR.

Signed-off-by: Robin Bate Boerop <me@robinbb.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants