-
Notifications
You must be signed in to change notification settings - Fork 475
test: record consumer rebuild count when shadowed dep lib changes #14324
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
Merged
Changes from all commits
Commits
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
75 changes: 75 additions & 0 deletions
75
test/blackbox-tests/test-cases/per-module-lib-deps/lib-vs-lib-name-collision.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,75 @@ | ||
| Two unwrapped libraries expose an entry module of the same name. | ||
| A consumer library lists both and references the name in its code. | ||
| OCaml's [-I] path resolution picks the lib whose [-I] comes first | ||
| on the command line (the order of declared libraries in | ||
| [(libraries ...)]), so the consumer compiles against that lib's | ||
| version of the module. The other lib's same-named module is | ||
| shadowed — unreachable from consumer code. | ||
|
|
||
| This test is observational: it records the rebuild-target count | ||
| for a consumer module after editing the *shadowed* lib's | ||
| same-named module. The expected count on current [main] is | ||
| positive because cross-library dep tracking is library-level: the | ||
| consumer depends on a glob over each declared library's public | ||
| cmi directory, so any change to the shadowed lib's public cmis | ||
| invalidates the consumer. | ||
|
|
||
| A future per-module dependency filter (#4572) would not | ||
| automatically improve this case: without qualified-path analysis | ||
| the filter cannot know which lib's [Shared] the consumer actually | ||
| resolves through, and must conservatively depend on both. | ||
|
|
||
| See: https://github.com/ocaml/dune/issues/4572 | ||
|
|
||
| $ cat > dune-project <<EOF | ||
| > (lang dune 3.23) | ||
| > EOF | ||
|
|
||
| $ mkdir active_lib | ||
| $ cat > active_lib/dune <<EOF | ||
| > (library (name active_lib) (wrapped false)) | ||
| > EOF | ||
| $ cat > active_lib/shared.ml <<EOF | ||
| > let from_active = "a" | ||
| > EOF | ||
|
|
||
| $ mkdir shadowed_lib | ||
| $ cat > shadowed_lib/dune <<EOF | ||
| > (library (name shadowed_lib) (wrapped false)) | ||
| > EOF | ||
| $ cat > shadowed_lib/shared.ml <<EOF | ||
| > let from_shadowed = "b" | ||
| > EOF | ||
|
|
||
| [consumer_lib] lists [active_lib] first, so [-I active_lib/.objs] | ||
| comes before [-I shadowed_lib/.objs] on the command line and OCaml | ||
| resolves [Shared] to [active_lib/shared.cmi]: | ||
|
|
||
| $ mkdir consumer_lib | ||
| $ cat > consumer_lib/dune <<EOF | ||
| > (library | ||
| > (name consumer_lib) | ||
| > (wrapped false) | ||
| > (libraries active_lib shadowed_lib)) | ||
| > EOF | ||
| $ cat > consumer_lib/consumer.ml <<EOF | ||
| > let _ = Shared.from_active | ||
| > EOF | ||
| $ cat > consumer_lib/filler.ml <<EOF | ||
| > let _ = () | ||
| > EOF | ||
|
|
||
| $ dune build @check | ||
|
|
||
| Edit [shadowed_lib]'s [Shared] — which [consumer] does *not* resolve | ||
| through, because [active_lib] wins under [-I] order. [consumer] | ||
| still rebuilds because its dependency on [shadowed_lib]'s object | ||
| directory is a glob: | ||
|
|
||
| $ cat > shadowed_lib/shared.ml <<EOF | ||
| > let from_shadowed = "b" | ||
| > let also_from_shadowed = 42 | ||
| > EOF | ||
| $ dune build @check | ||
| $ dune trace cat | jq -s 'include "dune"; [.[] | targetsMatchingFilter(test("consumer_lib/\\.consumer_lib\\.objs/byte/consumer\\."))] | length > 0' | ||
| true | ||
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.