OSDN Git Service

retab
[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 include_once('Ethna/Ethna.php');
22
23 /** SimpleTest¤Î¥¤¥ó¥¯¥ë¡¼¥É */
24 include_once('simpletest/unit_tester.php');
25 include_once('simpletest/reporter.php');
26
27 /** ¥Æ¥¹¥È¥±¡¼¥¹¤¬¤¢¤ë¥Ç¥£¥ì¥¯¥È¥ê */
28 $test_dir = ETHNA_BASE . '/test';
29
30 $test = &new GroupTest('Ethna All tests');
31
32 // ¥Æ¥¹¥È¥±¡¼¥¹¤Î¥Õ¥¡¥¤¥ë¥ê¥¹¥È¤ò¼èÆÀ
33 $file_list = getFileList($test_dir);
34
35 // ¥Æ¥¹¥È¥±¡¼¥¹¤òÅÐÏ¿
36 foreach ($file_list as $file) {
37     $test->addTestFile($file);
38 }
39
40 // ·ë²Ì¤ò¥³¥Þ¥ó¥É¥é¥¤¥ó¤Ë½ÐÎÏ
41 $test->run(new TextReporter());
42
43 /**
44  * getFileList
45  *
46  * @param string $dir_path
47  */
48 function getFileList($dir_path)
49 {
50     $file_list = array();
51
52     $dir = opendir($dir_path);
53
54     if ($dir == false) {
55         return false;
56     }
57
58     while($file_path = readdir($dir)) {
59
60         $full_path = $dir_path . '/'. $file_path;
61
62         if (is_file($full_path)){
63
64             // ¥Æ¥¹¥È¥±¡¼¥¹¤Î¥Õ¥¡¥¤¥ë¤Î¤ßÆɤ߹þ¤à
65             if (preg_match('/^(Ethna_)(.*)(_Test.php)$/',$file_path,$matches)) {
66                 $file_list[] = $full_path;
67             }
68
69         // ¥µ¥Ö¥Ç¥£¥ì¥¯¥È¥ê¤¬¤¢¤ë¾ì¹ç¤Ï¡¤ºÆµ¢Åª¤ËÆɤ߹þ¤à¡¥
70         // "."¤Ç»Ï¤Þ¤ë¥Ç¥£¥ì¥¯¥È¥ê¤ÏÆɤ߹þ¤Þ¤Ê¤¤.
71         } else if (is_dir($full_path) && !preg_match('/^\./',$file_path,$matches)) {
72
73             $file_list = array_merge($file_list,getFileList($full_path));
74         }
75     }
76
77     closedir($dir);
78     return $file_list;
79 }
80 ?>