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";
32 // もとから存在した symlink は削除しない
33 $symlink_filename = null;
38 /** テストケースがあるディレクトリ */
39 $test_dir = ETHNA_INSTALL_BASE . '/test';
41 /** include_pathの設定(このtest runnerがあるディレクトリを追加) */
42 //ini_set('include_path', realpath(ETHNA_INSTALL_BASE . '/class') . PATH_SEPARATOR . ini_get('include_path'));
43 ini_set('include_path', realpath(dirname(ETHNA_INSTALL_BASE)) . PATH_SEPARATOR . ini_get('include_path'));
45 /** Ethna関連クラスのインクルード */
46 require_once 'Ethna/Ethna.php';
48 /** SimpleTestのインクルード */
49 require_once 'simpletest/unit_tester.php';
50 require_once 'simpletest/reporter.php';
51 require_once $test_dir . '/TextDetailReporter.php';
52 require_once $test_dir . '/Ethna_UnitTestBase.php';
54 $test = new GroupTest('Ethna All tests');
57 require_once 'Ethna/class/Ethna_Getopt.php';
58 $opt = new Ethna_Getopt();
59 $args = $opt->readPHPArgv();
60 list($args, $opts) = $opt->getopt($args, '', array());
62 if (count($opts) > 0) {
65 $file_list = getFileList($test_dir);
69 foreach ($file_list as $file) {
70 $test->addTestFile($file);
74 $test->run(new TextDetailReporter());
76 if ($symlink_filename !== null && is_link($symlink_filename)) {
77 unlink($symlink_filename);
84 * @param string $dir_path
86 function getFileList($dir_path)
90 $dir = opendir($dir_path);
96 while($file_path = readdir($dir)) {
98 $full_path = $dir_path . '/'. $file_path;
100 if (is_file($full_path)){
103 if (preg_match('/^(Ethna_)(.*)(_Test.php)$/',$file_path,$matches)) {
104 $file_list[] = $full_path;
107 // サブディレクトリがある場合は,再帰的に読み込む.
108 // "."で始まるディレクトリは読み込まない.
109 } else if (is_dir($full_path) && !preg_match('/^\./',$file_path,$matches)) {
111 $file_list = array_merge($file_list,getFileList($full_path));