Skip to content

Commit 98da0e5

Browse files
committed
doc: document dune runtest for test stanza and inline tests
Signed-off-by: Ali Caglayan <[email protected]>
1 parent d17fc59 commit 98da0e5

File tree

2 files changed

+20
-16
lines changed

2 files changed

+20
-16
lines changed

doc/reference/dune/test.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ This defines an executable named ``mytest.exe``. These tests can be run by
3030
building the aliases ``runtest-mytest`` and ``runtest-expect_test``
3131
respectively. They will also be added to the ``runtest`` alias.
3232

33+
You may also run the test directly by using ``dune runtest`` and passing the
34+
name of the test: ``dune runtest mytest``. If the test stanza was in a
35+
directory ``src/`` then it would be ``dune runtest src/mytest``.
36+
3337
If the directory also contains an ``expect_test.expected`` file, then
3438
``expect_test`` will be used to define an expect test. That is, the test will be
3539
executed and its output will be compared to ``expect_test.expected``.

doc/tests.rst

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -42,35 +42,33 @@ call ``dune runtest`` from the shell (or the command alias ``dune test``). This
4242
will run all the tests defined in the current directory and any subdirectory
4343
recursively.
4444

45-
Note that in any case, ``dune runtest`` is simply shorthand for building the
46-
``runtest`` alias, so you can always ask Dune to run the tests in conjunction
47-
with other targets by passing ``@runtest`` to ``dune build``. For instance:
48-
49-
.. code:: console
50-
51-
$ dune build @install @runtest
52-
$ dune build @install @test/runtest
53-
54-
5545
Running a Single Test
5646
---------------------
5747

58-
If you would only like to run a single test for your project, you may use ``dune
59-
exec`` to run the test executable (for the sake of this example,
60-
``project/tests/myTest.ml``):
48+
If you would only like to run a single test for your project, you may use
49+
``dune runtest`` to run the :doc:`test<reference/dune/test>` executable (for
50+
the sake of this example, ``project/tests/myTest.ml``):
6151

6252
.. code:: console
6353
64-
$ dune exec project/tests/myTest.exe
54+
$ dune runtest project/tests/myTest
6555
66-
To run :ref:`cram-tests` you can pass their paths to the ``dune test`` command.
56+
To run :ref:`cram-tests` you can pass their paths to the ``dune runtest``
57+
command.
6758

6859
.. code:: console
6960
70-
$ dune test tests/myCramTest.t
61+
$ dune runtest tests/myCramTest.t
7162
7263
This works both for directory and file cram tests.
7364

65+
Library stanzas with :ref:`inline tests<inline_tests>` enabled may also be run
66+
by passing the name of the library:
67+
68+
.. code:: console
69+
70+
$ dune runtest tests/myinlinetestlib
71+
7472
Running Tests in a Directory
7573
----------------------------
7674

@@ -461,6 +459,8 @@ this is only an example. We don't recommend using ``sed`` in your
461459
build, as this would cause portability problems.
462460

463461

462+
.. _test_stanza:
463+
464464
Custom Tests
465465
============
466466

0 commit comments

Comments
 (0)