summaryrefslogtreecommitdiff
path: root/_test/runtests.php
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2005-10-15 13:45:45 +0200
committerAndreas Gohr <andi@splitbrain.org>2005-10-15 13:45:45 +0200
commitb73cc7dccaa01778de20ade004e0c3bde2e2e36a (patch)
treea082fedea2f4a7e99b5cc6352c35e9b192b145ec /_test/runtests.php
parent5e35ae2a19fba9e79a1b71d951d7f322b864c001 (diff)
downloadrpg-b73cc7dccaa01778de20ade004e0c3bde2e2e36a.tar.gz
rpg-b73cc7dccaa01778de20ade004e0c3bde2e2e36a.tar.bz2
renamed test directory
darcs-hash:20051015114545-7ad00-561552ce7e519d81146b5cb2d28203aee7c6d2ad.gz
Diffstat (limited to '_test/runtests.php')
-rwxr-xr-x_test/runtests.php133
1 files changed, 133 insertions, 0 deletions
diff --git a/_test/runtests.php b/_test/runtests.php
new file mode 100755
index 000000000..ba9bc4b1d
--- /dev/null
+++ b/_test/runtests.php
@@ -0,0 +1,133 @@
+#!/usr/bin/php -q
+<?php
+ini_set('memory_limit','128M');
+if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../').'/');
+define('TEST_ROOT', dirname(__FILE__));
+define('TMPL_FILESCHEME_PATH', TEST_ROOT . '/filescheme/');
+error_reporting(E_ALL);
+
+require_once 'lib/testmanager.php';
+TestManager::setup();
+
+function usage() {
+ $usage = <<<EOD
+Usage: ./runtests.php [OPTION]...
+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.
+ -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.
+ -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
+ -h, --help display this help and exit
+
+EOD;
+ echo $usage;
+ exit(0);
+}
+
+/* test options */
+$opt_separator = '->';
+$opt_caselist = FALSE;
+$opt_grouplist = FALSE;
+$opt_caseid = FALSE;
+$opt_casefile = FALSE;
+$opt_groupfile = FALSE;
+
+include_once(DOKU_INC.'inc/cliopts.php');
+
+$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");
+ usage($available_grouptests);
+ exit(1);
+}
+
+foreach ($OPTS->options as $key => $val) {
+ switch ($key) {
+ case 'c':
+ case 'case':
+ $opt_caseid = $val;
+ break;
+ case 'h':
+ case 'help':
+ usage();
+ break;
+ case 'f':
+ case 'file':
+ $opt_casefile = $val;
+ break;
+ case 'g':
+ case 'group':
+ $opt_groupfile = $val;
+ break;
+ case 'i':
+ case 'caselist':
+ $opt_caselist = TRUE;
+ break;
+ case 'l':
+ case 'grouplist':
+ $opt_grouplist = TRUE;
+ break;
+ case 's':
+ case 'separator':
+ $opt_separator = $val;
+ break;
+ case 'p':
+ case 'path':
+ if (file_exists($val)) {
+ define('SIMPLE_TEST', $val);
+ }
+ break;
+ }
+}
+
+if (!@include_once SIMPLE_TEST . 'reporter.php') {
+ die("Where's Simple Test ?!? Not at ".SIMPLE_TEST);
+}
+
+require_once 'lib/cli_reporter.php';
+
+/* list grouptests */
+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::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 */
+if ($opt_groupfile) {
+ TestManager::runGroupTest($opt_groupfile, TEST_GROUPS,
+ new CLIReporter($opt_separator));
+ exit(0);
+}
+/* run all tests */
+TestManager::runAllTests(new CLIReporter($opt_separator));
+exit(0);
+?>