Example #1
0
 *  Ethna Handle Gateway
 *
 *  @author     Masaki Fujimoto <*****@*****.**>
 *  @license    http://www.opensource.org/licenses/bsd-license.php The BSD License
 *  @package    Ethna
 *  @version    $Id: 7f8f5b31c83b87ac69d9f6195ba27157efb2fe5f $
 */
while (ob_get_level()) {
    ob_end_clean();
}
$base = dirname(dirname(dirname(__FILE__)));
ini_set('include_path', $base . PATH_SEPARATOR . ini_get('include_path'));
require_once 'Ethna/Ethna.php';
require_once ETHNA_BASE . '/class/Getopt.php';
// fetch arguments
$opt = new Ethna_Getopt();
$arg_list = $opt->readPHPArgv();
if (Ethna::isError($arg_list)) {
    echo $arg_list->getMessage() . "\n";
    exit(2);
}
array_shift($arg_list);
// remove "ethna_handle.php"
$eh = new Ethna_Handle();
//  はじめの引数に - が含まれていればそれを分離する
//  含まれていた場合、それは -v|--version でなければならない
list($my_arg_list, $arg_list) = _Ethna_HandleGateway_SeparateArgList($arg_list);
$r = $opt->getopt($my_arg_list, "v", array("version"));
if (Ethna::isError($r)) {
    $id = 'help';
} else {
 /**
  * easy getopt :)
  *
  * @param   array   $lopts  long options
  * @return  array   list($opts, $args)
  * @access  protected
  */
 function &_getopt($lopts = array())
 {
     // create opts
     // ex: $lopts = array('foo', 'bar=');
     $lopts = to_array($lopts);
     $sopts = '';
     $opt_def = array();
     foreach ($lopts as $lopt) {
         if ($lopt[strlen($lopt) - 2] === '=') {
             $opt_def[$lopt[0]] = substr($lopt, 0, strlen($lopt) - 2);
             $sopts .= $lopt[0] . '::';
         } else {
             if ($lopt[strlen($lopt) - 1] === '=') {
                 $opt_def[$lopt[0]] = substr($lopt, 0, strlen($lopt) - 1);
                 $sopts .= $lopt[0] . ':';
             } else {
                 $opt_def[$lopt[0]] = $lopt;
                 $sopts .= $lopt[0];
             }
         }
     }
     // do getopt
     // ex: $sopts = 'fb:';
     $opt = new Ethna_Getopt();
     $opts_args = $opt->getopt($this->arg_list, $sopts, $lopts);
     if (Ethna::isError($opts_args)) {
         return $opts_args;
     }
     // parse opts
     // ex: "-ff --bar=baz" gets
     //      $opts = array('foo' => array(true, true),
     //                    'bar' => array('baz'));
     $opts = array();
     foreach ($opts_args[0] as $opt) {
         $opt[0] = $opt[0][0] === '-' ? $opt_def[$opt[0][2]] : $opt_def[$opt[0][0]];
         $opt[1] = $opt[1] === null ? true : $opt[1];
         if (isset($opts[$opt[0]]) === false) {
             $opts[$opt[0]] = array($opt[1]);
         } else {
             $opts[$opt[0]][] = $opt[1];
         }
     }
     $opts_args[0] = $opts;
     return $opts_args;
 }
Example #3
0
/** include_pathの設定(このtest runnerがあるディレクトリを追加) */
//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';
// simpletest を使っているため、E_DEPRECATED, E_STRICT は解除
error_reporting(error_reporting() ^ E_DEPRECATED ^ E_STRICT);
/** SimpleTestのインクルード */
require_once 'simpletest/unit_tester.php';
require_once 'simpletest/reporter.php';
require_once $test_dir . '/TextDetailReporter.php';
require_once $test_dir . '/UnitTestBase.php';
$test = new GroupTest('Ethna All tests');
// テストケースのファイルリストを取得
require_once 'Ethna/class/Getopt.php';
$opt = new Ethna_Getopt();
$args = $opt->readPHPArgv();
list($args, $opts) = $opt->getopt($args, '', array());
array_shift($opts);
if (count($opts) > 0) {
    $file_list = $opts;
} else {
    $file_list = getFileList($test_dir);
}
// テストケースを登録
foreach ($file_list as $file) {
    $test->addTestFile($file);
}
// 結果をコマンドラインに出力
$test->run(new TextDetailReporter());
if ($symlink_filename !== null && is_link($symlink_filename)) {
Example #4
0
 /**
  *  (experimental)
  *  @return array
  */
 private function _getPearOpt(&$cmd_obj, $cmd_str, $opt_array)
 {
     $short_args = $long_args = null;
     PEAR_Command::getGetOptArgs($cmd_str, $short_args, $long_args);
     $opt = new Ethna_Getopt();
     $opt_arg = $opt->getopt($opt_array, $short_args, $long_args);
     if (Ethna::isError($opt_arg)) {
         return array();
     }
     $opts = array();
     foreach ($opt_arg[0] as $tmp) {
         list($opt, $val) = $tmp;
         if ($val === null) {
             $val = true;
         }
         if (strlen($opt) == 1) {
             $cmd_opts = $cmd_obj->getOptions($cmd_str);
             foreach ($cmd_opts as $o => $d) {
                 if (isset($d['shortopt']) && $d['shortopt'] == $opt) {
                     $opts[$o] = $val;
                 }
             }
         } else {
             if (substr($opt, 0, 2) == '--') {
                 $opts[substr($opt, 2)] = $val;
             }
         }
     }
     return $opts;
 }
Example #5
0
if (extension_loaded('xdebug')) {
    ini_set('xdebug.scream', 0);
}

/** SimpleTestのインクルード */
require_once 'simpletest/unit_tester.php';
require_once 'simpletest/reporter.php';
require_once $test_dir . '/TextSimpleReporter.php';
require_once $test_dir . '/TextDetailReporter.php';
require_once $test_dir . '/UnitTestBase.php';

$test = new TestSuite('Ethna All tests');

// テストケースのファイルリストを取得
require_once 'Ethna/class/Getopt.php';
$opt = new Ethna_Getopt();
$args = $opt->readPHPArgv();
array_shift($args);
$opt_ret = $opt->getopt($args, "", array('coverage', 'verbose'));
if (Ethna::isError($opt_ret)) {
    echo $opt_ret->getMessage(), PHP_EOL;
    exit(255);
}
list($args, $opts) = $opt_ret;

$coverage = false;
$verbose = false;
foreach ($args as $arg) {
    switch ($arg[0]) {
    case '--coverage':
        $coverage = true;