From e4d71c4c3fd5aeddddc016ad8444946ace3fd087 Mon Sep 17 00:00:00 2001 From: Antonio Nuno Monteiro Date: Wed, 1 Mar 2023 09:25:25 -0800 Subject: [PATCH] test(melange): add test exercising #7104 Signed-off-by: Antonio Nuno Monteiro --- .../melange/virtual_lib_compilation.t/dune | 11 +++++ .../virtual_lib_compilation.t/dune-project | 3 ++ .../impl_melange/dune | 4 ++ .../impl_melange/virt.ml | 1 + .../virtual_lib_compilation.t/impl_ml/dune | 3 ++ .../virtual_lib_compilation.t/impl_ml/virt.ml | 1 + .../melange/virtual_lib_compilation.t/mel.ml | 1 + .../melange/virtual_lib_compilation.t/ml.ml | 1 + .../melange/virtual_lib_compilation.t/run.t | 42 +++++++++++++++++++ .../virtual_lib_compilation.t/vlib/dune | 5 +++ .../virtual_lib_compilation.t/vlib/shared.ml | 1 + .../virtual_lib_compilation.t/vlib/virt.mli | 1 + .../vlib/vlib_impl.ml | 1 + 13 files changed, 75 insertions(+) create mode 100644 test/blackbox-tests/test-cases/melange/virtual_lib_compilation.t/dune create mode 100644 test/blackbox-tests/test-cases/melange/virtual_lib_compilation.t/dune-project create mode 100644 test/blackbox-tests/test-cases/melange/virtual_lib_compilation.t/impl_melange/dune create mode 100644 test/blackbox-tests/test-cases/melange/virtual_lib_compilation.t/impl_melange/virt.ml create mode 100644 test/blackbox-tests/test-cases/melange/virtual_lib_compilation.t/impl_ml/dune create mode 100644 test/blackbox-tests/test-cases/melange/virtual_lib_compilation.t/impl_ml/virt.ml create mode 100644 test/blackbox-tests/test-cases/melange/virtual_lib_compilation.t/mel.ml create mode 100644 test/blackbox-tests/test-cases/melange/virtual_lib_compilation.t/ml.ml create mode 100644 test/blackbox-tests/test-cases/melange/virtual_lib_compilation.t/run.t create mode 100644 test/blackbox-tests/test-cases/melange/virtual_lib_compilation.t/vlib/dune create mode 100644 test/blackbox-tests/test-cases/melange/virtual_lib_compilation.t/vlib/shared.ml create mode 100644 test/blackbox-tests/test-cases/melange/virtual_lib_compilation.t/vlib/virt.mli create mode 100644 test/blackbox-tests/test-cases/melange/virtual_lib_compilation.t/vlib/vlib_impl.ml diff --git a/test/blackbox-tests/test-cases/melange/virtual_lib_compilation.t/dune b/test/blackbox-tests/test-cases/melange/virtual_lib_compilation.t/dune new file mode 100644 index 00000000000..e18f48bc534 --- /dev/null +++ b/test/blackbox-tests/test-cases/melange/virtual_lib_compilation.t/dune @@ -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)) diff --git a/test/blackbox-tests/test-cases/melange/virtual_lib_compilation.t/dune-project b/test/blackbox-tests/test-cases/melange/virtual_lib_compilation.t/dune-project new file mode 100644 index 00000000000..f40bf8c4a59 --- /dev/null +++ b/test/blackbox-tests/test-cases/melange/virtual_lib_compilation.t/dune-project @@ -0,0 +1,3 @@ +(lang dune 3.8) + +(using melange 0.1) diff --git a/test/blackbox-tests/test-cases/melange/virtual_lib_compilation.t/impl_melange/dune b/test/blackbox-tests/test-cases/melange/virtual_lib_compilation.t/impl_melange/dune new file mode 100644 index 00000000000..e6f5041f496 --- /dev/null +++ b/test/blackbox-tests/test-cases/melange/virtual_lib_compilation.t/impl_melange/dune @@ -0,0 +1,4 @@ +(library + (name impl_melange) + (modes melange) + (implements vlib)) diff --git a/test/blackbox-tests/test-cases/melange/virtual_lib_compilation.t/impl_melange/virt.ml b/test/blackbox-tests/test-cases/melange/virtual_lib_compilation.t/impl_melange/virt.ml new file mode 100644 index 00000000000..d815f6d0e58 --- /dev/null +++ b/test/blackbox-tests/test-cases/melange/virtual_lib_compilation.t/impl_melange/virt.ml @@ -0,0 +1 @@ +let t = "melange" diff --git a/test/blackbox-tests/test-cases/melange/virtual_lib_compilation.t/impl_ml/dune b/test/blackbox-tests/test-cases/melange/virtual_lib_compilation.t/impl_ml/dune new file mode 100644 index 00000000000..30a7d62189c --- /dev/null +++ b/test/blackbox-tests/test-cases/melange/virtual_lib_compilation.t/impl_ml/dune @@ -0,0 +1,3 @@ +(library + (name impl_ml) + (implements vlib)) diff --git a/test/blackbox-tests/test-cases/melange/virtual_lib_compilation.t/impl_ml/virt.ml b/test/blackbox-tests/test-cases/melange/virtual_lib_compilation.t/impl_ml/virt.ml new file mode 100644 index 00000000000..6a9a3521b4b --- /dev/null +++ b/test/blackbox-tests/test-cases/melange/virtual_lib_compilation.t/impl_ml/virt.ml @@ -0,0 +1 @@ +let t = "ml" diff --git a/test/blackbox-tests/test-cases/melange/virtual_lib_compilation.t/mel.ml b/test/blackbox-tests/test-cases/melange/virtual_lib_compilation.t/mel.ml new file mode 100644 index 00000000000..c25ecb35241 --- /dev/null +++ b/test/blackbox-tests/test-cases/melange/virtual_lib_compilation.t/mel.ml @@ -0,0 +1 @@ +print_endline Virt.t diff --git a/test/blackbox-tests/test-cases/melange/virtual_lib_compilation.t/ml.ml b/test/blackbox-tests/test-cases/melange/virtual_lib_compilation.t/ml.ml new file mode 100644 index 00000000000..73dcbfa9be1 --- /dev/null +++ b/test/blackbox-tests/test-cases/melange/virtual_lib_compilation.t/ml.ml @@ -0,0 +1 @@ +let () = print_endline Virt.t diff --git a/test/blackbox-tests/test-cases/melange/virtual_lib_compilation.t/run.t b/test/blackbox-tests/test-cases/melange/virtual_lib_compilation.t/run.t new file mode 100644 index 00000000000..b4ed8203aa5 --- /dev/null +++ b/test/blackbox-tests/test-cases/melange/virtual_lib_compilation.t/run.t @@ -0,0 +1,42 @@ +Test virtual lib in an exe / melange environment + + $ dune build @melange --display=short + ocamldep impl_melange/.impl_melange.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 + melc vlib/.vlib.objs/melange/virt.{cmi,cmti} + melc vlib/.vlib.objs/melange/vlib_impl.{cmi,cmj,cmt} + melc vlib/.vlib.objs/melange/shared.{cmi,cmj,cmt} + melc output/vlib/vlib_impl.js + melc impl_melange/.impl_melange.objs/melange/virt.{cmj,cmt} + melc output/vlib/shared.js + melc .output.mobjs/melange/melange__Mel.{cmi,cmj,cmt} + melc output/impl_melange/virt.js + melc output/mel.js + $ output=_build/default/output/mel.js + $ test -f "$output" && node "$output" + melange + + $ dune exec ./ml.exe --display=short + ocamldep impl_ml/.impl_ml.objs/virt.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 + ml + $ ls _build/default/vlib/.vlib.objs/byte + shared.cmi + shared.cmo + shared.cmt + virt.cmi + virt.cmti + vlib_impl.cmi + vlib_impl.cmo + vlib_impl.cmt diff --git a/test/blackbox-tests/test-cases/melange/virtual_lib_compilation.t/vlib/dune b/test/blackbox-tests/test-cases/melange/virtual_lib_compilation.t/vlib/dune new file mode 100644 index 00000000000..b66794a49c3 --- /dev/null +++ b/test/blackbox-tests/test-cases/melange/virtual_lib_compilation.t/vlib/dune @@ -0,0 +1,5 @@ +(library + (name vlib) + (wrapped false) + (modes :standard melange) + (virtual_modules virt)) diff --git a/test/blackbox-tests/test-cases/melange/virtual_lib_compilation.t/vlib/shared.ml b/test/blackbox-tests/test-cases/melange/virtual_lib_compilation.t/vlib/shared.ml new file mode 100644 index 00000000000..94967d3d91e --- /dev/null +++ b/test/blackbox-tests/test-cases/melange/virtual_lib_compilation.t/vlib/shared.ml @@ -0,0 +1 @@ +let t = Vlib_impl.hello diff --git a/test/blackbox-tests/test-cases/melange/virtual_lib_compilation.t/vlib/virt.mli b/test/blackbox-tests/test-cases/melange/virtual_lib_compilation.t/vlib/virt.mli new file mode 100644 index 00000000000..cd7e75f75fb --- /dev/null +++ b/test/blackbox-tests/test-cases/melange/virtual_lib_compilation.t/vlib/virt.mli @@ -0,0 +1 @@ +val t : string diff --git a/test/blackbox-tests/test-cases/melange/virtual_lib_compilation.t/vlib/vlib_impl.ml b/test/blackbox-tests/test-cases/melange/virtual_lib_compilation.t/vlib/vlib_impl.ml new file mode 100644 index 00000000000..7bc0913f44f --- /dev/null +++ b/test/blackbox-tests/test-cases/melange/virtual_lib_compilation.t/vlib/vlib_impl.ml @@ -0,0 +1 @@ +let hello = "Hello from " ^ Virt.t