7 * @author Kazuhiro Hosoi <hosoi@gree.co.jp>
8 * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
13 /** Ethnaインストールルートディレクトリ */
14 define('ETHNA_INSTALL_BASE', dirname(dirname(__FILE__)));
16 $symlink_filename = null;
18 /** シンボリックリンクをインストールディレクトリの親に張る */
19 /** symlink 関数は 5.3.0 以前では Windows 上で動作しない */
20 /** が、Cygwinでテストするため問題はない。 */
21 if (basename(ETHNA_INSTALL_BASE) != 'Ethna') {
22 $symlink_filename = dirname(ETHNA_INSTALL_BASE) . "/Ethna";
23 if (!file_exists($symlink_filename)) {
24 symlink(ETHNA_INSTALL_BASE, $symlink_filename);
26 if (!is_link($symlink_filename)
27 || realpath($symlink_filename) != ETHNA_INSTALL_BASE) {
28 echo "Base dir 'Ethna' exists and it's not ETHNA_INSTALL_BASE.\n";
34 /** テストケースがあるディレクトリ */
35 $test_dir = ETHNA_INSTALL_BASE . '/test';
37 /** include_pathの設定(このtest runnerがあるディレクトリを追加) */
38 //ini_set('include_path', realpath(ETHNA_INSTALL_BASE . '/class') . PATH_SEPARATOR . ini_get('include_path'));
39 ini_set('include_path', realpath(dirname(ETHNA_INSTALL_BASE)) . PATH_SEPARATOR . ini_get('include_path'));
41 /** Ethna関連クラスのインクルード */
42 require_once 'Ethna/Ethna.php';
44 /** SimpleTestのインクルード */
45 require_once 'simpletest/unit_tester.php';
46 require_once 'simpletest/reporter.php';
47 require_once $test_dir . '/TextDetailReporter.php';
48 require_once $test_dir . '/Ethna_UnitTestBase.php';
50 $test = &new GroupTest('Ethna All tests');
53 require_once 'Ethna/class/Ethna_Getopt.php';
54 $opt = new Ethna_Getopt();
55 $args = $opt->readPHPArgv();
56 list($args, $opts) = $opt->getopt($args, '', array());
58 if (count($opts) > 0) {
61 $file_list = getFileList($test_dir);
65 foreach ($file_list as $file) {
66 $test->addTestFile($file);
70 $test->run(new TextDetailReporter());
72 if ($symlink_filename !== null && is_link($symlink_filename)) {
73 unlink($symlink_filename);
80 * @param string $dir_path
82 function getFileList($dir_path)
86 $dir = opendir($dir_path);
92 while($file_path = readdir($dir)) {
94 $full_path = $dir_path . '/'. $file_path;
96 if (is_file($full_path)){
99 if (preg_match('/^(Ethna_)(.*)(_Test.php)$/',$file_path,$matches)) {
100 $file_list[] = $full_path;
103 // サブディレクトリがある場合は,再帰的に読み込む.
104 // "."で始まるディレクトリは読み込まない.
105 } else if (is_dir($full_path) && !preg_match('/^\./',$file_path,$matches)) {
107 $file_list = array_merge($file_list,getFileList($full_path));