MOxUnit / MOcov

A coverage report generator for Matlab and GNU Octave.
20 stars 12 forks source link

MOcov : A coverage report generator for Matlab and GNU-Octave

tests status

MOcov is a coverage report generator for Matlab and GNU-Octave.

Features

Installation

Determining coverage

Coverage can be determined for evaluating a single expression or evaluation of a single function handle; for typical use cases this invokes running a test suite.

There are two methods to generate coverage while evaluating such an expression or function handle:

  1. the 'file' method (default)

    • Coverage information is stored internally by the function mocov_line_covered, which keeps this information through the use of persistent variables. Initially the coverage information is reset to being empty.
    • This method considers all files in a directory (and its subdirectories).
    • A temporary directory is created where modified versions of each file is stored.
    • Prior to evaluting the expression or function handle, for each file, MOcov determines which of its lines can be executed. Each line that can be executed is prefixed by a call to mocov_line_covered, which cause it to update internal state to record the filename and line number that was executed, and the result stored in the temporary directory.
    • The search path is updated to include the new temporary directory.

    After evaluating the expression or function handle, the temporary directory is deleted and the search path restored. Line coverage information is then extracted from the internal state of mocov_line_covered.

    This method runs on both GNU Octave and Matlab, but is typically slow.

  2. the 'profile' method

    • It uses the Matlab profiler.
    • This method runs on Matlab only (not on GNU Octave), but is generally faster.

Use cases

Typical use cases for MOcov are:

Use with travis-ci and Shippable

MOcov can be used with the Travis-ci and Shippable services for continuous integration testing. This is achieved by setting up a travis.yml file. Due to recursiveness issues, MOcov cannot use these services to generate coverage reports for itself; for an example in the related MOxUnit project, see the travis.yml configuration file file.

Compatibility notes

Limitations

Contact

Nikolaas N. Oosterhof, nikolaas dot oosterhof at unitn dot it

Contributions

License

(The MIT License)

Copyright (c) 2015-2017 Nikolaas N. Oosterhof

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.