From 900fee19f96d52310181ae252dcb5127a09eda73 Mon Sep 17 00:00:00 2001 From: Paul Sochiera Date: Tue, 28 Apr 2026 13:56:23 +0200 Subject: [PATCH] feat: include test-files not living in root/Tests/ (i.e. root/modules/Example/Tests/) --- modules/Example/tests/ShardModuleExample.php | 5 +++++ src/Plugins/Shard.php | 2 +- tests/Unit/Plugins/Shard.php | 13 +++++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 modules/Example/tests/ShardModuleExample.php create mode 100644 tests/Unit/Plugins/Shard.php diff --git a/modules/Example/tests/ShardModuleExample.php b/modules/Example/tests/ShardModuleExample.php new file mode 100644 index 000000000..66083b652 --- /dev/null +++ b/modules/Example/tests/ShardModuleExample.php @@ -0,0 +1,5 @@ +toBeTrue(); +}); diff --git a/src/Plugins/Shard.php b/src/Plugins/Shard.php index 814125f20..610ce8949 100644 --- a/src/Plugins/Shard.php +++ b/src/Plugins/Shard.php @@ -193,7 +193,7 @@ private function allTests(array $arguments): array '--list-tests', ]))->setTimeout(120)->mustRun()->getOutput(); - preg_match_all('/ - (?:P\\\\)?(Tests\\\\[^:]+)::/', $output, $matches); + preg_match_all('/ - (?:P\\\\)?([^:]+)::/', $output, $matches); return array_values(array_unique($matches[1])); } diff --git a/tests/Unit/Plugins/Shard.php b/tests/Unit/Plugins/Shard.php new file mode 100644 index 000000000..6cc7363f7 --- /dev/null +++ b/tests/Unit/Plugins/Shard.php @@ -0,0 +1,13 @@ +createMock(OutputInterface::class)); + + $allTests = \Closure::bind(fn (array $arguments): array => $this->allTests($arguments), $plugin, ShardPlugin::class); + + expect($allTests(['bin/pest', 'modules/Example/tests/ShardModuleExample.php'])) + ->toContain('Modules\\Example\\tests\\ShardModuleExample'); +});