OSDN Git Service

*** empty log message ***
[ethna/ethna.git] / bin / ethna_run_test.php
1 <?php
2 /**
3  *  ethna_run_test.php
4  *
5  *  Ethna Test Runner
6  *
7  *  @author     Kazuhiro Hosoi <hosoi@gree.co.jp>
8  *  @license    http://www.opensource.org/licenses/bsd-license.php The BSD License
9  *  @package    Ethna
10  *  @version    $Id$
11  */
12
13 /** ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥Ù¡¼¥¹¥Ç¥£¥ì¥¯¥È¥ê */
14 define('BASE', dirname(dirname(__FILE__)));
15
16 // include_path¤ÎÀßÄê(¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥Ç¥£¥ì¥¯¥È¥ê¤òÄɲÃ)
17 $app = BASE . "/app";
18 $lib = BASE . "/lib";
19
20 /** Ethna´ØÏ¢¥¯¥é¥¹¤Î¥¤¥ó¥¯¥ë¡¼¥É */
21 require_once('Ethna/Ethna.php');
22
23 /** SimpleTest¤Î¥¤¥ó¥¯¥ë¡¼¥É */
24 require_once('simpletest/unit_tester.php');
25 require_once('simpletest/reporter.php');
26 require_once 'Ethna/test/TextDetailReporter.php';
27
28 /** ¥Æ¥¹¥È¥±¡¼¥¹¤¬¤¢¤ë¥Ç¥£¥ì¥¯¥È¥ê */
29 $test_dir = ETHNA_BASE . '/test';
30
31 $test = &new GroupTest('Ethna All tests');
32
33 // ¥Æ¥¹¥È¥±¡¼¥¹¤Î¥Õ¥¡¥¤¥ë¥ê¥¹¥È¤ò¼èÆÀ
34 $file_list = getFileList($test_dir);
35
36 // ¥Æ¥¹¥È¥±¡¼¥¹¤òÅÐÏ¿
37 foreach ($file_list as $file) {
38     $test->addTestFile($file);
39 }
40
41 // ·ë²Ì¤ò¥³¥Þ¥ó¥É¥é¥¤¥ó¤Ë½ÐÎÏ
42 //$test->run(new TextReporter());
43 $test->run(new TextDetailReporter());
44
45 //{{{ getFileList
46 /**
47  * getFileList
48  *
49  * @param string $dir_path
50  */
51 function getFileList($dir_path)
52 {
53     $file_list = array();
54
55     $dir = opendir($dir_path);
56
57     if ($dir == false) {
58         return false;
59     }
60
61     while($file_path = readdir($dir)) {
62
63         $full_path = $dir_path . '/'. $file_path;
64
65         if (is_file($full_path)){
66
67             // ¥Æ¥¹¥È¥±¡¼¥¹¤Î¥Õ¥¡¥¤¥ë¤Î¤ßÆɤ߹þ¤à
68             if (preg_match('/^(Ethna_)(.*)(_Test.php)$/',$file_path,$matches)) {
69                 $file_list[] = $full_path;
70             }
71
72         // ¥µ¥Ö¥Ç¥£¥ì¥¯¥È¥ê¤¬¤¢¤ë¾ì¹ç¤Ï¡¤ºÆµ¢Åª¤ËÆɤ߹þ¤à¡¥
73         // "."¤Ç»Ï¤Þ¤ë¥Ç¥£¥ì¥¯¥È¥ê¤ÏÆɤ߹þ¤Þ¤Ê¤¤.
74         } else if (is_dir($full_path) && !preg_match('/^\./',$file_path,$matches)) {
75
76             $file_list = array_merge($file_list,getFileList($full_path));
77         }
78     }
79
80     closedir($dir);
81     return $file_list;
82 }
83 //}}}
84 ?>