From 67b5acae49fda2f82873c12509b7e68bef3b292b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Ojeda=20B=C3=A4r?= Date: Tue, 8 Oct 2019 23:41:56 +0200 Subject: [PATCH] Add test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Nicolás Ojeda Bär --- .../test-cases/deprecated-library-name/run.t | 159 ++++++++++++++++++ 1 file changed, 159 insertions(+) diff --git a/test/blackbox-tests/test-cases/deprecated-library-name/run.t b/test/blackbox-tests/test-cases/deprecated-library-name/run.t index 761f3b7bb680..1b4a58e476d6 100644 --- a/test/blackbox-tests/test-cases/deprecated-library-name/run.t +++ b/test/blackbox-tests/test-cases/deprecated-library-name/run.t @@ -93,3 +93,162 @@ that wasn't found: Error: Library "a" not found. Hint: try: dune external-lib-deps --missing c/prog.exe [1] + +Test that we can migrate top-level libraries +-------------------------------------------- + + $ mkdir d + +First the motivating case. + + $ cat >d/dune-project < (lang dune 2.0) + > (package (name menhir) (deprecated_package_names menhirLib menhirSdk)) + > EOF + + $ cat >d/dune < (rule (with-stdout-to lib.ml (progn))) + > (library + > (name menhirLib) + > (public_name menhir.lib) + > (modules lib)) + > (deprecated_library_name + > (old_public_name menhirLib) + > (new_public_name menhir.lib)) + > (rule (with-stdout-to sdk.ml (echo "let version = ()"))) + > (library + > (name menhirSdk) + > (public_name menhir.sdk) + > (modules sdk)) + > (deprecated_library_name + > (old_public_name menhirSdk) + > (new_public_name menhir.sdk)) + > EOF + + $ cd d && dune build --root . @install + $ find d/_build/install/default -name 'META*' -exec echo {} \; -exec cat {} \; + d/_build/install/default/lib/menhirSdk/META + requires = "menhir.sdk" + d/_build/install/default/lib/menhirLib/META + requires = "menhir.lib" + d/_build/install/default/lib/menhir/META + package "lib" ( + directory = "lib" + description = "" + requires = "" + archive(byte) = "menhirLib.cma" + archive(native) = "menhirLib.cmxa" + plugin(byte) = "menhirLib.cma" + plugin(native) = "menhirLib.cmxs" + ) + package "sdk" ( + directory = "sdk" + description = "" + requires = "" + archive(byte) = "menhirSdk.cma" + archive(native) = "menhirSdk.cmxa" + plugin(byte) = "menhirSdk.cma" + plugin(native) = "menhirSdk.cmxs" + ) + +Check that we can use the short name in library dependencies. + + $ cat >>d/dune < (rule (with-stdout-to use.ml (echo "let _ = MenhirSdk.Sdk.version"))) + > (library + > (name foo) + > (public_name menhir.foo) + > (libraries menhirSdk menhirLib) + > (modules use)) + > EOF + + $ cd d && dune build --root . @all + +Checks that we can migrate top-level libraries across packages. + + $ cat >d/dune-project < (lang dune 2.0) + > (package (name p) (deprecated_package_names top1 top2)) + > (package (name q)) + > EOF + + $ cat >d/dune < (rule (with-stdout-to foo.ml (progn))) + > (library + > (name foo) + > (public_name q.bar) + > (modules foo)) + > (deprecated_library_name + > (old_public_name top1) + > (new_public_name q.bar)) + + $ cd d && dune build --root . @install + $ cat d/_build/install/default/lib/top1/META + requires = "q.bar" + +Check that we can do it when the name of the new library is the same as the +old public name: + + $ cat >d/dune < (rule (with-stdout-to bar.ml (progn))) + > (library + > (name top2) + > (public_name q.top2) + > (modules bar)) + > (deprecated_library_name + > (old_public_name top2) + > (new_public_name q.top2)) + > EOF + + $ cd d && dune build --root . @all + $ cat d/_build/install/default/lib/top2/META + requires = "q.top2" + +We check that there is an error when there is an actual ambiguity: + + $ cat >d/dune < (rule (with-stdout-to bar.ml (progn))) + > (rule (with-stdout-to bar2.ml (progn))) + > (library + > (name top2) + > (public_name q.top2) + > (modules bar)) + > (library + > (name top3) + > (public_name q.top3) + > (modules bar2)) + > (deprecated_library_name + > (old_public_name top2) + > (new_public_name q.top3)) + > EOF + + $ cd d && dune build --root . @all + Error: Library top2 is defined twice: + - dune:13 + - dune:5 + [1] + +Another case of ambiguity: + + $ cat >d/dune-project < (lang dune 2.0) + > (package (name p)) + > (package (name q) (deprecated_package_names p)) + > EOF + + $ cat >d/dune < (rule (with-stdout-to bar.ml (progn))) + > (library + > (name p) + > (public_name p) + > (modules bar)) + > (deprecated_library_name + > (old_public_name p) + > (new_public_name p)) + > EOF + + $ cd d && dune build --root . --display=short @all + Error: Package name p is defined twice: + - dune-project:3 + - dune-project:2 + [1]