Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/Plugins/Tia/Recorder.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ public function activate(): void
{
$this->active = true;
$this->captureCoverage = true;

if ($this->driverAvailable() && $this->driver === 'xdebug') {
\xdebug_set_filter(
XDEBUG_FILTER_CODE_COVERAGE,
XDEBUG_PATH_EXCLUDE,
SourceScope::noisePaths(TestSuite::getInstance()->rootPath),
);
}
}

public function activateLinkTracking(): void
Expand Down
15 changes: 15 additions & 0 deletions src/Plugins/Tia/SourceScope.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,21 @@ public static function testPaths(): array
return array_values(array_unique($out));
}

/**
* @return list<string> Absolute directory prefixes, each ending in a separator, that hold no project source.
*/
public static function noisePaths(string $projectRoot): array
{
$out = [];

foreach ([...self::TOP_LEVEL_NOISE, ...self::NESTED_NOISE] as $relative) {
$abs = $projectRoot.DIRECTORY_SEPARATOR.str_replace('/', DIRECTORY_SEPARATOR, $relative);
$out[] = self::normalise(@realpath($abs) ?: $abs).DIRECTORY_SEPARATOR;
}

return array_values(array_unique($out));
}

public function contains(string $absoluteFile): bool
{
if (isset($this->containsCache[$absoluteFile])) {
Expand Down
6 changes: 5 additions & 1 deletion tests/.snapshots/success.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1937,6 +1937,10 @@
✓ it records assertions against the same per-dataset key
✓ it leaves a test without a dataset keyed by class and method

PASS Tests\Unit\Plugins\Tia\SourceScope
✓ noisePaths() → it lists the directories that hold no project source
✓ noisePaths() → it ends every path with a separator so a sibling directory cannot match it

PASS Tests\Unit\Plugins\Tia\Storage
✓ it uses a project-relative configured directory
✓ it uses an absolute configured directory
Expand Down Expand Up @@ -2226,4 +2230,4 @@
✓ pass with dataset with ('my-datas-set-value')
✓ within describe → pass with dataset with ('my-datas-set-value')

Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 40 todos, 35 skipped, 1573 passed (3414 assertions)
Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 40 todos, 35 skipped, 1575 passed (3429 assertions)
18 changes: 18 additions & 0 deletions tests/Unit/Plugins/Tia/SourceScope.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

declare(strict_types=1);

use Pest\Plugins\Tia\SourceScope;

describe('noisePaths()', function (): void {
it('lists the directories that hold no project source', function (): void {
expect(SourceScope::noisePaths('/project'))
->toContain('/project/vendor/')
->toContain('/project/node_modules/')
->toContain('/project/storage/framework/');
});

it('ends every path with a separator so a sibling directory cannot match it', function (): void {
expect(SourceScope::noisePaths('/project'))->each->toEndWith(DIRECTORY_SEPARATOR);
});
});
4 changes: 2 additions & 2 deletions tests/Visual/Parallel.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@
$file = file_get_contents(__FILE__);
$file = preg_replace(
'/\$expected = \'.*?\';/',
"\$expected = '2 deprecated, 4 warnings, 5 incomplete, 3 notices, 40 todos, 27 skipped, 1555 passed (3359 assertions)';",
"\$expected = '2 deprecated, 4 warnings, 5 incomplete, 3 notices, 40 todos, 27 skipped, 1557 passed (3374 assertions)';",
$file,
);
file_put_contents(__FILE__, $file);
}

$expected = '2 deprecated, 4 warnings, 5 incomplete, 3 notices, 40 todos, 27 skipped, 1555 passed (3359 assertions)';
$expected = '2 deprecated, 4 warnings, 5 incomplete, 3 notices, 40 todos, 27 skipped, 1557 passed (3374 assertions)';

expect($output)
->toContain("Tests: {$expected}")
Expand Down