|
|
(26 intermediate revisions by 9 users not shown) |
Line 1: |
Line 1: |
| ==Coverage With C++==
| | {{CMake/Template/Moved}} |
|
| |
|
| Currently coverage is only supported on gcc compiler. To perform coverage test, make sure that your code is build with debug symbols, without optimization, and with special flags. These flags are:
| | This page has moved [https://gitlab.kitware.com/cmake/community/wikis/doc/ctest/Coverage here]. |
| | |
| -fprofile-arcs -ftest-coverage
| |
| | |
| Also make sure to pass these flags to C compiler, CXX compiler, and the linker. For example:
| |
| | |
| CXXFLAGS="-g -O0 -Wall -W -Wshadow -Wunused-variable \
| |
| -Wunused-parameter -Wunused-function -Wunused -Wno-system-headers \
| |
| -Wno-deprecated -Woverloaded-virtual -Wwrite-strings -fprofile-arcs -ftest-coverage"
| |
| CFLAGS="-g -O0 -Wall -W -fprofile-arcs -ftest-coverage"
| |
| LDFLAGS="-fprofile-arcs -ftest-coverage"
| |
| | |
| ==Coverage With Python==
| |
| | |
| Typical usage:
| |
| | |
| $ cat hello.py
| |
| <pre>
| |
| """
| |
| Comment #1
| |
| """
| |
| def untested():
| |
| print "untested"
| |
| | |
| """
| |
| Comment #2
| |
| """
| |
| def tested():
| |
| print "tested"
| |
| | |
| """
| |
| Comment #3
| |
| """
| |
| if __name__ == '__main__':
| |
| tested()
| |
| </pre>
| |
| | |
| $ python /usr/lib/python2.3/trace.py -c --coverdir=. --ignore-dir /usr/lib/python2.3 hello.py
| |
| | |
| will produce a file
| |
| | |
| hello.cover
| |
| | |
| $ cat hello.cover
| |
| <pre>
| |
| """
| |
| Comment #1
| |
| 1: """
| |
| 1: def untested():
| |
| print "untested"
| |
| | |
| """
| |
| Comment #2
| |
| """
| |
| 1: def tested():
| |
| 1: print "tested"
| |
| | |
| """
| |
| Comment #3
| |
| """
| |
| 1: if __name__ == '__main__':
| |
| 1: tested()
| |
| </pre>
| |
Latest revision as of 15:41, 30 April 2018