1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
|
.. m-unit-tests documentation master file, created by
sphinx-quickstart on Fri Oct 31 14:20:36 2014.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Dynare's m-unit-tests module
============================
Contents:
.. toctree::
:maxdepth: 2
.. function:: get_directory_description(basedir)
Returns a list of ``*.m`` files in directory ``basedir`` and its
subfolders. The input argument ``basedir`` is a string and the
returned argument is cell of strings with \\(n\\) elements where
each element is the relative address of a file. The default value
for ``basedir``is the current directory.
.. function:: is_unitary_test_available(fname)
Returns ``1`` if unitary tests defined in matlab routine ``fname``
have to be run, ``0`` otherwise. The mandatory input argument
``fname`` is a string. The returned argument is set equal to one if
and only if the first line contains the following comment:
.. code-block:: matlab
% --*-- Unitary tests --*--
after the function header.
.. function:: mtest(fname[, fpath])
Extracts unit test sections from matlab's routine ``fname``
executes the tests and reports results.
**INPUTS**
- ``fname`` (*string*) Name of the Matlab routine where unit
tests to be run are defined.
- ``fpath`` (*string*) Path to the routine (optional).
**OUTPUTS**
- ``check`` (*integer*) Scalar equal to 0 if the test fails and 1
otherwise.
- ``info`` (*cell*) Describes the test results. Cell info has nn
rows and five columns. Each row correponds to a unitary test in
fname, and the columns report the following informations:
- Column 1 Name of the tested routine.
- Column 2 Number of the unitary test.
- Column 3 Status of the unitary test (0 if the unitary test fails, 1 otherwise).
- Column 4 Details about the failure (vector of 0 and 1).
- Column 5 Elapsed time in seconds (cpu time).
**REMARKS**
1. If only one input argument is provided, ``fname`` must contain
the full path to the routine.
2. For each unit test, :func:`mtest` generates a matlab function
saved in ``<fname>_test_x.m`` and runs the function. If the
function does not return errors the file is erased, otherwise the
file is kept on disk.
.. function:: dtest(fname[, tpath])
Runs unit tests defined in ``fname``, by calling :func:`mtest`
routine, and displays the results.
**INPUTS**
- ``fname`` (*string*) Name (with path) of the Matlab routine
where unit tests to be run are defined.
- ``tpath`` (*string*) Path to the folder where the test routines
generated by :func:`mtest` should be temporarly saved
(optional, default value is the current directory).
**OUTPUTS**
None
**REMARKS**
1. The full path to the tested routine must be provided in ``fname``.
.. function:: run_unitary_tests(listoffiles)
Runs unitary tests defined in a collection of files.
**INPUTS**
- ``listoffiles`` (*cell of strings*) The list of m files (with
path) where the unitary tests are written. This cell, with
\\(n\\) elements, is the output of :func:`get_directory_description` routine.
**OUTPUTS**
- ``report`` (*cell*) Results of the unitary tests (\\(n\\) rows
and five columns). Each row stores the second output argument
of :func:`mtest` routine (info).
- ``time`` (*double*) Current date and time as date vector (see
matlab's documentation for the ``clock`` function).
.. function:: run_unitary_tests_in_directory(dirname[, savereport[, printreport, sendreport])
Runs all the unitary tests defined in a directory (and subfolders).
**INPUTS**
- ``dirname`` (*string*) Path to the directory.
- ``savereport`` (*logical*) Scalar equal to ``false`` or ``true``. If equal to ``true`` generated report is saved in a ``*.mat`` file.
- ``printreport`` (*logical*) Scalar equal to ``false`` or ``true``. If equal to ``true`` generated report is printed on screen.
- ``sendreport`` (*string*) Email adress. If not empty generated report is sent by email.
**OUTPUTS**
- ``report`` (*cell*) First output argument of :func:`run_unitary_test routine`.
**REMARKS**
1. Git needs to be available on the system, and it is assumed that the content of ``dirname`` is versionned with Git.
.. function:: display_report(report)
Displays detailed report for the testsuite.
**INPUTS**
- ``report`` (*cell*) Output of :func:`run_unitary_tests_in_directory`.
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
|