Skip to content

Commit

Permalink
Add test cases to show binary/lib name collisions (#2358)
Browse files Browse the repository at this point in the history
Add test cases to show binary/lib name collisions
  • Loading branch information
rgrinberg authored Jul 4, 2019
2 parents cedf1e7 + 1ba9394 commit 299fb23
Show file tree
Hide file tree
Showing 17 changed files with 67 additions and 0 deletions.
10 changes: 10 additions & 0 deletions test/blackbox-tests/dune.inc
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,14 @@
test-cases/exclude-missing-module
(progn (run %{exe:cram.exe} -test run.t) (diff? run.t run.t.corrected)))))

(alias
(name exe-name-mangle)
(deps (package dune) (source_tree test-cases/exe-name-mangle))
(action
(chdir
test-cases/exe-name-mangle
(progn (run %{exe:cram.exe} -test run.t) (diff? run.t run.t.corrected)))))

(alias
(name exec-cmd)
(deps (package dune) (source_tree test-cases/exec-cmd))
Expand Down Expand Up @@ -1628,6 +1636,7 @@
(alias env-var-expansion)
(alias env-variables)
(alias exclude-missing-module)
(alias exe-name-mangle)
(alias exec-cmd)
(alias exec-missing)
(alias external-lib-deps)
Expand Down Expand Up @@ -1818,6 +1827,7 @@
(alias env-var-expansion)
(alias env-variables)
(alias exclude-missing-module)
(alias exe-name-mangle)
(alias exec-cmd)
(alias exec-missing)
(alias external-lib-deps)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
let () =
Foo.run ()
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
(executable
(libraries foo)
(name baz))

(alias
(name default)
(action (run ./baz.exe)))
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(lang dune 1.11)
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
(* finally calling into library *)
let run = Bar.run ()
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
(* directly usable but will cause linking error *)
let run = Foo.run
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(library
(name foo)
(wrapped false))
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
let run () = print_endline "not directly usable"
15 changes: 15 additions & 0 deletions test/blackbox-tests/test-cases/exe-name-mangle/run.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Binary composed of a single module with the same name as the dependency
$ dune build --root single-module 2>&1 | grep -v ocamlopt
Entering directory 'single-module'
File "exe.ml", line 1:
Error: The files foo/.foo.objs/byte/foo.cmi and .exe.eobjs/byte/exe.cmi
make inconsistent assumptions over interface Exe
Binary composed of multiple modules where one collides with a dependency
$ dune build --root multi-module 2>&1 | grep -v ocamlopt | grep -v ocamlc
Entering directory 'multi-module'
File "foo.ml", line 1:
Error: The files foo/.foo.objs/byte/bar.cmi and .baz.eobjs/byte/foo.cmi
make inconsistent assumptions over interface Foo
File "baz.ml", line 1:
Error: The files .baz.eobjs/byte/foo.cmi and .baz.eobjs/byte/foo.cmi
make inconsistent assumptions over interface Foo
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
(* make sure everything is linked *)
let run = Exe.run
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(library
(name exe)
(wrapped false))
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
let run () = print_endline "this module is unlinkable"
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
(executable
(libraries foo)
(name exe))

(alias
(name default)
(action (run ./exe.exe)))
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(lang dune 1.11)

(implicit_transitive_deps false)
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
let () =
Foo.run ()
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(library
(libraries exe)
(name foo))
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
let run () =
Exe.run ();
Collisionlib.run ()

0 comments on commit 299fb23

Please sign in to comment.