From 1201bb6c5b6ddb166067530627f280654dac7080 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Sat, 11 Jul 2020 18:23:11 -0700 Subject: [PATCH 1/5] split inline tests into separate tests Makes it simpler to add new tests Signed-off-by: Rudi Grinberg --- test/blackbox-tests/dune.inc | 62 +++++++++++++++++-- .../test-cases/inline_tests.t/dune-project | 1 - .../inline_tests.t/many-backends-choose/dune | 18 ------ .../inline_tests.t/missing-backend/dune | 3 - .../test-cases/inline_tests.t/simple/dune | 14 ----- .../test-cases/inline_tests.t/simple/test.ml | 1 - .../inline_tests.t/too-many-backends/dune | 18 ------ .../dune-file.t}/dune-file-user/dune | 0 .../dune-file.t}/dune-file-user/dune-project | 0 .../dune-file.t}/dune-file/dune | 0 .../dune-file.t}/dune-file/dune-project | 0 .../dune-file.t}/dune-file/foo.opam | 0 .../dune-file.t}/run.t | 39 ------------ .../inline_tests/many-backends-choose.t/run.t | 25 ++++++++ .../inline_tests/missing-backend.t/run.t | 15 +++++ .../test-cases/inline_tests/simple.t/run.t | 43 +++++++++++++ .../inline_tests/too-many-backends.t/run.t | 30 +++++++++ 17 files changed, 170 insertions(+), 99 deletions(-) delete mode 100644 test/blackbox-tests/test-cases/inline_tests.t/dune-project delete mode 100644 test/blackbox-tests/test-cases/inline_tests.t/many-backends-choose/dune delete mode 100644 test/blackbox-tests/test-cases/inline_tests.t/missing-backend/dune delete mode 100644 test/blackbox-tests/test-cases/inline_tests.t/simple/dune delete mode 100644 test/blackbox-tests/test-cases/inline_tests.t/simple/test.ml delete mode 100644 test/blackbox-tests/test-cases/inline_tests.t/too-many-backends/dune rename test/blackbox-tests/test-cases/{inline_tests.t => inline_tests/dune-file.t}/dune-file-user/dune (100%) rename test/blackbox-tests/test-cases/{inline_tests.t => inline_tests/dune-file.t}/dune-file-user/dune-project (100%) rename test/blackbox-tests/test-cases/{inline_tests.t => inline_tests/dune-file.t}/dune-file/dune (100%) rename test/blackbox-tests/test-cases/{inline_tests.t => inline_tests/dune-file.t}/dune-file/dune-project (100%) rename test/blackbox-tests/test-cases/{inline_tests.t => inline_tests/dune-file.t}/dune-file/foo.opam (100%) rename test/blackbox-tests/test-cases/{inline_tests.t => inline_tests/dune-file.t}/run.t (52%) create mode 100644 test/blackbox-tests/test-cases/inline_tests/many-backends-choose.t/run.t create mode 100644 test/blackbox-tests/test-cases/inline_tests/missing-backend.t/run.t create mode 100644 test/blackbox-tests/test-cases/inline_tests/simple.t/run.t create mode 100644 test/blackbox-tests/test-cases/inline_tests/too-many-backends.t/run.t diff --git a/test/blackbox-tests/dune.inc b/test/blackbox-tests/dune.inc index 6ce0d3d81c7..267bee05741 100644 --- a/test/blackbox-tests/dune.inc +++ b/test/blackbox-tests/dune.inc @@ -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 @@ -1590,6 +1612,28 @@ test-cases/inline_tests-multi-mode.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 @@ -3235,8 +3279,12 @@ (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-simple) + (alias inline_tests-too-many-backends) (alias install-dry-run) (alias install-libdir) (alias install-mandir) @@ -3525,8 +3573,12 @@ (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-simple) + (alias inline_tests-too-many-backends) (alias install-mandir) (alias install-multiple-contexts) (alias install-partial-package) diff --git a/test/blackbox-tests/test-cases/inline_tests.t/dune-project b/test/blackbox-tests/test-cases/inline_tests.t/dune-project deleted file mode 100644 index 0636ab6acf4..00000000000 --- a/test/blackbox-tests/test-cases/inline_tests.t/dune-project +++ /dev/null @@ -1 +0,0 @@ -(lang dune 1.11) diff --git a/test/blackbox-tests/test-cases/inline_tests.t/many-backends-choose/dune b/test/blackbox-tests/test-cases/inline_tests.t/many-backends-choose/dune deleted file mode 100644 index 496427fff53..00000000000 --- a/test/blackbox-tests/test-cases/inline_tests.t/many-backends-choose/dune +++ /dev/null @@ -1,18 +0,0 @@ -(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)) diff --git a/test/blackbox-tests/test-cases/inline_tests.t/missing-backend/dune b/test/blackbox-tests/test-cases/inline_tests.t/missing-backend/dune deleted file mode 100644 index f00a338da35..00000000000 --- a/test/blackbox-tests/test-cases/inline_tests.t/missing-backend/dune +++ /dev/null @@ -1,3 +0,0 @@ -(library - (name foo_mb) - (inline_tests)) diff --git a/test/blackbox-tests/test-cases/inline_tests.t/simple/dune b/test/blackbox-tests/test-cases/inline_tests.t/simple/dune deleted file mode 100644 index e823a7f85b6..00000000000 --- a/test/blackbox-tests/test-cases/inline_tests.t/simple/dune +++ /dev/null @@ -1,14 +0,0 @@ -(library - (name backend_simple) - (modules ()) - (inline_tests.backend - (generate_runner (run sed "s/(\\*TEST:\\(.*\\)\\*)/let () = if \"%{inline_tests}\" = \"enabled\" then \\1;;/" %{impl-files}) - ))) - -(library - (name foo_simple) - (inline_tests (backend backend_simple))) - -(env (ignore-inline-tests (inline_tests ignored)) - (enable-inline-tests (inline_tests enabled)) - (disable-inline-tests (inline_tests disabled))) diff --git a/test/blackbox-tests/test-cases/inline_tests.t/simple/test.ml b/test/blackbox-tests/test-cases/inline_tests.t/simple/test.ml deleted file mode 100644 index 41ccd24d3b4..00000000000 --- a/test/blackbox-tests/test-cases/inline_tests.t/simple/test.ml +++ /dev/null @@ -1 +0,0 @@ -(*TEST: assert (1 = 2) *) diff --git a/test/blackbox-tests/test-cases/inline_tests.t/too-many-backends/dune b/test/blackbox-tests/test-cases/inline_tests.t/too-many-backends/dune deleted file mode 100644 index 44c300d9434..00000000000 --- a/test/blackbox-tests/test-cases/inline_tests.t/too-many-backends/dune +++ /dev/null @@ -1,18 +0,0 @@ -(library - (name backend_tmb1) - (modules ()) - (inline_tests.backend - (generate_runner (echo foo) -))) - -(library - (name backend_tmb2) - (modules ()) - (inline_tests.backend - (generate_runner (echo foo) -))) - -(library - (name foo_tmb) - (inline_tests) - (libraries backend_tmb1 backend_tmb2)) diff --git a/test/blackbox-tests/test-cases/inline_tests.t/dune-file-user/dune b/test/blackbox-tests/test-cases/inline_tests/dune-file.t/dune-file-user/dune similarity index 100% rename from test/blackbox-tests/test-cases/inline_tests.t/dune-file-user/dune rename to test/blackbox-tests/test-cases/inline_tests/dune-file.t/dune-file-user/dune diff --git a/test/blackbox-tests/test-cases/inline_tests.t/dune-file-user/dune-project b/test/blackbox-tests/test-cases/inline_tests/dune-file.t/dune-file-user/dune-project similarity index 100% rename from test/blackbox-tests/test-cases/inline_tests.t/dune-file-user/dune-project rename to test/blackbox-tests/test-cases/inline_tests/dune-file.t/dune-file-user/dune-project diff --git a/test/blackbox-tests/test-cases/inline_tests.t/dune-file/dune b/test/blackbox-tests/test-cases/inline_tests/dune-file.t/dune-file/dune similarity index 100% rename from test/blackbox-tests/test-cases/inline_tests.t/dune-file/dune rename to test/blackbox-tests/test-cases/inline_tests/dune-file.t/dune-file/dune diff --git a/test/blackbox-tests/test-cases/inline_tests.t/dune-file/dune-project b/test/blackbox-tests/test-cases/inline_tests/dune-file.t/dune-file/dune-project similarity index 100% rename from test/blackbox-tests/test-cases/inline_tests.t/dune-file/dune-project rename to test/blackbox-tests/test-cases/inline_tests/dune-file.t/dune-file/dune-project diff --git a/test/blackbox-tests/test-cases/inline_tests.t/dune-file/foo.opam b/test/blackbox-tests/test-cases/inline_tests/dune-file.t/dune-file/foo.opam similarity index 100% rename from test/blackbox-tests/test-cases/inline_tests.t/dune-file/foo.opam rename to test/blackbox-tests/test-cases/inline_tests/dune-file.t/dune-file/foo.opam diff --git a/test/blackbox-tests/test-cases/inline_tests.t/run.t b/test/blackbox-tests/test-cases/inline_tests/dune-file.t/run.t similarity index 52% rename from test/blackbox-tests/test-cases/inline_tests.t/run.t rename to test/blackbox-tests/test-cases/inline_tests/dune-file.t/run.t index e8225a75392..e9473885dbf 100644 --- a/test/blackbox-tests/test-cases/inline_tests.t/run.t +++ b/test/blackbox-tests/test-cases/inline_tests/dune-file.t/run.t @@ -1,42 +1,3 @@ - $ env -u OCAMLRUNPARAM dune runtest simple - run alias simple/runtest (exit 2) - (cd _build/default/simple && .foo_simple.inline-tests/run.exe) - Fatal error: exception File "simple/.foo_simple.inline-tests/run.ml-gen", line 1, characters 40-46: Assertion failed - [1] - -The expected behavior for the following three tests is to output nothing: the tests are disabled or ignored. - $ env -u OCAMLRUNPARAM dune runtest simple --profile release - - $ env -u OCAMLRUNPARAM dune runtest simple --profile disable-inline-tests - - $ env -u OCAMLRUNPARAM dune runtest simple --profile ignore-inline-tests - - $ env -u OCAMLRUNPARAM dune runtest simple --profile enable-inline-tests - run alias simple/runtest (exit 2) - (cd _build/default/simple && .foo_simple.inline-tests/run.exe) - Fatal error: exception File "simple/.foo_simple.inline-tests/run.ml-gen", line 1, characters 40-46: Assertion failed - [1] - - $ dune runtest missing-backend - File "missing-backend/dune", line 3, characters 1-15: - 3 | (inline_tests)) - ^^^^^^^^^^^^^^ - Error: No inline tests backend found. - [1] - - $ dune runtest too-many-backends - File "too-many-backends/dune", line 17, characters 1-15: - 17 | (inline_tests) - ^^^^^^^^^^^^^^ - Error: Too many independent inline tests backends found: - - "backend_tmb1" in _build/default/too-many-backends - - "backend_tmb2" in _build/default/too-many-backends - [1] - - $ dune runtest many-backends-choose - run alias many-backends-choose/runtest - backend_mbc1 - $ dune runtest dune-file | sed "s/(lang dune .*)/(lang dune )/" | dune_cmd sanitize run alias dune-file/runtest 414243 diff --git a/test/blackbox-tests/test-cases/inline_tests/many-backends-choose.t/run.t b/test/blackbox-tests/test-cases/inline_tests/many-backends-choose.t/run.t new file mode 100644 index 00000000000..e68244e68d8 --- /dev/null +++ b/test/blackbox-tests/test-cases/inline_tests/many-backends-choose.t/run.t @@ -0,0 +1,25 @@ + $ cat >dune-project < (lang dune 2.6) + > EOF + $ cat >dune < (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 + run alias runtest + backend_mbc1 diff --git a/test/blackbox-tests/test-cases/inline_tests/missing-backend.t/run.t b/test/blackbox-tests/test-cases/inline_tests/missing-backend.t/run.t new file mode 100644 index 00000000000..46189c93c3a --- /dev/null +++ b/test/blackbox-tests/test-cases/inline_tests/missing-backend.t/run.t @@ -0,0 +1,15 @@ + $ cat >dune-project < (lang dune 2.6) + > EOF + $ cat >dune < (library + > (name foo_mb) + > (inline_tests)) + > EOF + + $ dune runtest + File "dune", line 3, characters 1-15: + 3 | (inline_tests)) + ^^^^^^^^^^^^^^ + Error: No inline tests backend found. + [1] diff --git a/test/blackbox-tests/test-cases/inline_tests/simple.t/run.t b/test/blackbox-tests/test-cases/inline_tests/simple.t/run.t new file mode 100644 index 00000000000..67f698a430a --- /dev/null +++ b/test/blackbox-tests/test-cases/inline_tests/simple.t/run.t @@ -0,0 +1,43 @@ + $ cat >test.ml < (*TEST: assert (1 = 2) *) + > EOF + + $ cat >dune-project < (lang dune 2.6) + > EOF + + $ cat >dune < (library + > (name backend_simple) + > (modules ()) + > (inline_tests.backend + > (generate_runner (run sed "s/(\\\\*TEST:\\\\(.*\\\\)\\\\*)/let () = if \\"%{inline_tests}\\" = \\"enabled\\" then \\\\1;;/" %{impl-files})))) + > + > (library + > (name foo_simple) + > (inline_tests (backend backend_simple))) + > + > (env + > (ignore-inline-tests (inline_tests ignored)) + > (enable-inline-tests (inline_tests enabled)) + > (disable-inline-tests (inline_tests disabled))) + > EOF + + $ env -u OCAMLRUNPARAM dune runtest + run alias runtest (exit 2) + (cd _build/default && .foo_simple.inline-tests/run.exe) + Fatal error: exception File ".foo_simple.inline-tests/run.ml-gen", line 1, characters 40-46: Assertion failed + [1] + +The expected behavior for the following three tests is to output nothing: the tests are disabled or ignored. + $ env -u OCAMLRUNPARAM dune runtest --profile release + + $ env -u OCAMLRUNPARAM dune runtest --profile disable-inline-tests + + $ env -u OCAMLRUNPARAM dune runtest --profile ignore-inline-tests + + $ env -u OCAMLRUNPARAM dune runtest --profile enable-inline-tests + run alias runtest (exit 2) + (cd _build/default && .foo_simple.inline-tests/run.exe) + Fatal error: exception File ".foo_simple.inline-tests/run.ml-gen", line 1, characters 40-46: Assertion failed + [1] diff --git a/test/blackbox-tests/test-cases/inline_tests/too-many-backends.t/run.t b/test/blackbox-tests/test-cases/inline_tests/too-many-backends.t/run.t new file mode 100644 index 00000000000..c519fb9de6f --- /dev/null +++ b/test/blackbox-tests/test-cases/inline_tests/too-many-backends.t/run.t @@ -0,0 +1,30 @@ + $ cat >dune-project < (lang dune 2.6) + > EOF + $ cat >dune < (library + > (name backend_tmb1) + > (modules ()) + > (inline_tests.backend + > (generate_runner (echo foo)))) + > + > (library + > (name backend_tmb2) + > (modules ()) + > (inline_tests.backend + > (generate_runner (echo foo)))) + > + > (library + > (name foo_tmb) + > (inline_tests) + > (libraries backend_tmb1 backend_tmb2)) + > EOF + + $ dune runtest + File "dune", line 15, characters 1-15: + 15 | (inline_tests) + ^^^^^^^^^^^^^^ + Error: Too many independent inline tests backends found: + - "backend_tmb1" in _build/default + - "backend_tmb2" in _build/default + [1] From ce8990226e88b23b3edd5009620b4c40fa1d050d Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Sat, 11 Jul 2020 18:39:37 -0700 Subject: [PATCH 2/5] add test for multiple inline_tests in one dir This doesn't seem to work Signed-off-by: Rudi Grinberg --- test/blackbox-tests/dune.inc | 13 +++++++ .../multiple-inline-tests.t/run.t | 34 +++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 test/blackbox-tests/test-cases/inline_tests/multiple-inline-tests.t/run.t diff --git a/test/blackbox-tests/dune.inc b/test/blackbox-tests/dune.inc index 267bee05741..4e6d1991e14 100644 --- a/test/blackbox-tests/dune.inc +++ b/test/blackbox-tests/dune.inc @@ -1612,6 +1612,17 @@ 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 @@ -3283,6 +3294,7 @@ (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) @@ -3577,6 +3589,7 @@ (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) diff --git a/test/blackbox-tests/test-cases/inline_tests/multiple-inline-tests.t/run.t b/test/blackbox-tests/test-cases/inline_tests/multiple-inline-tests.t/run.t new file mode 100644 index 00000000000..e60be089aa7 --- /dev/null +++ b/test/blackbox-tests/test-cases/inline_tests/multiple-inline-tests.t/run.t @@ -0,0 +1,34 @@ +Test for multiple libraries with inline_tests set in the same directory + + $ cat >dune-project < (lang dune 2.6) + > EOF + +Create a dummy backend and two libraries with inline_tests + + $ cat >dune < (library + > (name backend_simple) + > (modules ()) + > (inline_tests.backend + > (generate_runner (echo "print_endline \"test\"")))) + > + > (library + > (name foo_simple1) + > (modules ()) + > (inline_tests (backend backend_simple))) + > + > (library + > (name foo_simple2) + > (modules ()) + > (inline_tests (backend backend_simple))) + > EOF + +try to run them: + + $ env -u OCAMLRUNPARAM dune runtest + Error: Multiple rules generated for + _build/.aliases/default/runtest-b11519c7100cda2ee17e767e4ea9f6b3: + - dune:15 + - dune:10 + [1] From 87374154d91331e93572b67740e18ae96a863a48 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Sat, 11 Jul 2020 19:12:53 -0700 Subject: [PATCH 3/5] Allow multiple inline tests in a directory choose a unique name for the runner based on the library name Signed-off-by: Rudi Grinberg --- CHANGES.md | 3 +++ src/dune/inline_tests.ml | 2 +- .../test-cases/inline_tests-multi-mode.t/run.t | 4 ++-- .../test-cases/inline_tests/dune-file.t/run.t | 4 ++-- .../inline_tests/many-backends-choose.t/run.t | 2 +- .../inline_tests/multiple-inline-tests.t/run.t | 9 ++++----- .../test-cases/inline_tests/simple.t/run.t | 12 ++++++------ 7 files changed, 19 insertions(+), 17 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index d3a8c0d80ef..01fedcd1116 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -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) ------------------ diff --git a/src/dune/inline_tests.ml b/src/dune/inline_tests.ml index ebdc9b707b3..ac6609cdb40 100644 --- a/src/dune/inline_tests.ml +++ b/src/dune/inline_tests.ml @@ -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 diff --git a/test/blackbox-tests/test-cases/inline_tests-multi-mode.t/run.t b/test/blackbox-tests/test-cases/inline_tests-multi-mode.t/run.t index 467ebfaaf35..8d88a58cab3 100644 --- a/test/blackbox-tests/test-cases/inline_tests-multi-mode.t/run.t +++ b/test/blackbox-tests/test-cases/inline_tests-multi-mode.t/run.t @@ -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 diff --git a/test/blackbox-tests/test-cases/inline_tests/dune-file.t/run.t b/test/blackbox-tests/test-cases/inline_tests/dune-file.t/run.t index e9473885dbf..ea0c1827590 100644 --- a/test/blackbox-tests/test-cases/inline_tests/dune-file.t/run.t +++ b/test/blackbox-tests/test-cases/inline_tests/dune-file.t/run.t @@ -1,5 +1,5 @@ $ dune runtest dune-file | sed "s/(lang dune .*)/(lang dune )/" | dune_cmd sanitize - run alias dune-file/runtest + inline_test_runner_foo_tests alias dune-file/runtest 414243 (lang dune ) (name foo) @@ -55,5 +55,5 @@ 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' - run alias runtest + inline_test_runner_foo_tests alias runtest 414243 diff --git a/test/blackbox-tests/test-cases/inline_tests/many-backends-choose.t/run.t b/test/blackbox-tests/test-cases/inline_tests/many-backends-choose.t/run.t index e68244e68d8..55608b221ec 100644 --- a/test/blackbox-tests/test-cases/inline_tests/many-backends-choose.t/run.t +++ b/test/blackbox-tests/test-cases/inline_tests/many-backends-choose.t/run.t @@ -21,5 +21,5 @@ > EOF $ dune runtest - run alias runtest + inline_test_runner_foo_mbc alias runtest backend_mbc1 diff --git a/test/blackbox-tests/test-cases/inline_tests/multiple-inline-tests.t/run.t b/test/blackbox-tests/test-cases/inline_tests/multiple-inline-tests.t/run.t index e60be089aa7..53669cea881 100644 --- a/test/blackbox-tests/test-cases/inline_tests/multiple-inline-tests.t/run.t +++ b/test/blackbox-tests/test-cases/inline_tests/multiple-inline-tests.t/run.t @@ -27,8 +27,7 @@ Create a dummy backend and two libraries with inline_tests try to run them: $ env -u OCAMLRUNPARAM dune runtest - Error: Multiple rules generated for - _build/.aliases/default/runtest-b11519c7100cda2ee17e767e4ea9f6b3: - - dune:15 - - dune:10 - [1] + inline_test_runner_foo_simple1 alias runtest + test + inline_test_runner_foo_simple2 alias runtest + test diff --git a/test/blackbox-tests/test-cases/inline_tests/simple.t/run.t b/test/blackbox-tests/test-cases/inline_tests/simple.t/run.t index 67f698a430a..40c39e62a40 100644 --- a/test/blackbox-tests/test-cases/inline_tests/simple.t/run.t +++ b/test/blackbox-tests/test-cases/inline_tests/simple.t/run.t @@ -24,9 +24,9 @@ > EOF $ env -u OCAMLRUNPARAM dune runtest - run alias runtest (exit 2) - (cd _build/default && .foo_simple.inline-tests/run.exe) - Fatal error: exception File ".foo_simple.inline-tests/run.ml-gen", line 1, characters 40-46: Assertion failed + inline_test_runner_foo_simple alias runtest (exit 2) + (cd _build/default && .foo_simple.inline-tests/inline_test_runner_foo_simple.exe) + Fatal error: exception File ".foo_simple.inline-tests/inline_test_runner_foo_simple.ml-gen", line 1, characters 40-46: Assertion failed [1] The expected behavior for the following three tests is to output nothing: the tests are disabled or ignored. @@ -37,7 +37,7 @@ The expected behavior for the following three tests is to output nothing: the te $ env -u OCAMLRUNPARAM dune runtest --profile ignore-inline-tests $ env -u OCAMLRUNPARAM dune runtest --profile enable-inline-tests - run alias runtest (exit 2) - (cd _build/default && .foo_simple.inline-tests/run.exe) - Fatal error: exception File ".foo_simple.inline-tests/run.ml-gen", line 1, characters 40-46: Assertion failed + inline_test_runner_foo_simple alias runtest (exit 2) + (cd _build/default && .foo_simple.inline-tests/inline_test_runner_foo_simple.exe) + Fatal error: exception File ".foo_simple.inline-tests/inline_test_runner_foo_simple.ml-gen", line 1, characters 40-46: Assertion failed [1] From ddd068c3c1cf50827bd1ba8f1b9040a567093b70 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Mon, 13 Jul 2020 15:53:51 -0700 Subject: [PATCH 4/5] Add description to dune-file.t test Signed-off-by: Rudi Grinberg --- .../test-cases/inline_tests/dune-file.t/run.t | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/test/blackbox-tests/test-cases/inline_tests/dune-file.t/run.t b/test/blackbox-tests/test-cases/inline_tests/dune-file.t/run.t index ea0c1827590..5e80c9393ff 100644 --- a/test/blackbox-tests/test-cases/inline_tests/dune-file.t/run.t +++ b/test/blackbox-tests/test-cases/inline_tests/dune-file.t/run.t @@ -1,3 +1,8 @@ +This test makes sure that inline_tests backends are functional when they are +externally installed. + +First we build the backend: + $ dune runtest dune-file | sed "s/(lang dune .*)/(lang dune )/" | dune_cmd sanitize inline_test_runner_foo_tests alias dune-file/runtest 414243 @@ -38,6 +43,8 @@ (echo "\n") (echo "let () = print_int 43;;"))))) +Then we install the backend: + $ 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 @@ -51,7 +58,8 @@ Installing install/lib/foo/foo.ml Installing install/lib/foo/opam -Make sure we can read generated dune-package files: +Now we make sure that we can use the backend when it's available as an external +package: $ export OCAMLPATH=$PWD/install/lib; dune runtest --root dune-file-user Entering directory 'dune-file-user' From 3eb6b640207d348efb9017b630383923b606dd8e Mon Sep 17 00:00:00 2001 From: Jeremie Dimino Date: Tue, 14 Jul 2020 10:17:28 +0100 Subject: [PATCH 5/5] Make the inline_tests test more focused Signed-off-by: Jeremie Dimino --- .../inline_tests/dune-file.t/dune-file/dune | 4 -- .../test-cases/inline_tests/dune-file.t/run.t | 55 ++++--------------- 2 files changed, 10 insertions(+), 49 deletions(-) diff --git a/test/blackbox-tests/test-cases/inline_tests/dune-file.t/dune-file/dune b/test/blackbox-tests/test-cases/inline_tests/dune-file.t/dune-file/dune index 20167ea0c03..1f712cb4ceb 100644 --- a/test/blackbox-tests/test-cases/inline_tests/dune-file.t/dune-file/dune +++ b/test/blackbox-tests/test-cases/inline_tests/dune-file.t/dune-file/dune @@ -17,7 +17,3 @@ (library (name foo_tests) (inline_tests (backend foo))) - -(alias - (name runtest) - (action (echo %{read:foo.dune-package}))) diff --git a/test/blackbox-tests/test-cases/inline_tests/dune-file.t/run.t b/test/blackbox-tests/test-cases/inline_tests/dune-file.t/run.t index 5e80c9393ff..78738c46429 100644 --- a/test/blackbox-tests/test-cases/inline_tests/dune-file.t/run.t +++ b/test/blackbox-tests/test-cases/inline_tests/dune-file.t/run.t @@ -1,31 +1,18 @@ This test makes sure that inline_tests backends are functional when they are externally installed. -First we build the backend: +First we build and use the backend locally: - $ dune runtest dune-file | sed "s/(lang dune .*)/(lang dune )/" | dune_cmd sanitize + $ dune runtest dune-file inline_test_runner_foo_tests alias dune-file/runtest 414243 - (lang dune ) - (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))) + +Then we install the backend and check that the "inline_tests.backend" +field is properly generated in the installed `dune-package` file: + + $ dune build dune-file/foo.install + $ dune install foo --prefix _install 2> /dev/null + $ grep -A8 inline_tests.backend _install/lib/foo/dune-package (inline_tests.backend (runner_libraries str) (flags @@ -35,33 +22,11 @@ First we build the backend: %{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;;"))))) - -Then we install the backend: - - $ 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 Now we make sure that we can use the backend when it's available as an external package: - $ export OCAMLPATH=$PWD/install/lib; dune runtest --root dune-file-user + $ export OCAMLPATH=$PWD/_install/lib; dune runtest --root dune-file-user Entering directory 'dune-file-user' inline_test_runner_foo_tests alias runtest 414243