mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
performance improvements for code coverage analysis
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7603 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
93c5b68a93
commit
35a2b466de
1 changed files with 18 additions and 14 deletions
|
@ -216,8 +216,8 @@ class CodeCoverageManager {
|
||||||
|
|
||||||
foreach ($testObjectFile as $num => $line) {
|
foreach ($testObjectFile as $num => $line) {
|
||||||
$num++;
|
$num++;
|
||||||
$foundByManualFinder = array_key_exists($num, $execCodeLines) && trim($execCodeLines[$num]) != '';
|
$foundByManualFinder = isset($execCodeLines[$num]) && trim($execCodeLines[$num]) != '';
|
||||||
$foundByXdebug = array_key_exists($num, $coverageData) && $coverageData[$num] !== -2;
|
$foundByXdebug = isset($coverageData[$num]) && $coverageData[$num] !== -2;
|
||||||
|
|
||||||
// xdebug does not find all executable lines (zend engine fault)
|
// xdebug does not find all executable lines (zend engine fault)
|
||||||
if ($foundByManualFinder && $foundByXdebug) {
|
if ($foundByManualFinder && $foundByXdebug) {
|
||||||
|
@ -250,11 +250,11 @@ class CodeCoverageManager {
|
||||||
$lines = array();
|
$lines = array();
|
||||||
|
|
||||||
for ($i = 1; $i < $total + 1; $i++) {
|
for ($i = 1; $i < $total + 1; $i++) {
|
||||||
$foundByManualFinder = array_key_exists($i, $execCodeLines) && trim($execCodeLines[$i]) != '';
|
$foundByManualFinder = isset($execCodeLines[$i]) && trim($execCodeLines[$i]) != '';
|
||||||
$foundByXdebug = array_key_exists($i, $coverageData);
|
$foundByXdebug = isset($coverageData[$i]);
|
||||||
|
|
||||||
if (!$foundByManualFinder || !$foundByXdebug || $coverageData[$i] === -2) {
|
if (!$foundByManualFinder || !$foundByXdebug || $coverageData[$i] === -2) {
|
||||||
if (array_key_exists($i, $lines)) {
|
if (isset($lines[$i])) {
|
||||||
$lines[$i] = 'ignored ' . $lines[$i];
|
$lines[$i] = 'ignored ' . $lines[$i];
|
||||||
} else {
|
} else {
|
||||||
$lines[$i] = 'ignored';
|
$lines[$i] = 'ignored';
|
||||||
|
@ -263,7 +263,7 @@ class CodeCoverageManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($coverageData[$i] !== -1) {
|
if ($coverageData[$i] !== -1) {
|
||||||
if (array_key_exists($i, $lines)) {
|
if (isset($lines[$i])) {
|
||||||
$lines[$i] = 'covered ' . $lines[$i];
|
$lines[$i] = 'covered ' . $lines[$i];
|
||||||
} else {
|
} else {
|
||||||
$lines[$i] = 'covered';
|
$lines[$i] = 'covered';
|
||||||
|
@ -276,7 +276,7 @@ class CodeCoverageManager {
|
||||||
for ($j = 1; $j <= $numContextLines; $j++) {
|
for ($j = 1; $j <= $numContextLines; $j++) {
|
||||||
$key = $i - $j;
|
$key = $i - $j;
|
||||||
|
|
||||||
if ($key > 0 && array_key_exists($key, $lines)) {
|
if ($key > 0 && isset($lines[$key])) {
|
||||||
if (strpos($lines[$key], 'end') !== false) {
|
if (strpos($lines[$key], 'end') !== false) {
|
||||||
$foundEndBlockInContextSearch = true;
|
$foundEndBlockInContextSearch = true;
|
||||||
if ($j < $numContextLines) {
|
if ($j < $numContextLines) {
|
||||||
|
@ -317,17 +317,19 @@ class CodeCoverageManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// find the last "uncovered" or "show"n line and "end" its block
|
// find the last "uncovered" or "show"n line and "end" its block
|
||||||
$lastShownLine = $manager->__array_strpos($lines, 'show', true);
|
$lastShownLine = $manager->__array_strpos($lines, 'show', true);
|
||||||
|
|
||||||
if (isset($lines[$lastShownLine])) {
|
if (isset($lines[$lastShownLine])) {
|
||||||
$lines[$lastShownLine] .= ' end';
|
$lines[$lastShownLine] .= ' end';
|
||||||
}
|
}
|
||||||
|
|
||||||
// give the first start line another class so we can control the top padding of the entire results
|
// give the first start line another class so we can control the top padding of the entire results
|
||||||
$firstShownLine = $manager->__array_strpos($lines, 'show');
|
$firstShownLine = $manager->__array_strpos($lines, 'show');
|
||||||
if (isset($lines[$firstShownLine])) {
|
if (isset($lines[$firstShownLine])) {
|
||||||
$lines[$firstShownLine] .= ' realstart';
|
$lines[$firstShownLine] .= ' realstart';
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the output
|
// get the output
|
||||||
$lineCount = $coveredCount = 0;
|
$lineCount = $coveredCount = 0;
|
||||||
$report = '';
|
$report = '';
|
||||||
|
@ -366,8 +368,8 @@ class CodeCoverageManager {
|
||||||
|
|
||||||
foreach ($testObjectFile as $num => $line) {
|
foreach ($testObjectFile as $num => $line) {
|
||||||
$num++;
|
$num++;
|
||||||
$foundByManualFinder = array_key_exists($num, $execCodeLines) && trim($execCodeLines[$num]) != '';
|
$foundByManualFinder = isset($execCodeLines[$num]) && trim($execCodeLines[$num]) != '';
|
||||||
$foundByXdebug = array_key_exists($num, $coverageData) && $coverageData[$num] !== -2;
|
$foundByXdebug = isset($coverageData[$num]) && $coverageData[$num] !== -2;
|
||||||
|
|
||||||
if ($foundByManualFinder && $foundByXdebug) {
|
if ($foundByManualFinder && $foundByXdebug) {
|
||||||
$lineCount++;
|
$lineCount++;
|
||||||
|
@ -399,8 +401,8 @@ class CodeCoverageManager {
|
||||||
|
|
||||||
foreach ($testObjectFile as $num => $line) {
|
foreach ($testObjectFile as $num => $line) {
|
||||||
$num++;
|
$num++;
|
||||||
$foundByManualFinder = array_key_exists($num, $execCodeLines[$objFilename]) && trim($execCodeLines[$objFilename][$num]) != '';
|
$foundByManualFinder = isset($execCodeLines[$objFilename][$num]) && trim($execCodeLines[$objFilename][$num]) != '';
|
||||||
$foundByXdebug = array_key_exists($num, $coverageData[$objFilename]) && $coverageData[$objFilename][$num] !== -2;
|
$foundByXdebug = isset($coverageData[$objFilename][$num]) && $coverageData[$objFilename][$num] !== -2;
|
||||||
|
|
||||||
if ($foundByManualFinder && $foundByXdebug) {
|
if ($foundByManualFinder && $foundByXdebug) {
|
||||||
$class = 'uncovered';
|
$class = 'uncovered';
|
||||||
|
@ -438,8 +440,8 @@ class CodeCoverageManager {
|
||||||
|
|
||||||
foreach ($testObjectFile as $num => $line) {
|
foreach ($testObjectFile as $num => $line) {
|
||||||
$num++;
|
$num++;
|
||||||
$foundByManualFinder = array_key_exists($num, $execCodeLines[$objFilename]) && trim($execCodeLines[$objFilename][$num]) != '';
|
$foundByManualFinder = isset($execCodeLines[$objFilename][$num]) && trim($execCodeLines[$objFilename][$num]) != '';
|
||||||
$foundByXdebug = array_key_exists($num, $coverageData[$objFilename]) && $coverageData[$objFilename][$num] !== -2;
|
$foundByXdebug = isset($coverageData[$objFilename][$num]) && $coverageData[$objFilename][$num] !== -2;
|
||||||
|
|
||||||
if ($foundByManualFinder && $foundByXdebug) {
|
if ($foundByManualFinder && $foundByXdebug) {
|
||||||
$lineCount++;
|
$lineCount++;
|
||||||
|
@ -531,6 +533,7 @@ class CodeCoverageManager {
|
||||||
trigger_error('This group file does not exist!');
|
trigger_error('This group file does not exist!');
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = array();
|
$result = array();
|
||||||
$groupContent = file_get_contents($path);
|
$groupContent = file_get_contents($path);
|
||||||
$ds = '\s*\.\s*DS\s*\.\s*';
|
$ds = '\s*\.\s*DS\s*\.\s*';
|
||||||
|
@ -544,6 +547,7 @@ class CodeCoverageManager {
|
||||||
'/\s*APP_TEST_CASES\s*/',
|
'/\s*APP_TEST_CASES\s*/',
|
||||||
'/\s*CORE_TEST_CASES\s*/',
|
'/\s*CORE_TEST_CASES\s*/',
|
||||||
);
|
);
|
||||||
|
|
||||||
$replacements = array(DS, '', '');
|
$replacements = array(DS, '', '');
|
||||||
$file = preg_replace($patterns, $replacements, $file);
|
$file = preg_replace($patterns, $replacements, $file);
|
||||||
$file = str_replace("'", '', $file);
|
$file = str_replace("'", '', $file);
|
||||||
|
|
Loading…
Reference in a new issue