- 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 2017-01-05 18:09:00 +07:00 committed by Dmitry Khomutov
commit 8078d0befe
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);