| [ Index ] |
PHP Cross Reference of DokuWiki |
[Summary view] [Print] [Text view]
1 #!/usr/bin/php -q 2 <?php 3 ini_set('memory_limit','128M'); 4 5 if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../').'/'); 6 7 require_once 'lib/testmanager.php'; 8 TestManager::setup(); 9 10 function usage() { 11 $usage = <<<EOD 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 17 exit code. 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 25 details to SEP 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) 29 30 EOD; 31 echo $usage; 32 exit(0); 33 } 34 35 /* default test options */ 36 $opt_separator = '->'; 37 $opt_caselist = FALSE; 38 $opt_grouplist = FALSE; 39 $opt_caseid = FALSE; 40 $opt_caseurl = FALSE; 41 $opt_groupfile = FALSE; 42 $opt_url = FALSE; 43 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); 51 exit(1); 52 } 53 54 foreach ($OPTS->options as $key => $val) { 55 switch ($key) { 56 case 'c': 57 case 'case': 58 $opt_caseid = $val; 59 break; 60 case 'h': 61 case 'help': 62 usage(); 63 break; 64 case 'f': 65 case 'caseurl': 66 $opt_caseurl = $val; 67 break; 68 case 'g': 69 case 'group': 70 $opt_groupfile = $val; 71 break; 72 case 'i': 73 case 'caselist': 74 $opt_caselist = TRUE; 75 break; 76 case 'l': 77 case 'grouplist': 78 $opt_grouplist = TRUE; 79 break; 80 case 's': 81 case 'separator': 82 $opt_separator = $val; 83 break; 84 case 'p': 85 case 'path': 86 if (file_exists($val)) { 87 define('SIMPLE_TEST', $val); 88 } 89 break; 90 case 'u': 91 case '--url': 92 $opt_url = $val; 93 break; 94 } 95 } 96 97 if ( ! $opt_url ) { 98 if ( !defined('REMOTE_TEST_URL') ) { 99 fwrite( STDERR, "No test URL defined. Either modify tests.ini or use -u option\n"); 100 exit(1); 101 } else { 102 $opt_url = REMOTE_TEST_URL; 103 } 104 } 105 106 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"); 110 } else { 111 fwrite( STDERR, "Where's Simple Test ?!? SIMPLE_TEST not even defined!\n"); 112 } 113 exit(1); 114 } 115 116 require_once 'lib/cli_reporter.php'; 117 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"); 124 } 125 } 126 127 /* list test cases */ 128 if ($opt_caselist) { 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"); 133 } 134 } 135 136 /* exit if we've displayed a list */ 137 if ( $opt_grouplist || $opt_caselist ) { 138 exit(0); 139 } 140 141 /* run a test case given it's URL */ 142 if ($opt_caseurl) { 143 RemoteTestManager::runTestUrl($opt_caseurl, new CLIReporter($opt_separator), $opt_url); 144 exit(0); 145 } 146 147 /* run a test case by id*/ 148 if ($opt_caseid) { 149 RemoteTestManager::runTestCase($opt_caseid, new CLIReporter($opt_separator), $opt_url); 150 exit(0); 151 } 152 153 /* run a grouptest */ 154 if ($opt_groupfile) { 155 RemoteTestManager::runGroupTest( 156 $opt_groupfile, new CLIReporter($opt_separator), $opt_url 157 ); 158 exit(0); 159 } 160 /* run all tests */ 161 RemoteTestManager::runAllTests(new CLIReporter($opt_separator), $opt_url); 162 exit(0); 163 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Fri Nov 21 01:30:02 2008 | Cross-referenced by PHPXref 0.7 |