Do You PHP はてブロ

Do You PHPはてなからはてブロに移動しました

OCI8拡張モジュールのテスト方法


あまりドキュメント化されていない気がしますが、Christopher Jones氏のサイトでまとめられています。


The PHP source code includes tests for all the core functionality and extensions. You should run the tests after building PHP.

You should also strongly consider contributing tests to the PHP community. Adding tests that are relevant to your application minimizes the risks of PHP developers breaking PHP features important to you.

OracleXEを使った例ですが、手順はざっと以下のようになります。

  1. ext/oci8/tests/details.incの「$password」「$dbase」「$oracle_on_localhost」を適宜変更する
  2. php.ini(もしくはphp-cli.ini)の「variables_order」の先頭に「E」を追加する
  3. oracle_env.shを実行する
  4. PHPのソースディレクトリに移動し、「make test」もしくは「make test TESTS=ext/oci8」を実行する

注意点としては、NLS_LANGの値を変更して、メッセージを英語表記にしておくことが挙げられます。

$ export NLS_LANG=american_america.ja16euc

で、CentOS4.4+PHP 5.2.2RC1+Oracle XE 10.2.0.1でやってみましたが、いくつか失敗しました。

=====================================================================
Number of tests :  182               180
Tests skipped   :    2 (  1.1%) --------
Tests warned    :    0 (  0.0%) (  0.0%)
Tests failed    :    3 (  1.6%) (  1.7%)
Tests passed    :  177 ( 97.3%) ( 98.3%)
---------------------------------------------------------------------
Time taken      :   48 seconds
=====================================================================

=====================================================================
FAILED TEST SUMMARY
---------------------------------------------------------------------
oci_lob_write()/erase()/read() with CLOBs [ext/oci8/tests/lob_020.phpt]
Test CLOB->write() for multiple inserts [ext/oci8/tests/lob_039.phpt]
privileged connect tests [ext/oci8/tests/privileged_connect1.phpt]
=====================================================================

SKIPされた2つは意図的なもののようです。失敗したモノは、時間があれば掘り下げてみますかね。。。