バージョンごとのドキュメント一覧

33.5. テストが網羅する範囲の検証 #

<title>Test Coverage Examination</title>

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 it requires the <literal>gcov</literal> and <literal>lcov</literal> packages. PostgreSQLソースコードは、カバレッジテストツールとともにコンパイルすることができるため、リグレッションテスト、あるいはその他のテストスイートによって、コードのどの部分が網羅されているかを評価することができます。 これは現在、GCCを使用してコンパイルした時にサポートされ、gcovおよびlcovパッケージを必要とします。

33.5.1. AutoconfとMakeでのカバレッジ #

<title>Coverage with Autoconf and Make</title>

A typical workflow looks like this: 典型的な作業の流れは以下のようになります。

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

Then point your HTML browser to <filename>coverage/index.html</filename>. そして、HTMLブラウザでcoverage/index.htmlを参照します。

If you don't have <command>lcov</command> or prefer text output over an HTML report, you can run lcovがない、あるいは、HTMLレポートよりもテキスト出力を好むなら、以下を実行してください。

make coverage

instead of <literal>make coverage-html</literal>, which will produce <filename>.gcov</filename> output files for each source file relevant to the test. (<literal>make coverage</literal> and <literal>make coverage-html</literal> will overwrite each other's files, so mixing them might be confusing.) make coverage-htmlの代わりに、これはテストに関連する各ソースファイルに対して.gcov出力ファイルを生成します。 (make coveragemake coverage-htmlは互いのファイルを上書きしますので、混用は混乱をひき起こすかもしれません)

You can run several different tests before making the coverage report; the execution counts will accumulate. If you want to reset the execution counts between test runs, run: カバレッジレポートを作成する前に複数の異なるテストを実行できます。実行カウントは累積されます。 実行カウントをテストの間でリセットしたければ、以下を実行してください。

make coverage-clean

You can run the <literal>make coverage-html</literal> or <literal>make coverage</literal> command in a subdirectory if you want a coverage report for only a portion of the code tree. コードツリーの一部だけのカバレッジレポートが必要ならば、make coverage-htmlあるいはmake coverageコマンドをそのサブディレクトリで実行することができます。

Use <literal>make distclean</literal> to clean up when done. 終了後に結果を削除するにはmake distcleanを実行します。

33.5.2. Mesonでのカバレッジ #

<title>Coverage with Meson</title>

A typical workflow looks like this: 典型的な作業の流れは以下のようになります。

meson setup -Db_coverage=true ... OTHER OPTIONS ... builddir/
meson compile -C builddir/
meson test -C builddir/
cd builddir/
ninja coverage-html

Then point your HTML browser to <filename>./meson-logs/coveragereport/index.html</filename>. 次に、HTMLブラウザで./meson-logs/coveragereport/index.htmlを指定します。

You can run several different tests before making the coverage report; the execution counts will accumulate. カバレッジレポートを作成する前に複数の異なるテストを実行できます。実行回数は累積されます。