Skip to content

Commit

Permalink
add tests for the implementation check.
Browse files Browse the repository at this point in the history
Signed-off-by: Lucas Pluvinage <[email protected]>
  • Loading branch information
TheLortex committed Jun 28, 2019
1 parent 86b8c5c commit e246e29
Show file tree
Hide file tree
Showing 21 changed files with 85 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/blackbox-tests/dune.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1490,6 +1490,16 @@
test-cases/variants-only-package
(progn (run %{exe:cram.exe} -test run.t) (diff? run.t run.t.corrected)))))

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

(alias
(name vlib)
(deps (package dune) (source_tree test-cases/vlib))
Expand All @@ -1506,6 +1516,14 @@
test-cases/vlib-default-impl
(progn (run %{exe:cram.exe} -test run.t) (diff? run.t run.t.corrected)))))

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

(alias
(name windows-diff)
(deps (package dune) (source_tree test-cases/windows-diff))
Expand Down Expand Up @@ -1721,8 +1739,10 @@
(alias variants-external-declaration-conflict)
(alias variants-multi-project)
(alias variants-only-package)
(alias variants-wrong-external-declaration)
(alias vlib)
(alias vlib-default-impl)
(alias vlib-wrong-default-impl)
(alias windows-diff)
(alias workspaces)
(alias wrapped-false-main-module-name)
Expand Down Expand Up @@ -1885,8 +1905,10 @@
(alias variants-external-declaration-conflict)
(alias variants-multi-project)
(alias variants-only-package)
(alias variants-wrong-external-declaration)
(alias vlib)
(alias vlib-default-impl)
(alias vlib-wrong-default-impl)
(alias windows-diff)
(alias workspaces)
(alias wrapped-false-main-module-name)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
(executable
(name exe)
(libraries vlibfoo-ext)
(variants somevariant))
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
(lang dune 1.10)
(using library_variants 0.1)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
let () = Vlibfoo.implme ()
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
(library
(name vlibfoo)
(public_name vlibfoo-ext)
(virtual_modules vlibfoo)
)

(external_variant
(virtual_library vlibfoo)
(variant somevariant)
(implementation not-an-implementation))
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
(lang dune 1.10)
(using library_variants 0.2)
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
val implme : unit -> unit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
let implme () = print_endline "foobar"
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
(library
(name not_an_implementation)
(public_name not-an-implementation)
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
(lang dune 1.10)
(using library_variants 0.1)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
External declaration of an implementation, when the given library is not an
implementation, should fail.

$ dune build exe/exe.exe
Error: "not-an-implementation" is not an implementation of "vlibfoo-ext".
-> required by executable exe in exe/dune:2
[1]
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
(lang dune 1.10)
(using library_variants 0.1)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
(executable
(name exe)
(libraries vlibfoo)
)

(alias
(name default)
(action
(run ./exe.exe)))
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
let () = Vlibfoo.implme ()
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
let implme () = ()
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(library
(name not_an_implem)
)
7 changes: 7 additions & 0 deletions test/blackbox-tests/test-cases/vlib-wrong-default-impl/run.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Check that dune makes a proper error if the default implementation of a virtual
library is not actually an implementation of the virtual library.

$ dune build @default
Error: "not_an_implem" is not an implementation of "vlibfoo".
-> required by executable exe in exe/dune:2
[1]
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
(library
(name vlibfoo)
(virtual_modules vlibfoo)
(default_implementation not_an_implem)
)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
val implme : unit -> unit

0 comments on commit e246e29

Please sign in to comment.