mirror of
https://github.com/pestphp/pest.git
synced 2026-06-05 10:52:14 +02:00
wqdqwd
This commit is contained in:
@ -149,7 +149,10 @@ final class Recorder
|
|||||||
if ($this->driver === 'pcov') {
|
if ($this->driver === 'pcov') {
|
||||||
\pcov\stop();
|
\pcov\stop();
|
||||||
/** @var array<string, mixed> $data */
|
/** @var array<string, mixed> $data */
|
||||||
$data = \pcov\collect(\pcov\all);
|
$filesToCollectCoverageFor = \pcov\waiting();
|
||||||
|
|
||||||
|
/** @var array<string, mixed> $data */
|
||||||
|
$data = \pcov\collect(\pcov\inclusive, $filesToCollectCoverageFor);
|
||||||
|
|
||||||
// pcov returns every executable line in every file it
|
// pcov returns every executable line in every file it
|
||||||
// tracked: positive values for executed lines, `-1` for
|
// tracked: positive values for executed lines, `-1` for
|
||||||
@ -160,7 +163,9 @@ final class Recorder
|
|||||||
// at framework boot. Including those attributes every
|
// at framework boot. Including those attributes every
|
||||||
// globally-bootstrapped class to whichever test triggered
|
// globally-bootstrapped class to whichever test triggered
|
||||||
// the boot, blowing up the affected set on edits to those
|
// the boot, blowing up the affected set on edits to those
|
||||||
// files.
|
// files. We further narrow to phpunit.xml's `<source>`
|
||||||
|
// scope so files outside the configured include set never
|
||||||
|
// become edges.
|
||||||
$coveredFiles = self::filesWithExecutedLines($data);
|
$coveredFiles = self::filesWithExecutedLines($data);
|
||||||
} else {
|
} else {
|
||||||
/** @var array<string, mixed> $data */
|
/** @var array<string, mixed> $data */
|
||||||
@ -656,11 +661,16 @@ final class Recorder
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters pcov's `file => line => executionCount` map to the files
|
* Filters pcov's `file => line => executionCount` map to files that
|
||||||
* that actually had at least one executed line. pcov reports `-1`
|
* actually had executed code AND live inside the configured source
|
||||||
* for "executable but not run" and a positive count for executed
|
* scope (`phpunit.xml`'s `<source>` block, or the project root with
|
||||||
* lines; a file with no positives was loaded but contributed no
|
* vendor/etc. excluded as fallback).
|
||||||
* executed code to this test.
|
*
|
||||||
|
* pcov reports `-1` for "executable but not run" and a positive
|
||||||
|
* count for executed lines. We also skip files where the *only*
|
||||||
|
* positive line is the implicit `ZEND_RETURN` at end-of-file: pcov
|
||||||
|
* surfaces that as a one-line artifact for files that were merely
|
||||||
|
* included (autoloaded) without any real code running.
|
||||||
*
|
*
|
||||||
* @param array<string, mixed> $data
|
* @param array<string, mixed> $data
|
||||||
* @return list<string>
|
* @return list<string>
|
||||||
@ -674,13 +684,25 @@ final class Recorder
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($lines as $count) {
|
$covered = [];
|
||||||
|
foreach ($lines as $line => $count) {
|
||||||
if (is_int($count) && $count > 0) {
|
if (is_int($count) && $count > 0) {
|
||||||
$out[] = $file;
|
$covered[] = $line;
|
||||||
|
|
||||||
continue 2;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($covered === []) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Skip files where the only "executed" line is the implicit
|
||||||
|
// ZEND_RETURN at end-of-file (pcov artifact from being included
|
||||||
|
// but never actually run).
|
||||||
|
if (count($covered) === 1 && max($covered) === max(array_keys($lines))) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$out[] = $file;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $out;
|
return $out;
|
||||||
|
|||||||
Reference in New Issue
Block a user