Added help to test runner
This commit is contained in:
parent
f20ed1d3d6
commit
ee3f2ca9d3
3 changed files with 33 additions and 1 deletions
|
@ -4,4 +4,5 @@ class SzurubooruTestOptions
|
|||
public $cleanDatabase;
|
||||
public $filter;
|
||||
public $dbDriver;
|
||||
public $help;
|
||||
}
|
||||
|
|
|
@ -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
18
tests/help.txt
Normal 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.
|
Loading…
Reference in a new issue