fix: skip the frames of Pest by its own directory, not by the name of the checkout (#1913)

`Backtrace::backtrace()` skipped a frame when its path held `pest/src`, so
a checkout of this repository in a directory with any other name, such as
`pest5`, returned `src/Support/Backtrace.php` as the file of the caller and
`tests/Unit/Support/Backtrace.php` failed. The frame check now compares
against the directory that holds this file, which is the same directory
whether Pest runs from its own checkout or from `vendor/pestphp/pest`, and
the global that marked the internal test suite has no reader left.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Co-authored-by: Punyapal Shah <53343069+MrPunyapal@users.noreply.github.com>
This commit is contained in:
Jhon Farias
2026-10-31 19:40:56 +01:00
committed by GitHub
parent 4cfe8ecc42
commit f66a8e9e93
2 changed files with 1 additions and 7 deletions
+1 -5
View File
@@ -99,11 +99,7 @@ final class Backtrace
continue;
}
if (($GLOBALS['__PEST_INTERNAL_TEST_SUITE'] ?? false) && str_contains($trace['file'], 'pest'.DIRECTORY_SEPARATOR.'src')) {
continue;
}
if (str_contains($trace['file'], DIRECTORY_SEPARATOR.'pestphp'.DIRECTORY_SEPARATOR.'pest'.DIRECTORY_SEPARATOR.'src')) {
if (str_starts_with($trace['file'], dirname(__DIR__).DIRECTORY_SEPARATOR)) {
continue;
}
-2
View File
@@ -5,8 +5,6 @@ use Tests\CustomTestCaseInSubFolders\SubFolder\SubFolder\CustomTestCaseInSubFold
error_reporting(E_ALL);
$GLOBALS['__PEST_INTERNAL_TEST_SUITE'] = true;
pest()->project()->github('pestphp/pest');
pest()->in('PHPUnit/CustomTestCaseInSubFolders/SubFolder/SubFolder')->use(CustomTestCaseInSubFolder::class);