LoginSignup
4
4

More than 5 years have passed since last update.

Windows上でPHP拡張のテストを行う方法

Last updated at Posted at 2017-07-13

下記記事にまとめた通り、Linux/macOS上であればPHP拡張のテストは make test で動かすのが普通です。

しかし、Windows環境では通常makeコマンドが動きません。PHP拡張のテストをするにはrun-tests.phpを直接呼び出すしかないように思います。

下記では、自作のPHP拡張のテストをXAMPP環境で行ったときの内容を記録しています。

テスト対象のPHP拡張のDLLをインストール

まずはテストしたいPHP拡張のDLLをインストールしましょう。 extension_dirにDLLを設置します。

テスト対象のPHP拡張のソースコードをダウンロード

テスト対象のPHP拡張のソースコードを適当な場所にダウンロードします。

> cd c:\xampp\php
> git clone https://github.com/hnw/php-timecop.git 
> cd php-timecop

run-tests.php のダウンロード

Linux/macOS環境であれば、 run-tests.php はphpizeコマンドが用意してくれますが、Windows環境ではphpizeがないので run-tests.php も手に入りません。wgetなどで落としてきましょう。

> wget https://github.com/php/php-src/raw/master/run-tests.php

run-tests.php の実行

> SET TEST_PHP_EXECUTABLE=..\php.exe
> SET NO_INTERACTION=1
> ..\php.exe run-tests.php --show-diff

=====================================================================
PHP         : ..\php.exe
PHP_SAPI    : cli
PHP_VERSION : 7.1.6
ZEND_VERSION: 3.1.0
PHP_OS      : WINNT - Windows NT WAFFLE 10.0 build 15063 (Windows 10) i586
INI actual  : C:\xampp\php\php.ini
More .INIs  :
---------------------------------------------------------------------
PHP         : C:\xampp\php\phpdbg.exe
PHP_SAPI    : phpdbg
PHP_VERSION : 7.1.6
ZEND_VERSION: 3.1.0
PHP_OS      : WINNT - Windows NT WAFFLE 10.0 build 15063 (Windows 10) i586
INI actual  : C:\xampp\php\php.ini
More .INIs  :
---------------------------------------------------------------------
CWD         : C:\xampp\php\php-timecop
Extra dirs  :
VALGRIND    : Not used
=====================================================================
TIME START 2017-07-14 00:07:43
=====================================================================
PASS Check for timecop_freeze() [C:\xampp\php\php-timecop\tests\core_001.phpt]

(snip)

=====================================================================
TIME END 2017-07-14 00:07:57

=====================================================================
TEST RESULT SUMMARY
---------------------------------------------------------------------
Exts skipped    :    0
Exts tested     :   42
---------------------------------------------------------------------

Number of tests :   71                69
Tests skipped   :    2 (  2.8%) --------
Tests warned    :    0 (  0.0%) (  0.0%)
Tests failed    :    6 (  8.5%) (  8.7%)
Expected fail   :    0 (  0.0%) (  0.0%)
Tests passed    :   63 ( 88.7%) ( 91.3%)
---------------------------------------------------------------------
Time taken      :   14 seconds
=====================================================================

=====================================================================
FAILED TEST SUMMARY
---------------------------------------------------------------------
Check for timecop_scale() [C:\xampp\php\php-timecop\tests\core_003.phpt]
Check for Timecop::travel() [C:\xampp\php\php-timecop\tests\core_006.phpt]
Test for timecop_mktime() [C:\xampp\php\php-timecop\tests\func_002.phpt]
Test for timecop_gmmktime() [C:\xampp\php\php-timecop\tests\func_003.phpt]
Function overrideing test for mktime() [C:\xampp\php\php-timecop\tests\func_override_002.phpt]
Function overrideing test for gmmktime() [C:\xampp\php\php-timecop\tests\func_override_003.phpt]
=====================================================================

無事にテストが走り、Windows上でのみ失敗するテストが見つかったりします。

4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4