OSDN Git Service

テスト実行ファイルの動作を変更
authorsotarok <sotarok@2ef88817-412d-0410-a32c-8029a115e976>
Sun, 17 May 2009 13:18:17 +0000 (13:18 +0000)
committersotarok <sotarok@2ef88817-412d-0410-a32c-8029a115e976>
Sun, 17 May 2009 13:18:17 +0000 (13:18 +0000)
 * 実行するディレクトリのトップが Ethna という名前ではない場合,Ethnaという名前でシンボリックリンクを作成する

bin/ethna_run_test.php

index 94ef6d8..3e778ee 100644 (file)
 /** Ethnaインストールルートディレクトリ */
 define('ETHNA_INSTALL_BASE', dirname(dirname(__FILE__)));
 
+$symlink_filename = null;
+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)
+            || readlink($symlink_filename) != ETHNA_INSTALL_BASE) {
+            echo "Base dir 'Ethna' exists and it's not ETHNA_INSTALL_BASE.\n";
+            exit(1);
+        }
+    }
+}
+
 /** テストケースがあるディレクトリ */
 $test_dir = ETHNA_INSTALL_BASE . '/test';
 
 /** include_pathの設定(このtest runnerがあるディレクトリを追加) */
-ini_set('include_path', realpath(ETHNA_INSTALL_BASE . '/class') . 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_INSTALL_BASE . '/Ethna.php';
+require_once 'Ethna/Ethna.php';
 
 /** SimpleTestのインクルード */
 require_once 'simpletest/unit_tester.php';
@@ -31,7 +47,7 @@ require_once $test_dir . '/Ethna_UnitTestBase.php';
 $test = &new GroupTest('Ethna All tests');
 
 // テストケースのファイルリストを取得
-require_once ETHNA_INSTALL_BASE . '/class/Ethna_Getopt.php';
+require_once 'Ethna/class/Ethna_Getopt.php';
 $opt = new Ethna_Getopt();
 $args = $opt->readPHPArgv();
 list($args, $opts) = $opt->getopt($args, '', array());
@@ -50,6 +66,10 @@ foreach ($file_list as $file) {
 // 結果をコマンドラインに出力
 $test->run(new TextDetailReporter());
 
+if ($symlink_filename !== null) {
+    unlink($symlink_filename);
+}
+
 //{{{ getFileList
 /**
  * getFileList