Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolás Ojeda Bär <n.oje.bar@gmail.com>
  • Loading branch information
nojb committed Oct 11, 2019
1 parent b24461b commit 67b5aca
Showing 1 changed file with 159 additions and 0 deletions.
159 changes: 159 additions & 0 deletions test/blackbox-tests/test-cases/deprecated-library-name/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -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 <<EOF
> (lang dune 2.0)
> (package (name menhir) (deprecated_package_names menhirLib menhirSdk))
> EOF

$ cat >d/dune <<EOF
> (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 <<EOF
> (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 <<EOF
> (lang dune 2.0)
> (package (name p) (deprecated_package_names top1 top2))
> (package (name q))
> EOF

$ cat >d/dune <<EOF
> (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 <<EOF
> (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 <<EOF
> (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 <<EOF
> (lang dune 2.0)
> (package (name p))
> (package (name q) (deprecated_package_names p))
> EOF

$ cat >d/dune <<EOF
> (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]

0 comments on commit 67b5aca

Please sign in to comment.