3 ini_set('memory_limit','128M');
5 if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__
).'/../').'/');
7 require_once 'lib/testmanager.php';
12 Usage: ./remotetests.php [OPTION]...
13 Run the Dokuwiki unit tests remotely executing tests over HTTP and delivering
14 results to the command line. If ALL of the test cases pass a count of
15 total passes is printed on STDOUT. If ANY of the test cases fail (or raise
16 errors) details are printed on STDERR and this script returns a non-zero
18 -c --case=NAME specify a test case by it's ID (see -i for list)
19 -f --caseurl=NAME specify a test case file (full or relative path)
20 -g --group=NAME specify a grouptest. If no grouptest is
21 specified, all test cases will be run.
22 -i --caselist list individual test cases by their ID
23 -l --grouplist list available grouptests
24 -s, --separator=SEP set the character(s) used to separate fail
26 -p, --path path to SimpleTest installation
27 -h, --help display this help and exit
28 -u --url=TEST_URL specify remote server test url (w. index.php)
35 /* default test options */
36 $opt_separator = '->';
37 $opt_caselist = FALSE;
38 $opt_grouplist = FALSE;
41 $opt_groupfile = FALSE;
44 include_once(DOKU_INC
.'inc/cliopts.php');
45 $short_opts = "c:f:g:hils:p:u:";
46 $long_opts = array("case=","caselist","help", "caseurl=", "group=", "grouplist", "separator=", "path=","url=");
47 $OPTS = Doku_Cli_Opts
::getOptions(__FILE__
,$short_opts,$long_opts);
48 if ( $OPTS->isError() ) {
49 fwrite( STDERR
, $OPTS->getMessage() . "\n");
50 usage($available_grouptests);
54 foreach ($OPTS->options
as $key => $val) {
70 $opt_groupfile = $val;
78 $opt_grouplist = TRUE;
82 $opt_separator = $val;
86 if (file_exists($val)) {
87 define('SIMPLE_TEST', $val);
98 if ( !defined('REMOTE_TEST_URL') ) {
99 fwrite( STDERR
, "No test URL defined. Either modify tests.ini or use -u option\n");
102 $opt_url = REMOTE_TEST_URL
;
107 if (!@include_once SIMPLE_TEST
. 'reporter.php') {
108 if ( defined(SIMPLE_TEST
) ) {
109 fwrite( STDERR
, "Where's Simple Test ?!? Not at ".SIMPLE_TEST
." \n");
111 fwrite( STDERR
, "Where's Simple Test ?!? SIMPLE_TEST not even defined!\n");
116 require_once 'lib/cli_reporter.php';
118 /* list grouptests */
119 if ($opt_grouplist) {
120 $groups = RemoteTestManager
::getGroupTestList($opt_url);
121 fwrite( STDOUT
, "Available grouptests:\n");
122 foreach ( array_keys($groups) as $group ) {
123 fwrite( STDOUT
, $group."\n");
127 /* list test cases */
129 $cases = RemoteTestManager
::getTestCaseList($opt_url);
130 fwrite( STDOUT
, "Available tests tests:\n");
131 foreach ( array_keys($cases) as $case ) {
132 fwrite( STDOUT
, $case."\n");
136 /* exit if we've displayed a list */
137 if ( $opt_grouplist ||
$opt_caselist ) {
141 /* run a test case given it's URL */
143 RemoteTestManager
::runTestUrl($opt_caseurl, new CLIReporter($opt_separator), $opt_url);
147 /* run a test case by id*/
149 RemoteTestManager
::runTestCase($opt_caseid, new CLIReporter($opt_separator), $opt_url);
153 /* run a grouptest */
154 if ($opt_groupfile) {
155 RemoteTestManager
::runGroupTest(
156 $opt_groupfile, new CLIReporter($opt_separator), $opt_url
161 RemoteTestManager
::runAllTests(new CLIReporter($opt_separator), $opt_url);