-
Notifications
You must be signed in to change notification settings - Fork 454
feat: %{cmt} and %{cmti} artifact variables #12634
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
+241
−19
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
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
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,3 @@ | ||
| - Add support for `%{cmt:...}` and `%{cmti:...}` variables to reference | ||
| compiled annotation files (.cmt and .cmti) containing typed abstract syntax | ||
| trees with location and type information. (#12634, grants #12633, @Alizter) |
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
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
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
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
167 changes: 167 additions & 0 deletions
167
test/blackbox-tests/test-cases/variables-for-artifacts/cmt-cmti.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,167 @@ | ||
| Test that %{cmt:...} and %{cmti:...} variables work correctly. | ||
|
|
||
| $ cat > dune-project <<EOF | ||
| > (lang dune 3.20) | ||
| > EOF | ||
|
|
||
| Create a library with both .ml and .mli files: | ||
|
|
||
| $ cat > mylib.mli <<EOF | ||
| > val hello : string | ||
| > EOF | ||
|
|
||
| $ cat > mylib.ml <<EOF | ||
| > let hello = "world" | ||
| > EOF | ||
|
|
||
| $ cat > dune <<EOF | ||
| > (library | ||
| > (name mylib)) | ||
| > | ||
| > (rule | ||
| > (alias show-cmt) | ||
| > (deps %{cmt:mylib}) | ||
| > (action | ||
| > (echo "cmt file: %{cmt:mylib}\n"))) | ||
| > | ||
| > (rule | ||
| > (alias show-cmti) | ||
| > (deps %{cmti:mylib}) | ||
| > (action | ||
| > (echo "cmti file: %{cmti:mylib}\n"))) | ||
| > EOF | ||
|
|
||
| This feature is guarded behind dune lang 3.21: | ||
|
|
||
| $ dune build @show-cmt @show-cmti | ||
| File "dune", line 6, characters 7-19: | ||
| 6 | (deps %{cmt:mylib}) | ||
| ^^^^^^^^^^^^ | ||
| Error: %{cmt:..} is only available since version 3.21 of the dune language. | ||
| Please update your dune-project file to have (lang dune 3.21). | ||
| [1] | ||
|
|
||
| $ cat > dune-project <<EOF | ||
| > (lang dune 3.21) | ||
| > EOF | ||
|
|
||
| Build and check that cmt and cmti files are found: | ||
|
|
||
| $ dune build @show-cmt | ||
| cmt file: .mylib.objs/byte/mylib.cmt | ||
|
|
||
| $ dune build @show-cmti | ||
| cmti file: .mylib.objs/byte/mylib.cmti | ||
|
|
||
| Test with a module that has only implementation (no interface): | ||
|
|
||
| $ cat > only_impl.ml <<EOF | ||
| > let x = 42 | ||
| > EOF | ||
|
|
||
| $ cat >> dune <<EOF | ||
| > (rule | ||
| > (alias show-impl-only-cmt) | ||
| > (deps %{cmt:only_impl}) | ||
| > (action | ||
| > (echo "impl-only cmt: %{cmt:only_impl}\n"))) | ||
| > | ||
| > (rule | ||
| > (alias show-impl-only-cmti) | ||
| > (deps %{cmti:only_impl}) | ||
| > (action | ||
| > (echo "impl-only cmti: %{cmti:only_impl}\n"))) | ||
| > EOF | ||
|
|
||
| $ dune build @show-impl-only-cmt | ||
| impl-only cmt: .mylib.objs/byte/mylib__Only_impl.cmt | ||
|
|
||
| $ dune build @show-impl-only-cmti | ||
| impl-only cmti: .mylib.objs/byte/mylib__Only_impl.cmt | ||
|
|
||
| Test with a module that has only interface (no implementation): | ||
|
|
||
| $ cat > only_intf.mli <<EOF | ||
| > val y : int | ||
| > EOF | ||
|
|
||
| $ cat > dune <<EOF | ||
| > (library | ||
| > (name mylib) | ||
| > (modules_without_implementation only_intf)) | ||
| > | ||
| > (rule | ||
| > (alias show-intf-only-cmt) | ||
| > (deps %{cmt:only_intf}) | ||
| > (action | ||
| > (echo "intf-only cmt: %{cmt:only_intf}\n"))) | ||
| > | ||
| > (rule | ||
| > (alias show-intf-only-cmti) | ||
| > (deps %{cmti:only_intf}) | ||
| > (action | ||
| > (echo "intf-only cmti: %{cmti:only_intf}\n"))) | ||
| > EOF | ||
|
|
||
| $ dune build @show-intf-only-cmt | ||
| Error: No rule found for . | ||
| -> required by alias show-intf-only-cmt in dune:5 | ||
| [1] | ||
|
|
||
| $ dune build @show-intf-only-cmti | ||
| intf-only cmti: .mylib.objs/byte/mylib__Only_intf.cmti | ||
|
|
||
| Test error when module does not exist: | ||
|
|
||
| $ cat >> dune <<EOF | ||
| > (alias | ||
| > (name test-nonexistent) | ||
| > (deps %{cmt:nonexistent})) | ||
| > EOF | ||
|
|
||
| $ dune build @test-nonexistent | ||
| File "dune", line 18, characters 7-25: | ||
| 18 | (deps %{cmt:nonexistent})) | ||
| ^^^^^^^^^^^^^^^^^^ | ||
| Error: Module Nonexistent does not exist. | ||
| [1] | ||
|
|
||
| Test with native-only library (bytecode disabled): | ||
|
|
||
| $ cat > native_lib.ml <<EOF | ||
| > let z = 100 | ||
| > EOF | ||
|
|
||
| $ cat > dune <<EOF | ||
| > (library | ||
| > (name native_lib) | ||
| > (modules native_lib) | ||
| > (modes native)) | ||
| > | ||
| > (rule | ||
| > (alias show-native-cmt) | ||
| > (deps %{cmt:native_lib}) | ||
| > (action | ||
| > (echo "native-lib cmt: %{cmt:native_lib}\n"))) | ||
| > EOF | ||
|
|
||
| $ dune build @show-native-cmt --display short | ||
| ocamlc .native_lib.objs/byte/native_lib.{cmi,cmo,cmt} | ||
| native-lib cmt: .native_lib.objs/byte/native_lib.cmt | ||
|
|
||
| $ cat > native_lib.mli <<EOF | ||
| > val z : int | ||
| > EOF | ||
|
|
||
| $ cat >> dune <<EOF | ||
| > (rule | ||
| > (alias show-native-cmti) | ||
| > (deps %{cmti:native_lib}) | ||
| > (action | ||
| > (echo "native-lib cmti: %{cmti:native_lib}\n"))) | ||
| > EOF | ||
|
|
||
| $ dune build @show-native-cmti --display short | ||
| ocamlc .native_lib.objs/byte/native_lib.{cmi,cmti} | ||
| native-lib cmti: .native_lib.objs/byte/native_lib.cmti | ||
|
|
||
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.