From 6ff8b8eb6c541aa23cdb9c741f25388380c3164b Mon Sep 17 00:00:00 2001 From: Olivier Gorzalka Date: Wed, 30 Sep 2026 13:17:50 +0200 Subject: [PATCH] test: warm up discovery before timing an empty scan The first scan in a process loads the discoverer's classes (150-225 ms idle), which pushed the empty-directory scan past the 250 ms threshold under pest --parallel. --- .../Services/DiscoveryCacheManagerSlowScanTest.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/Unit/Discovery/Infrastructure/Services/DiscoveryCacheManagerSlowScanTest.php b/tests/Unit/Discovery/Infrastructure/Services/DiscoveryCacheManagerSlowScanTest.php index 61f009ea..c06cfd23 100644 --- a/tests/Unit/Discovery/Infrastructure/Services/DiscoveryCacheManagerSlowScanTest.php +++ b/tests/Unit/Discovery/Infrastructure/Services/DiscoveryCacheManagerSlowScanTest.php @@ -73,6 +73,15 @@ function scanOf(DiscoveryCacheManager $manager, string $path): void // threshold is wrong and every site gets a log line per request. $this->logger->shouldNotReceive('warning'); + // The first scan in a process loads the discoverer's classes: 150 to + // 225 ms measured on an idle machine, past the threshold under the + // load of `pest --parallel`. That is autoloading, not the scan this + // test is about, so it is paid on another directory first. + $warmUp = sys_get_temp_dir().'/pollora-scan-'.bin2hex(random_bytes(6)); + mkdir($warmUp); + scanOf(managerFor(true), $warmUp); + rmdir($warmUp); + scanOf(managerFor(true, $this->logger), $this->dir); });