diff options
Diffstat (limited to 'test/runtests.php')
-rwxr-xr-x | test/runtests.php | 51 |
1 files changed, 35 insertions, 16 deletions
diff --git a/test/runtests.php b/test/runtests.php index 5e9bea983..ba9bc4b1d 100755 --- a/test/runtests.php +++ b/test/runtests.php @@ -1,11 +1,6 @@ #!/usr/bin/php -q <?php -/** -* TODO: This needs migrating to inc/cli_opts.php -*/ - ini_set('memory_limit','128M'); -/* wact common */ if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../').'/'); define('TEST_ROOT', dirname(__FILE__)); define('TMPL_FILESCHEME_PATH', TEST_ROOT . '/filescheme/'); @@ -21,10 +16,12 @@ Run the Dokuwiki unit tests. If ALL of the test cases pass a count of total passes is printed on STDOUT. If ANY of the test cases fail (or raise errors) details are printed on STDERR and this script returns a non-zero exit code. - -f --file=NAME specify a test case file + -c --case=NAME specify a test case by it's ID (see -i for list) + -f --file=NAME specify a test case file (full or relative path) -g --group=NAME specify a grouptest. If no grouptest is specified, all test cases will be run. - -l --list list available grouptests/test case files + -i --caselist list individual test cases by their ID + -l --grouplist list available grouptests -s, --separator=SEP set the character(s) used to separate fail details to SEP -p, --path path to SimpleTest installation @@ -37,15 +34,16 @@ EOD; /* test options */ $opt_separator = '->'; -$opt_list = FALSE; +$opt_caselist = FALSE; +$opt_grouplist = FALSE; +$opt_caseid = FALSE; $opt_casefile = FALSE; $opt_groupfile = FALSE; -/* only allow cmd line options if PEAR Console_Getopt is available */ include_once(DOKU_INC.'inc/cliopts.php'); -$short_opts = "f:g:hls:p:"; -$long_opts = array("help", "file=", "group=", "list", "separator=", "path="); +$short_opts = "c:f:g:hils:p:"; +$long_opts = array("case=","caselist","help", "file=", "group=", "grouplist", "separator=", "path="); $OPTS = Doku_Cli_Opts::getOptions(__FILE__,$short_opts,$long_opts); if ( $OPTS->isError() ) { fwrite( STDERR, $OPTS->getMessage() . "\n"); @@ -55,6 +53,10 @@ if ( $OPTS->isError() ) { foreach ($OPTS->options as $key => $val) { switch ($key) { + case 'c': + case 'case': + $opt_caseid = $val; + break; case 'h': case 'help': usage(); @@ -67,9 +69,13 @@ foreach ($OPTS->options as $key => $val) { case 'group': $opt_groupfile = $val; break; + case 'i': + case 'caselist': + $opt_caselist = TRUE; + break; case 'l': - case 'list': - $opt_list = TRUE; + case 'grouplist': + $opt_grouplist = TRUE; break; case 's': case 'separator': @@ -84,7 +90,6 @@ foreach ($OPTS->options as $key => $val) { } } - if (!@include_once SIMPLE_TEST . 'reporter.php') { die("Where's Simple Test ?!? Not at ".SIMPLE_TEST); } @@ -92,14 +97,28 @@ if (!@include_once SIMPLE_TEST . 'reporter.php') { require_once 'lib/cli_reporter.php'; /* list grouptests */ -if ($opt_list) { +if ($opt_grouplist) { echo CLITestManager::getGroupTestList(TEST_GROUPS); +} + +/* list test cases */ +if ($opt_caselist) { echo CLITestManager::getTestCaseList(TEST_CASES); +} + +/* exit if we've displayed a list */ +if ( $opt_grouplist || $opt_caselist ) { exit(0); } + /* run a test case */ if ($opt_casefile) { - TestManager::runTestCase($opt_casefile, new CLIReporter($opt_separator)); + TestManager::runTestFile($opt_casefile, new CLIReporter($opt_separator)); + exit(0); +} +/* run a test case by id*/ +if ($opt_caseid) { + TestManager::runTestCase($opt_caseid, TEST_CASES, new CLIReporter($opt_separator)); exit(0); } /* run a grouptest */ |