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 <[email protected]>
  • Loading branch information
nojb committed Oct 8, 2019
1 parent 08945c7 commit 9ce8d0f
Showing 1 changed file with 93 additions and 0 deletions.
93 changes: 93 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,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 <<EOF
> (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 <<EOF
> (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 <<EOF
> (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 <<EOF
> (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 <<EOF
> (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]

0 comments on commit 9ce8d0f

Please sign in to comment.