Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow multiple inline tests in a directory #3621

Merged
merged 5 commits into from
Jul 14, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ next

- Fix dune-build-info on 4.10.0+flambda (#3599, @emillon, @jeremiedimino).

- Allow multiple libraries with `inline_tests` to be defined in the same
directory (#3621, @rgrinberg)

2.6.1 (02/07/2020)
------------------

Expand Down
2 changes: 1 addition & 1 deletion src/dune/inline_tests.ml
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ include Sub_system.Register_end_point (struct
let obj_dir =
Obj_dir.make_exe ~dir:inline_test_dir ~name:inline_test_name
in
let name = "run" in
let name = sprintf "inline_test_runner_%s" (Lib_name.Local.to_string (snd lib.name)) in
let main_module =
let name = Module_name.of_string name in
let src_dir = Path.build inline_test_dir in
Expand Down
75 changes: 70 additions & 5 deletions test/blackbox-tests/dune.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1569,14 +1569,36 @@
(progn (run dune-cram run run.t) (diff? run.t run.t.corrected)))))

(rule
(alias inline_tests)
(alias inline_tests-dune-file)
(deps
(package dune)
(source_tree test-cases/inline_tests.t)
(source_tree test-cases/inline_tests/dune-file.t)
(alias test-deps))
(action
(chdir
test-cases/inline_tests.t
test-cases/inline_tests/dune-file.t
(progn (run dune-cram run run.t) (diff? run.t run.t.corrected)))))

(rule
(alias inline_tests-many-backends-choose)
(deps
(package dune)
(source_tree test-cases/inline_tests/many-backends-choose.t)
(alias test-deps))
(action
(chdir
test-cases/inline_tests/many-backends-choose.t
(progn (run dune-cram run run.t) (diff? run.t run.t.corrected)))))

(rule
(alias inline_tests-missing-backend)
(deps
(package dune)
(source_tree test-cases/inline_tests/missing-backend.t)
(alias test-deps))
(action
(chdir
test-cases/inline_tests/missing-backend.t
(progn (run dune-cram run run.t) (diff? run.t run.t.corrected)))))

(rule
Expand All @@ -1590,6 +1612,39 @@
test-cases/inline_tests-multi-mode.t
(progn (run dune-cram run run.t) (diff? run.t run.t.corrected)))))

(rule
(alias inline_tests-multiple-inline-tests)
(deps
(package dune)
(source_tree test-cases/inline_tests/multiple-inline-tests.t)
(alias test-deps))
(action
(chdir
test-cases/inline_tests/multiple-inline-tests.t
(progn (run dune-cram run run.t) (diff? run.t run.t.corrected)))))

(rule
(alias inline_tests-simple)
(deps
(package dune)
(source_tree test-cases/inline_tests/simple.t)
(alias test-deps))
(action
(chdir
test-cases/inline_tests/simple.t
(progn (run dune-cram run run.t) (diff? run.t run.t.corrected)))))

(rule
(alias inline_tests-too-many-backends)
(deps
(package dune)
(source_tree test-cases/inline_tests/too-many-backends.t)
(alias test-deps))
(action
(chdir
test-cases/inline_tests/too-many-backends.t
(progn (run dune-cram run run.t) (diff? run.t run.t.corrected)))))

(rule
(alias install-dry-run)
(deps
Expand Down Expand Up @@ -3235,8 +3290,13 @@
(alias include-loop)
(alias include-qualified)
(alias incremental-rebuilds)
(alias inline_tests)
(alias inline_tests-dune-file)
(alias inline_tests-many-backends-choose)
(alias inline_tests-missing-backend)
(alias inline_tests-multi-mode)
(alias inline_tests-multiple-inline-tests)
(alias inline_tests-simple)
(alias inline_tests-too-many-backends)
(alias install-dry-run)
(alias install-libdir)
(alias install-mandir)
Expand Down Expand Up @@ -3525,8 +3585,13 @@
(alias include-loop)
(alias include-qualified)
(alias incremental-rebuilds)
(alias inline_tests)
(alias inline_tests-dune-file)
(alias inline_tests-many-backends-choose)
(alias inline_tests-missing-backend)
(alias inline_tests-multi-mode)
(alias inline_tests-multiple-inline-tests)
(alias inline_tests-simple)
(alias inline_tests-too-many-backends)
(alias install-mandir)
(alias install-multiple-contexts)
(alias install-partial-package)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Reproduction case for #3347
$ touch test.ml

$ dune runtest
run alias runtest
inline_test_runner_test alias runtest
Test byte
run alias runtest
inline_test_runner_test alias runtest
Test native
1 change: 0 additions & 1 deletion test/blackbox-tests/test-cases/inline_tests.t/dune-project

This file was deleted.

This file was deleted.

This file was deleted.

98 changes: 0 additions & 98 deletions test/blackbox-tests/test-cases/inline_tests.t/run.t

This file was deleted.

14 changes: 0 additions & 14 deletions test/blackbox-tests/test-cases/inline_tests.t/simple/dune

This file was deleted.

This file was deleted.

This file was deleted.

59 changes: 59 additions & 0 deletions test/blackbox-tests/test-cases/inline_tests/dune-file.t/run.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
$ dune runtest dune-file | sed "s/(lang dune .*)/(lang dune <version>)/" | dune_cmd sanitize
This conversation was marked as resolved.
Show resolved Hide resolved
inline_test_runner_foo_tests alias dune-file/runtest
414243
(lang dune <version>)
(name foo)
(library
(name foo)
(kind normal)
(archives (byte foo.cma) (native foo.cmxa))
(plugins (byte foo.cma) (native foo.cmxs))
(native_archives foo$ext_lib)
(main_module_name Foo)
(modes byte native)
(modules
(wrapped
(main_module_name Foo)
(alias_module
(name Foo)
(obj_name foo)
(visibility public)
(kind alias)
(impl))
(wrapped true)))
(inline_tests.backend
(runner_libraries str)
(flags
inline-test-runner
%{library-name}
-source-tree-root
%{workspace_root}
-diff-cmd
-)
(generate_runner
(progn
(echo "let () = print_int 41")
(echo "\n")
(echo "let () = print_int 42")
(echo "\n")
(echo "let () = print_int 43;;")))))

$ dune build dune-file/foo.install && dune install foo --prefix install | dune_cmd sanitize
Installing install/lib/foo/META
Installing install/lib/foo/dune-package
Installing install/lib/foo/foo.a
Installing install/lib/foo/foo.cma
Installing install/lib/foo/foo.cmi
Installing install/lib/foo/foo.cmt
Installing install/lib/foo/foo.cmx
Installing install/lib/foo/foo.cmxa
Installing install/lib/foo/foo.cmxs
Installing install/lib/foo/foo.ml
Installing install/lib/foo/opam

Make sure we can read generated dune-package files:

$ export OCAMLPATH=$PWD/install/lib; dune runtest --root dune-file-user
Entering directory 'dune-file-user'
inline_test_runner_foo_tests alias runtest
414243
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
$ cat >dune-project <<EOF
> (lang dune 2.6)
> EOF
$ cat >dune <<EOF
> (library
> (name backend_mbc1)
> (modules ())
> (inline_tests.backend
> (generate_runner (echo "print_endline \"backend_mbc1\""))))
>
> (library
> (name backend_mbc2)
> (modules ())
> (inline_tests.backend
> (generate_runner (echo "print_endline \"backend_mbc2\""))))
>
> (library
> (name foo_mbc)
> (inline_tests (backend backend_mbc1))
> (libraries backend_mbc1 backend_mbc2))
> EOF

$ dune runtest
inline_test_runner_foo_mbc alias runtest
backend_mbc1
Loading