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

33.4. TAPテスト #

<title>TAP Tests</title>

Various tests, particularly the client program tests under <filename>src/bin</filename>, use the Perl TAP tools and are run using the Perl testing program <command>prove</command>. You can pass command-line options to <command>prove</command> by setting the <command>make</command> variable <varname>PROVE_FLAGS</varname>, for example: 様々なテスト、特にsrc/bin以下のクライアントプログラムテストはPerl TAPツールを使い、Perlテストプログラムproveを使って実行されます。 make変数PROVE_FLAGSを設定することでproveコマンドラインオプションを渡すことができます。 例えば、

make -C src/bin check PROVE_FLAGS='--timer'

See the manual page of <command>prove</command> for more information. 詳細な情報はproveのマニュアルページを参照してください。

The <command>make</command> variable <varname>PROVE_TESTS</varname> can be used to define a whitespace-separated list of paths relative to the <filename>Makefile</filename> invoking <command>prove</command> to run the specified subset of tests instead of the default <filename>t/*.pl</filename>. For example: デフォルトのt/*.plに替えて、テストの指定サブセットを実行するために、make変数PROVE_TESTSを使用できます。proveを起動するMakefileからの相対パスの空白区切りのリストを指定します。 以下に例を示します。

make check PROVE_TESTS='t/001_test1.pl t/003_test3.pl'

The TAP tests require the Perl module <literal>IPC::Run</literal>. This module is available from <ulink url="https://metacpan.org/dist/IPC-Run">CPAN</ulink> or an operating system package. They also require <productname>PostgreSQL</productname> to be configured with the option <option>&#45;-enable-tap-tests</option>. TAPテストはPerlモジュールIPC::Runが必要です。 このモジュールはCPANもしくはオペレーティングシステムのパッケージから入手可能です。 また、PostgreSQL--enable-tap-testsを有効にして構成しておく必要があります。

Generically speaking, the TAP tests will test the executables in a previously-installed installation tree if you say <literal>make installcheck</literal>, or will build a new local installation tree from current sources if you say <literal>make check</literal>. In either case they will initialize a local instance (data directory) and transiently run a server in it. Some of these tests run more than one server. Thus, these tests can be fairly resource-intensive. 一般的に言って、TAPテストは、make installcheckとした場合には以前インストールしたインストレーションツリーの実行ファイルをテストし、make checkとした場合には現在のソースから新しいインストレーションツリーを構築します。 どちらの場合も、ローカルインスタンス(データディレクトリ)を初期化し、その中で一時的にサーバを実行します。 テストの中には2つ以上のサーバを実行するものがあります。 従って、このテストはかなりリソース集約的になる可能性があります。

It's important to realize that the TAP tests will start test server(s) even when you say <literal>make installcheck</literal>; this is unlike the traditional non-TAP testing infrastructure, which expects to use an already-running test server in that case. Some PostgreSQL subdirectories contain both traditional-style and TAP-style tests, meaning that <literal>make installcheck</literal> will produce a mix of results from temporary servers and the already-running test server. make installcheckとした場合でも、TAPテストはテストサーバを開始することを理解しておくことは重要です。 これは伝統的な非TAPテスト基盤とは異なります。非TAPテスト基盤ではその場合、既に動作しているテストサーバを使うことが期待されます。 PostgreSQLのサブディレクトリには、伝統的な形式のテストとTAP形式のものの両方を含むものがありますので、make installcheckは一時的なサーバと既に動作しているテストサーバからの結果を寄せ集めることになります。

33.4.1. 環境変数 #

<title>Environment Variables</title>

Data directories are named according to the test filename, and will be retained if a test fails. If the environment variable <varname>PG_TEST_NOCLEAN</varname> is set, data directories will be retained regardless of test status. For example, retaining the data directory regardless of test results when running the <application>pg_dump</application> tests: データディレクトリは、テストファイル名に従って命名され、テストが失敗した場合は保持されます。 環境変数PG_TEST_NOCLEANが設定されている場合、テストステータスに関係なく、データディレクトリは保持されます。 たとえば、pg_dumpテストを実行するときに、テスト結果に関係なくデータディレクトリを保持するには、次のようにします。

PG_TEST_NOCLEAN=1 make -C src/bin/pg_dump check

This environment variable also prevents the test's temporary directories from being removed. この環境変数は、テストの一時ディレクトリが削除されないようにもします。

Many operations in the test suites use a 180-second timeout, which on slow hosts may lead to load-induced timeouts. Setting the environment variable <varname>PG_TEST_TIMEOUT_DEFAULT</varname> to a higher number will change the default to avoid this. テストスイートの多くの操作では、180秒のタイムアウトが使用されます。これは、低速なホストでは、ロードによってタイムアウトが誘発される可能性があります。 環境変数PG_TEST_TIMEOUT_DEFAULTをより大きな数値に設定すると、この問題を回避するためにデフォルトが変更されます。