Skip to content

test: regression guard for cross-lib reads of unwrapped libs with [private_modules] - #14388

Merged
robinbb merged 1 commit into
ocaml:mainfrom
robinbb:robinbb-test-private-modules
May 1, 2026
Merged

robinbb merged 1 commit into
ocaml:mainfrom
robinbb:robinbb-test-private-modules

Conversation

@robinbb

@robinbb robinbb commented Apr 30, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds test-cases/per-module-lib-deps/private-modules.t, an observational baseline asserting that a consumer of an unwrapped library that uses private_modules builds without error.

Why

When an unwrapped library has private_modules, dune produces public modules' cmis in a separate .objs/public_cmi directory (via a copy rule from the internal object dir), so consumers see only the public cmis on their -I search path. Any future inter-library dependency tracking that emits per-module cmi deps must point at the public cmi path, not the internal one — otherwise the produce-public-cmi rule doesn't run and sandboxed compiles fail to find the cmi.

This pitfall surfaced during #14116 development. The test guards against the same shape of regression in any future inter-library dep-tracking change.

Test plan

  • On main today: dune runtest test/blackbox-tests/test-cases/per-module-lib-deps/private-modules.t passes.
  • Sensitivity-checked by deliberately breaking consumer/c.ml to reference an unbound module — the test diffs against the resulting compile error, confirming the assertion catches build failures.

Companion to the other observational baselines under test-cases/per-module-lib-deps/ (transitive-unreferenced-module.t, cross-lib-ppx.t, etc.): each pins a structural shape that an inter-library filter must respect.

Related: #14116

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds a blackbox regression guard to ensure a consumer can compile against an unwrapped library that uses (private_modules ...), protecting against future inter-library/per-module dependency tracking regressions that might accidentally depend on internal .cmi paths instead of the public ones.

Changes:

  • Add a new blackbox test case private-modules.t under per-module-lib-deps/.
  • Test sets up an unwrapped library with one public module that depends on a private module, plus a separate consumer library that references only the public module.
  • Asserts the build succeeds (intended to catch regressions where public .cmi materialization isn’t triggered/available to the consumer).

@robinbb
robinbb force-pushed the robinbb-test-private-modules branch 2 times, most recently from 96c8d45 to 82ee202 Compare April 30, 2026 23:15
@robinbb
robinbb requested a review from Copilot April 30, 2026 23:15

Copilot AI left a comment

Copy link
Copy Markdown

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 1 out of 1 changed files in this pull request and generated no new comments.

@robinbb
robinbb marked this pull request as ready for review April 30, 2026 23:39
@robinbb
robinbb force-pushed the robinbb-test-private-modules branch from 82ee202 to 196cb45 Compare May 1, 2026 01:05
…ivate_modules]

Adds [test-cases/per-module-lib-deps/private-modules.t]. Documents that a consumer of an unwrapped library that uses [private_modules] builds without error today.

Companion to the other observational baselines under [test-cases/per-module-lib-deps/]: each pins a structural shape that an inter-library filter must respect.

Signed-off-by: Robin Bate Boerop <[email protected]>
@robinbb
robinbb force-pushed the robinbb-test-private-modules branch from 196cb45 to d62a088 Compare May 1, 2026 14:09
@robinbb
robinbb requested a review from Copilot May 1, 2026 14:17

Copilot AI left a comment

Copy link
Copy Markdown

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 1 out of 1 changed files in this pull request and generated no new comments.

@robinbb
robinbb requested a review from Leonidas-from-XIV May 1, 2026 14:23
@robinbb
robinbb dismissed Leonidas-from-XIV’s stale review May 1, 2026 16:30

I have made the requested change, but don't want to wait for the reviewer to verify that.

@robinbb
robinbb merged commit 9c7b7f5 into ocaml:main May 1, 2026
33 checks passed
@robinbb
robinbb deleted the robinbb-test-private-modules branch May 1, 2026 16:30
@Alizter Alizter added this to the 3.24.0 milestone Jul 8, 2026
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.

4 participants