- Improved the parser for the legacy args option

- New tests for the legacy args option string
- New Exception when no tests are executed
This commit is contained in:
Pablo Tejada 2016-11-08 21:22:37 -05:00
parent 11f087a239
commit 00035a7d81
3 changed files with 39 additions and 3 deletions

View file

@ -96,13 +96,13 @@ class PhpUnitOptions
$this->arguments = $rawArgs;
} else {
/*
* Try to parse old argument in a single string
* Try to parse old arguments in a single string
*/
preg_match_all('/--([a-z\-]+)\s?("?[^-]{2}[^"]*"?)?/', (string)$rawArgs, $argsMatch);
preg_match_all('@--([a-z\-]+)([\s=]+)?[\'"]?((?!--)[-\w/.,\\\]+)?[\'"]?@', (string)$rawArgs, $argsMatch);
if (!empty($argsMatch) && sizeof($argsMatch) > 2) {
foreach ($argsMatch[1] as $index => $argName) {
$this->addArgument($argName, $argsMatch[2][$index]);
$this->addArgument($argName, $argsMatch[3][$index]);
}
}
}

View file

@ -48,6 +48,9 @@ class PhpUnitResult
public function parse()
{
$rawResults = file_get_contents($this->outputFile);
if (empty($rawResults)) {
throw new \Exception('No test executed.');
}
if ($rawResults[0] == '{') {
$fixedJson = '[' . str_replace('}{', '},{', $rawResults) . ']';
$events = json_decode($fixedJson, true);

View file

@ -61,6 +61,39 @@ class PhpUnitOptionsTest extends \PHPUnit_Framework_TestCase
'coverage-html' => '/path/to/coverage1/',
),
),
array(
array(
'config' => array('tests/phpunit.xml'),
'args' => "--testsuite=unit --bootstrap=vendor/autoload.php",
),
array(
'testsuite' => 'unit',
'bootstrap' => 'vendor/autoload.php',
'configuration' => array('tests/phpunit.xml'),
),
),
array(
array(
'config' => array('tests/phpunit.xml'),
'args' => "--testsuite='unit' --bootstrap 'vendor/autoload.php'",
),
array(
'testsuite' => 'unit',
'bootstrap' => 'vendor/autoload.php',
'configuration' => array('tests/phpunit.xml'),
),
),
array(
array(
'config' => array('tests/phpunit.xml'),
'args' => '--testsuite="unit" --bootstrap "vendor/autoload.php"',
),
array(
'testsuite' => 'unit',
'bootstrap' => 'vendor/autoload.php',
'configuration' => array('tests/phpunit.xml'),
),
),
);
}