Skip to content

Commit

Permalink
generalize tests more
Browse files Browse the repository at this point in the history
test everything methodically

Signed-off-by: Rudi Grinberg <[email protected]>
  • Loading branch information
rgrinberg committed Nov 26, 2020
1 parent 2277733 commit 1e29831
Show file tree
Hide file tree
Showing 2 changed files with 231 additions and 128 deletions.
190 changes: 116 additions & 74 deletions test/blackbox-tests/test-cases/github3766.t/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,24 @@ ocaml 4.12.
In 4.11 - .a are always created
In 4.12 - they are omitted if there are no modules or stubs

A single test case is in test.ml
There's a combination of 3 options:
- With or without stubs
- Wrapped or unwrapped
- Contains an mli only module
$ ./test.exe unwrapped_empty <<EOF
> (library
> (public_name foo)
> (wrapped false)
> (modules ()))
> EOF
Our test checks each of the above with an internal and external library.
$ ./test.exe
# mli_only_wrapped_stubs
-> creating dune-project
# build the library and see if .a is present
-> creating dune
-> creating stub.c
-> creating foo.mli
% dune build --root . @install
% ls _build/install/default/lib/foo/*.a
_build/install/default/lib/foo/foo.a
_build/install/default/lib/foo/libfoo_stubs.a
# create a dummy executable to test
-> creating dune
Expand All @@ -32,15 +36,12 @@ A single test case is in test.ml
% OCAMLPATH=_build/install/default/lib dune exec --build-dir=_b2 ./exe/b.exe
exe working
$ ./test.exe wrapped_empty <<EOF
> (library
> (public_name foo)
> (wrapped true)
> (modules ()))
> EOF
# mli_only_wrapped_no_stubs
-> creating dune-project
# build the library and see if .a is present
-> creating dune
-> creating foo.mli
% dune build --root . @install
% ls _build/install/default/lib/foo/*.a
_build/install/default/lib/foo/foo.a
Expand All @@ -58,16 +59,13 @@ A single test case is in test.ml
% OCAMLPATH=_build/install/default/lib dune exec --build-dir=_b2 ./exe/b.exe
exe working
$ ./test.exe unwrapped_empty_with_stubs --stub baz <<EOF
> (library
> (public_name foo)
> (wrapped false)
> (foreign_stubs (language c) (names baz)))
> EOF
# mli_only_unwrapped_stubs
-> creating dune-project
# build the library and see if .a is present
-> creating dune
-> creating baz.c
-> creating stub.c
-> creating foo.mli
% dune build --root . @install
% ls _build/install/default/lib/foo/*.a
_build/install/default/lib/foo/foo.a
Expand All @@ -86,91 +84,135 @@ A single test case is in test.ml
% OCAMLPATH=_build/install/default/lib dune exec --build-dir=_b2 ./exe/b.exe
exe working

$ ./test.exe mli_only_no_stubs --mli-only <<EOF
> (library
> (public_name foo)
> (modules_without_implementation foo))
> EOF
# mli_only_unwrapped_no_stubs
-> creating dune-project
# build the library and see if .a is present
-> creating dune
-> creating mli_only_no_stubs.mli
-> creating foo.mli
% dune build --root . @install
File "lib/dune", line 3, characters 33-36:
3 | (modules_without_implementation foo))
^^^
Error: Module Foo doesn't exist.
[1]
% ls _build/install/default/lib/foo/*.a
ls: _build/install/default/lib/foo/*.a: No such file or directory
[1]
_build/install/default/lib/foo/foo.a
# create a dummy executable to test
-> creating dune
-> creating b.ml
# make sure that this library is usable locally
% dune exec ./exe/b.exe
File "lib/dune", line 3, characters 33-36:
3 | (modules_without_implementation foo))
^^^
Error: Module Foo doesn't exist.
[1]
exe working
# make sure that this library is usable externally
% rm -rf lib
% OCAMLPATH=_build/install/default/lib dune exec --build-dir=_b2 ./exe/b.exe
File "exe/dune", line 5, characters 12-15:
5 | (libraries foo))
^^^
Error: Library "foo" not found.
Hint: try:
dune external-lib-deps --missing --build-dir _b2 ./exe/b.exe
[1]
exe working

$ ./test.exe mli_only_no_stubs --mli-only --stub baz <<EOF
> (library
> (public_name foo)
> (foreign_stubs (language c) (names baz))
> (modules_without_implementation foo))
> EOF
# no_mli_wrapped_stubs
-> creating dune-project
# build the library and see if .a is present
-> creating dune
-> creating stub.c
% dune build --root . @install
% ls _build/install/default/lib/foo/*.a
_build/install/default/lib/foo/foo.a
_build/install/default/lib/foo/libfoo_stubs.a
# create a dummy executable to test
-> creating dune
-> creating b.ml
# make sure that this library is usable locally
% dune exec ./exe/b.exe
exe working
# make sure that this library is usable externally
% rm -rf lib
% OCAMLPATH=_build/install/default/lib dune exec --build-dir=_b2 ./exe/b.exe
exe working
# no_mli_wrapped_no_stubs
-> creating dune-project
# build the library and see if .a is present
-> creating dune
% dune build --root . @install
% ls _build/install/default/lib/foo/*.a
_build/install/default/lib/foo/foo.a
# create a dummy executable to test
-> creating dune
-> creating b.ml
# make sure that this library is usable locally
% dune exec ./exe/b.exe
exe working
# make sure that this library is usable externally
% rm -rf lib
% OCAMLPATH=_build/install/default/lib dune exec --build-dir=_b2 ./exe/b.exe
exe working
# no_mli_unwrapped_stubs
-> creating dune-project
# build the library and see if .a is present
-> creating dune
-> creating stub.c
% dune build --root . @install
% ls _build/install/default/lib/foo/*.a
_build/install/default/lib/foo/foo.a
_build/install/default/lib/foo/libfoo_stubs.a
# create a dummy executable to test
-> creating dune
-> creating b.ml
# make sure that this library is usable locally
% dune exec ./exe/b.exe
exe working
# make sure that this library is usable externally
% rm -rf lib
% OCAMLPATH=_build/install/default/lib dune exec --build-dir=_b2 ./exe/b.exe
exe working
# no_mli_unwrapped_no_stubs
-> creating dune-project
# build the library and see if .a is present
-> creating dune
-> creating baz.c
-> creating mli_only_no_stubs.mli
% dune build --root . @install
File "lib/dune", line 4, characters 33-36:
4 | (modules_without_implementation foo))
^^^
Error: Module Foo doesn't exist.
[1]
% ls _build/install/default/lib/foo/*.a
ls: _build/install/default/lib/foo/*.a: No such file or directory
[1]
_build/install/default/lib/foo/foo.a
# create a dummy executable to test
-> creating dune
-> creating b.ml
# make sure that this library is usable locally
% dune exec ./exe/b.exe
File "lib/dune", line 4, characters 33-36:
4 | (modules_without_implementation foo))
^^^
Error: Module Foo doesn't exist.
[1]
exe working
# make sure that this library is usable externally
% rm -rf lib
% OCAMLPATH=_build/install/default/lib dune exec --build-dir=_b2 ./exe/b.exe
File "exe/dune", line 5, characters 12-15:
5 | (libraries foo))
^^^
Error: Library "foo" not found.
Hint: try:
dune external-lib-deps --missing --build-dir _b2 ./exe/b.exe
[1]
exe working
mli_only_wrapped_stubs - external - pass
mli_only_wrapped_stubs - internal - pass
mli_only_wrapped_no_stubs - external - pass
mli_only_wrapped_no_stubs - internal - pass
mli_only_unwrapped_stubs - external - pass
mli_only_unwrapped_stubs - internal - pass
mli_only_unwrapped_no_stubs - external - pass
mli_only_unwrapped_no_stubs - internal - pass
no_mli_wrapped_stubs - external - pass
no_mli_wrapped_stubs - internal - pass
no_mli_wrapped_no_stubs - external - pass
no_mli_wrapped_no_stubs - internal - pass
no_mli_unwrapped_stubs - external - pass
no_mli_unwrapped_stubs - internal - pass
no_mli_unwrapped_no_stubs - external - pass
no_mli_unwrapped_no_stubs - internal - pass
Loading

0 comments on commit 1e29831

Please sign in to comment.