From 9ce8d0f9ee6f13c178a94e84a72780cef0b17e7c 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 | 93 +++++++++++++++++++ 1 file changed, 93 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..550d81f19290 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,96 @@ 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 + $ cat >d/dune-project < (lang dune 2.0) + > (package (name p)) + > (package (name q)) + > EOF + +The first tests checks that we can migrate top-level libraries +across packages. + + $ 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 top) + > (package p) + > (new_public_name q.bar)) + + $ cd d && dune build --root . @install + $ cat d/_build/install/default/lib/top/META + requires = "q.bar" + +Next we 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 www) + > (public_name q.www) + > (modules bar)) + > (deprecated_library_name + > (old_public_name www) + > (package p) + > (new_public_name q.www)) + > EOF + + $ cd d && dune build --root . @all + $ cat d/_build/install/default/lib/www/META + requires = "q.www" + +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 www) + > (public_name q.www) + > (modules bar)) + > (library + > (name www2) + > (public_name q.www2) + > (modules bar2)) + > (deprecated_library_name + > (old_public_name www) + > (package p) + > (new_public_name q.www2)) + > EOF + + $ cd d && dune build --root . @all + Error: Library www is defined twice: + - dune:11 + - dune:3 + [1] + +Another case of ambiguity: + + $ 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) + > (package q) + > (new_public_name p)) + > EOF + + $ cd d && dune build --root . --display=short @all + File "dune", line 7, characters 18-19: + 7 | (old_public_name p) + ^ + Error: a package named "p" already exists + [1]