From 377a8afd8d6b8054343fced914692da51487fc86 Mon Sep 17 00:00:00 2001 From: Baptiste Langlade Date: Mon, 6 Apr 2026 14:43:23 +0200 Subject: [PATCH 1/2] add Application::filterOnTags() --- CHANGELOG.md | 6 +++++ proofs/application.php | 29 +++++++++++++++++++++++ src/Application.php | 53 ++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 86 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 292d387..b471068 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## [Unreleased] + +### Added + +- `Innmind\BlackBox\Application::filterOnTags()` + ## 6.11.0 - 2026-03-18 ### Added diff --git a/proofs/application.php b/proofs/application.php index 23ff4d5..a9bbdf1 100644 --- a/proofs/application.php +++ b/proofs/application.php @@ -478,4 +478,33 @@ static function($assert, $i) { ->contains('$i = 0'); }, )->tag(Tag::ci, Tag::local); + + yield test( + 'Application::filterOnTags()', + static function($assert) { + $io = Collect::new(); + + $result = Application::new([]) + ->displayOutputVia($io) + ->displayErrorVia($io) + ->usePrinter(Standard::withoutColors()) + ->filterOnTags(Tag::local) + ->tryToProve(static function() { + yield test( + 'example', + static fn($assert) => $assert->true(true), + )->tag(Tag::local); + + yield test( + 'example', + static fn($assert) => $assert->true(true), + )->tag(Tag::ci); + }); + + $assert->true($result->successful()); + $assert + ->string($io->toString()) + ->contains('Proofs: 1, Scenarii: 1'); + }, + )->tag(Tag::ci, Tag::local); }; diff --git a/src/Application.php b/src/Application.php index 00253e4..40465f8 100644 --- a/src/Application.php +++ b/src/Application.php @@ -35,11 +35,14 @@ final class Application private bool $disableMemoryLimit; private bool $stopOnFailure; private bool $failWhenNoAssertions; + /** @var ?list<\UnitEnum> */ + private ?array $tags; /** * @param \Closure(string): ?\UnitEnum $parseTag * @param list $args * @param int<1, max> $scenariiPerProof + * @param ?list<\UnitEnum> $tags */ private function __construct( Random $random, @@ -55,6 +58,7 @@ private function __construct( bool $disableMemoryLimit, bool $stopOnFailure, bool $failWhenNoAssertions, + ?array $tags, ) { $this->random = $random; $this->printer = $printer; @@ -69,6 +73,7 @@ private function __construct( $this->disableMemoryLimit = $disableMemoryLimit; $this->stopOnFailure = $stopOnFailure; $this->failWhenNoAssertions = $failWhenNoAssertions; + $this->tags = $tags; } /** @@ -91,6 +96,7 @@ public static function new(array $args): self false, false, true, + null, ); } @@ -114,6 +120,7 @@ public function useRandom(Random $random): self $this->disableMemoryLimit, $this->stopOnFailure, $this->failWhenNoAssertions, + $this->tags, ); } @@ -137,6 +144,7 @@ public function usePrinter(Printer $printer): self $this->disableMemoryLimit, $this->stopOnFailure, $this->failWhenNoAssertions, + $this->tags, ); } @@ -160,6 +168,7 @@ public function displayOutputVia(IO $output): self $this->disableMemoryLimit, $this->stopOnFailure, $this->failWhenNoAssertions, + $this->tags, ); } @@ -183,6 +192,7 @@ public function displayErrorVia(IO $error): self $this->disableMemoryLimit, $this->stopOnFailure, $this->failWhenNoAssertions, + $this->tags, ); } @@ -206,6 +216,7 @@ public function disableShrinking(): self $this->disableMemoryLimit, $this->stopOnFailure, $this->failWhenNoAssertions, + $this->tags, ); } @@ -231,6 +242,7 @@ public function useExhaustiveShrinking(): self $this->disableMemoryLimit, $this->stopOnFailure, $this->failWhenNoAssertions, + $this->tags, ); } @@ -256,6 +268,7 @@ public function parseTagWith(callable $parser): self $this->disableMemoryLimit, $this->stopOnFailure, $this->failWhenNoAssertions, + $this->tags, ); } @@ -281,6 +294,7 @@ public function scenariiPerProof(int $count): self $this->disableMemoryLimit, $this->stopOnFailure, $this->failWhenNoAssertions, + $this->tags, ); } @@ -304,6 +318,7 @@ public function codeCoverage(CodeCoverage $codeCoverage): self $this->disableMemoryLimit, $this->stopOnFailure, $this->failWhenNoAssertions, + $this->tags, ); } @@ -327,6 +342,7 @@ public function disableGlobalFunctions(): self $this->disableMemoryLimit, $this->stopOnFailure, $this->failWhenNoAssertions, + $this->tags, ); } @@ -350,6 +366,7 @@ public function disableMemoryLimit(): self true, $this->stopOnFailure, $this->failWhenNoAssertions, + $this->tags, ); } @@ -373,6 +390,7 @@ public function stopOnFailure(): self $this->disableMemoryLimit, true, $this->failWhenNoAssertions, + $this->tags, ); } @@ -396,6 +414,32 @@ public function allowProofsToNotMakeAnyAssertions(): self $this->disableMemoryLimit, $this->stopOnFailure, false, + $this->tags, + ); + } + + /** + * @psalm-mutation-free + * @no-named-arguments + */ + #[\NoDiscard] + public function filterOnTags(\UnitEnum ...$tags): self + { + return new self( + $this->random, + $this->printer, + $this->output, + $this->error, + $this->runner, + $this->parseTag, + $this->codeCoverage, + $this->args, + $this->scenariiPerProof, + $this->useGlobalFunctions, + $this->disableMemoryLimit, + $this->stopOnFailure, + $this->failWhenNoAssertions, + $tags, ); } @@ -435,8 +479,13 @@ public function tryToProve(callable $proofs): Result require_once __DIR__.'/Runner/global.php'; } - $tags = \array_map($this->parseTag, $this->args); - $tags = \array_filter($tags, static fn($tag) => $tag instanceof \UnitEnum); + if (\is_null($this->tags)) { + $tags = \array_map($this->parseTag, $this->args); + $tags = \array_filter($tags, static fn($tag) => $tag instanceof \UnitEnum); + } else { + $tags = $this->tags; + } + $filter = Filter::new()->onTags(...$tags); $run = Runner::of( From e5e522fb1910ba8f1362796dcb9a620afc145f78 Mon Sep 17 00:00:00 2001 From: Baptiste Langlade Date: Mon, 6 Apr 2026 14:43:45 +0200 Subject: [PATCH 2/2] only run local proofs inside the lab station --- blackbox.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/blackbox.php b/blackbox.php index 276e5c5..3474e04 100644 --- a/blackbox.php +++ b/blackbox.php @@ -8,6 +8,7 @@ Runner\Load, Runner\CodeCoverage, Runner\IO\Collect, + Tag, }; use function Innmind\BlackBox\Runner\test; @@ -54,6 +55,7 @@ ->enableWhen(true), ), 'extensive' => $app->scenariiPerProof(1000), + 'lab_station' => $app->filterOnTags(Tag::local), default => $app, }) ->tryToProve(Load::everythingIn(__DIR__.'/proofs/'))