mirror of
https://github.com/pestphp/pest.git
synced 2026-12-05 23:32:17 +01:00
fix(tia): restrict Xdebug coverage to the source scope before tracing (#2091)
* fix(tia): restrict Xdebug coverage to the source scope before tracing * fix(tia): set the Xdebug exclude filter before the bootstrap and keep case twins traced --------- Co-authored-by: Punyapal Shah <mrpunyapal@gmail.com>
This commit is contained in:
@@ -215,3 +215,28 @@ it('tells an include path through a symlink to a directory with a separator in i
|
||||
}
|
||||
}
|
||||
})->skipOnWindows();
|
||||
|
||||
it('builds the source scope from the coverage filter and the source of the configuration', function (): void {
|
||||
mkdir($this->projectRoot.'/vendor/acme', 0755, true);
|
||||
file_put_contents($this->projectRoot.'/phpunit.xml', "<?xml version=\"1.0\"?>\n<phpunit><source><include><directory>lib</directory></include></source></phpunit>\n");
|
||||
$realRoot = (string) realpath($this->projectRoot);
|
||||
|
||||
$withoutFilter = ConfigurationFile::fromArguments(['--configuration', $this->projectRoot.'/phpunit.xml'])
|
||||
->sourceScope($this->projectRoot)
|
||||
?->coverageExcludePaths($this->projectRoot);
|
||||
$withFilter = ConfigurationFile::fromArguments(['--configuration', $this->projectRoot.'/phpunit.xml', '--coverage-filter', $realRoot.'/vendor/acme'])
|
||||
->sourceScope($this->projectRoot)
|
||||
?->coverageExcludePaths($this->projectRoot);
|
||||
|
||||
rmdir($this->projectRoot.'/vendor/acme');
|
||||
rmdir($this->projectRoot.'/vendor');
|
||||
|
||||
expect($withoutFilter)->toBe([$realRoot.DIRECTORY_SEPARATOR.'vendor'.DIRECTORY_SEPARATOR])
|
||||
->and($withFilter)->toBe([]);
|
||||
});
|
||||
|
||||
it('gives no source scope when the configuration cannot be read', function (): void {
|
||||
file_put_contents($this->projectRoot.'/phpunit.xml', '<phpunit');
|
||||
|
||||
expect(ConfigurationFile::at($this->projectRoot.'/phpunit.xml')->sourceScope($this->projectRoot))->toBeNull();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user