Added help to test runner

This commit is contained in:
Marcin Kurczewski 2014-05-16 18:55:52 +02:00
parent f20ed1d3d6
commit ee3f2ca9d3
3 changed files with 33 additions and 1 deletions

View file

@ -4,4 +4,5 @@ class SzurubooruTestOptions
public $cleanDatabase;
public $filter;
public $dbDriver;
public $help;
}

View file

@ -5,6 +5,12 @@ class SzurubooruTestRunner implements ITestRunner
{
$options = $this->getOptions();
if ($options->help)
{
$this->printHelp();
exit(0);
}
$this->resetEnvironment($options);
if ($options->cleanDatabase)
$this->cleanDatabase();
@ -36,12 +42,19 @@ class SzurubooruTestRunner implements ITestRunner
$testRunner->run();
}
private function printHelp()
{
readfile(__DIR__ . DIRECTORY_SEPARATOR . 'help.txt');
}
private function getOptions()
{
$options = getopt('cf:', ['clean', 'filter:', 'driver:']);
$options = getopt('cf:h', ['clean', 'filter:', 'driver:', 'help']);
$ret = new SzurubooruTestOptions;
$ret->help = (isset($options['h']) or isset($options['h']));
$ret->cleanDatabase = (isset($options['c']) or isset($options['clean']));
$ret->dbDriver = 'sqlite';

18
tests/help.txt Normal file
View file

@ -0,0 +1,18 @@
Usage: php run-all.php [OPTIONS]
Available options:
-c, --clean Clears the database. Used for upgrade testing.
-d, --driver DRIVER Sets database driver to DRIVER, where DRIVER can be
sqlite or mysql.
-f, --filter FILTER Runs only tests matching given FILTER.
-h, --help Shows this help.
Syntax of FILTER:
CLASS runs only tests from classes containing CLASS.
CLASS:: same as above.
::METHOD runs only tests from methods containing METHOD.
CLASS::METHOD combination of CLASS and ::METHOD filters.
Filters are case-insensitive.