OSDN Git Service

Merge branch 'release/2.6.0beta2'
[ethna/ethna.git] / bin / ethna_run_test.php
index 24fe840..325926b 100644 (file)
 /** Ethnaインストールルートディレクトリ */
 define('ETHNA_INSTALL_BASE', dirname(dirname(__FILE__)));
 
+$symlink_filename = null;
+
+/** シンボリックリンクをインストールディレクトリの親に張る */
+/** symlink 関数は 5.3.0 以前では Windows 上で動作しない   */
+/** が、Cygwinでテストするため問題はない。                 */
+if (basename(ETHNA_INSTALL_BASE) != 'Ethna') {
+    $symlink_filename = dirname(ETHNA_INSTALL_BASE) . "/Ethna";
+    if (!file_exists($symlink_filename)) {
+        symlink(ETHNA_INSTALL_BASE, $symlink_filename);
+    } else {
+        if (!is_link($symlink_filename)
+            || realpath($symlink_filename) != ETHNA_INSTALL_BASE) {
+            echo "Base dir 'Ethna' exists and it's not ETHNA_INSTALL_BASE.\n";
+            exit(1);
+        }
+        else {
+            // もとから存在した symlink は削除しない
+            $symlink_filename = null;
+        }
+    }
+}
+
+/** テストケースがあるディレクトリ */
+$test_dir = ETHNA_INSTALL_BASE . '/test';
+
 /** include_pathの設定(このtest runnerがあるディレクトリを追加) */
-ini_set('include_path', dirname(ETHNA_INSTALL_BASE) . PATH_SEPARATOR . ini_get('include_path'));
+//ini_set('include_path', realpath(ETHNA_INSTALL_BASE . '/class') . PATH_SEPARATOR . ini_get('include_path'));
+ini_set('include_path', realpath(dirname(ETHNA_INSTALL_BASE)) . PATH_SEPARATOR . ini_get('include_path'));
 
 /** Ethna関連クラスのインクルード */
 require_once 'Ethna/Ethna.php';
@@ -22,16 +48,13 @@ require_once 'Ethna/Ethna.php';
 /** SimpleTestのインクルード */
 require_once 'simpletest/unit_tester.php';
 require_once 'simpletest/reporter.php';
-require_once 'Ethna/test/TextDetailReporter.php';
-require_once 'Ethna/test/Ethna_UnitTestBase.php';
-
-/** テストケースがあるディレクトリ */
-$test_dir = ETHNA_BASE . '/test';
+require_once $test_dir . '/TextDetailReporter.php';
+require_once $test_dir . '/UnitTestBase.php';
 
-$test = &new GroupTest('Ethna All tests');
+$test = new GroupTest('Ethna All tests');
 
 // テストケースのファイルリストを取得
-require_once ETHNA_BASE . '/class/Ethna_Getopt.php';
+require_once 'Ethna/class/Getopt.php';
 $opt = new Ethna_Getopt();
 $args = $opt->readPHPArgv();
 list($args, $opts) = $opt->getopt($args, '', array());
@@ -50,6 +73,10 @@ foreach ($file_list as $file) {
 // 結果をコマンドラインに出力
 $test->run(new TextDetailReporter());
 
+if ($symlink_filename !== null && is_link($symlink_filename)) {
+    unlink($symlink_filename);
+}
+
 //{{{ getFileList
 /**
  * getFileList
@@ -73,7 +100,7 @@ function getFileList($dir_path)
         if (is_file($full_path)){
 
             // テストケースのファイルのみ読み込む
-            if (preg_match('/^(Ethna_)(.*)(_Test.php)$/',$file_path,$matches)) {
+            if (preg_match('/^(.*)(_Test.php)$/',$file_path,$matches)) {
                 $file_list[] = $full_path;
             }
 
@@ -90,4 +117,3 @@ function getFileList($dir_path)
 }
 //}}}
 
-?>