diff --git a/phpunit/src/FileScannerTest.php b/phpunit/src/FileScannerTest.php index 8a3c1e26..544cc9af 100644 --- a/phpunit/src/FileScannerTest.php +++ b/phpunit/src/FileScannerTest.php @@ -141,6 +141,15 @@ class FileScannerTest extends TestCase $scanner = new FileScanner($tmpDir); $files = $scanner->scan(); + $this->assertSame([ + $tmpDir . '/helper.c', + $tmpDir . '/lib.m', + $tmpDir . '/main.php', + $tmpDir . '/math.S', + $tmpDir . '/module.cc', + $tmpDir . '/sub/nested.cpp', + ], $files); + // Python and Markdown should not be included $this->assertContains($tmpDir . '/main.php', $files); $this->assertContains($tmpDir . '/helper.c', $files); diff --git a/src/Build/FileScanner.php b/src/Build/FileScanner.php index 6828b920..ee716ded 100644 --- a/src/Build/FileScanner.php +++ b/src/Build/FileScanner.php @@ -100,6 +100,12 @@ class FileScanner } } + // RecursiveDirectoryIterator follows filesystem directory-entry order, + // which differs between a fresh checkout and a long-lived worktree. + // Preparation allocates symbol-cache IDs while visiting this list, so + // keep both generated code and cache classification deterministic. + sort($files, SORT_STRING); + return $files; }