-
Notifications
You must be signed in to change notification settings - Fork 413
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* test(melange): add test exercising #7104 Signed-off-by: Antonio Nuno Monteiro <[email protected]>
- Loading branch information
1 parent
5de6e9f
commit b21df14
Showing
13 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
test/blackbox-tests/test-cases/melange/virtual_lib_compilation.t/dune
This file contains 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,11 @@ | ||
(executable | ||
(name ml) | ||
(modules ml) | ||
(libraries vlib impl_ml)) | ||
|
||
(melange.emit | ||
(target output) | ||
(alias melange) | ||
(entries mel) | ||
(libraries vlib impl_melange) | ||
(module_system commonjs)) |
3 changes: 3 additions & 0 deletions
3
test/blackbox-tests/test-cases/melange/virtual_lib_compilation.t/dune-project
This file contains 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 @@ | ||
(lang dune 3.8) | ||
|
||
(using melange 0.1) |
4 changes: 4 additions & 0 deletions
4
test/blackbox-tests/test-cases/melange/virtual_lib_compilation.t/impl_melange/dune
This file contains 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,4 @@ | ||
(library | ||
(name impl_melange) | ||
(modes melange) | ||
(implements vlib)) |
1 change: 1 addition & 0 deletions
1
test/blackbox-tests/test-cases/melange/virtual_lib_compilation.t/impl_melange/virt.ml
This file contains 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 @@ | ||
let t = "melange" |
3 changes: 3 additions & 0 deletions
3
test/blackbox-tests/test-cases/melange/virtual_lib_compilation.t/impl_ml/dune
This file contains 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 @@ | ||
(library | ||
(name impl_ml) | ||
(implements vlib)) |
1 change: 1 addition & 0 deletions
1
test/blackbox-tests/test-cases/melange/virtual_lib_compilation.t/impl_ml/virt.ml
This file contains 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 @@ | ||
let t = "ml" |
1 change: 1 addition & 0 deletions
1
test/blackbox-tests/test-cases/melange/virtual_lib_compilation.t/mel.ml
This file contains 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 @@ | ||
print_endline Virt.t |
1 change: 1 addition & 0 deletions
1
test/blackbox-tests/test-cases/melange/virtual_lib_compilation.t/ml.ml
This file contains 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 @@ | ||
let () = print_endline Vlib_impl.hello |
37 changes: 37 additions & 0 deletions
37
test/blackbox-tests/test-cases/melange/virtual_lib_compilation.t/run.t
This file contains 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,37 @@ | ||
Test virtual lib in an exe / melange environment | ||
|
||
The native build passes | ||
|
||
$ dune exec ./ml.exe --display=short | ||
ocamldep impl_ml/.impl_ml.objs/virt.impl.d | ||
ocamldep vlib/.vlib.objs/shared.impl.d | ||
ocamldep vlib/.vlib.objs/virt.intf.d | ||
ocamldep vlib/.vlib.objs/vlib_impl.impl.d | ||
ocamlc vlib/.vlib.objs/byte/virt.{cmi,cmti} | ||
ocamlc vlib/.vlib.objs/byte/vlib_impl.{cmi,cmo,cmt} | ||
ocamlopt vlib/.vlib.objs/native/vlib_impl.{cmx,o} | ||
ocamlc vlib/.vlib.objs/byte/shared.{cmi,cmo,cmt} | ||
ocamlc .ml.eobjs/byte/dune__exe__Ml.{cmi,cmti} | ||
ocamlopt vlib/.vlib.objs/native/shared.{cmx,o} | ||
ocamlopt impl_ml/.impl_ml.objs/native/virt.{cmx,o} | ||
ocamlopt .ml.eobjs/native/dune__exe__Ml.{cmx,o} | ||
ocamlopt impl_ml/impl_ml.{a,cmxa} | ||
ocamlopt ml.exe | ||
Hello from ml | ||
|
||
Melange can't produce a `.cmj` solely from a virtual module `.cmi`, because it | ||
needs to consult the `.cmj` files of dependencies to know where the require | ||
call should be emitted | ||
|
||
$ dune build @melange --display=short | ||
ocamldep impl_melange/.impl_melange.objs/virt.impl.d | ||
melc vlib/.vlib.objs/melange/virt.{cmi,cmti} | ||
melc vlib/.vlib.objs/melange/vlib_impl.{cmi,cmj,cmt} (exit 2) | ||
File "vlib/vlib_impl.ml", line 1: | ||
Error: Virt not found, it means either the module does not exist or it is a namespace | ||
[1] | ||
|
||
$ output=_build/default/output/mel.js | ||
$ test -f "$output" && node "$output" | ||
[1] | ||
|
5 changes: 5 additions & 0 deletions
5
test/blackbox-tests/test-cases/melange/virtual_lib_compilation.t/vlib/dune
This file contains 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,5 @@ | ||
(library | ||
(name vlib) | ||
(wrapped false) | ||
(modes :standard melange) | ||
(virtual_modules virt)) |
1 change: 1 addition & 0 deletions
1
test/blackbox-tests/test-cases/melange/virtual_lib_compilation.t/vlib/shared.ml
This file contains 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 @@ | ||
let t = Vlib_impl.hello |
1 change: 1 addition & 0 deletions
1
test/blackbox-tests/test-cases/melange/virtual_lib_compilation.t/vlib/virt.mli
This file contains 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 @@ | ||
val t : string |
1 change: 1 addition & 0 deletions
1
test/blackbox-tests/test-cases/melange/virtual_lib_compilation.t/vlib/vlib_impl.ml
This file contains 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 @@ | ||
let hello = "Hello from " ^ Virt.t |