31.5. Определение покрытия кода тестами

Исходный код PostgreSQL может быть скомпилирован с инструментарием определения покрытия, чтобы узнать, какие части кода покрываются регрессионными тестами или другими комплектами тестов, выполняемыми в дереве кода. В настоящее время эта возможность поддерживается в случае использования компилятора GCC и требует наличия gcov и lcov программ.

Типичный рабочий процесс выглядит так:

./configure --enable-coverage ... OTHER OPTIONS ...
make
make check # или другой комплект тестов
make coverage-html

Затем откройте в своём HTML-браузере страницу coverage/index.html. Команды make работают и в подкаталогах.

Чтобы обнулить подсчёт выполнений между тестами, запустите:

make coverage-clean

31.5. Test Coverage Examination

The PostgreSQL source code can be compiled with coverage testing instrumentation, so that it becomes possible to examine which parts of the code are covered by the regression tests or any other test suite that is run with the code. This is currently supported when compiling with GCC and requires the gcov and lcov programs.

A typical workflow would look like this:

./configure --enable-coverage ... OTHER OPTIONS ...
make
make check # or other test suite
make coverage-html

Then point your HTML browser to coverage/index.html. The make commands also work in subdirectories.

To reset the execution counts between test runs, run:

make coverage-clean

FAQ