diff --git a/bridge/symfony-console/src/Command/Run.php b/bridge/symfony-console/src/Command/Run.php index 6d3a5f57..4a09fe2d 100644 --- a/bridge/symfony-console/src/Command/Run.php +++ b/bridge/symfony-console/src/Command/Run.php @@ -64,6 +64,9 @@ * # Runs tests in Unit directory that match testImportant* AND are in Critical suite * ./bin/testo run --path="tests/Unit/*" --filter=testImportant --suite=Critical * + * # Hide the per-test progress; failures and the final report are still printed + * ./bin/testo run --no-progress + * * # Run tests with custom config * ./bin/testo run --config=./testo.php * ``` @@ -94,6 +97,13 @@ public function configure(): void 'Write the minimalistic JSON report (run summary + failed tests) to the given path. ' . 'Unlike --json this keeps the human-readable terminal output; mirrors --log-junit.', ); + $this->addOption( + 'no-progress', + null, + InputOption::VALUE_NONE, + 'Print nothing per suite, case or test while the run goes; the failures and the final ' + . 'report still come out at the end. Affects the terminal output only.', + ); $this->addOption( 'filter', null, diff --git a/bridge/symfony-console/tests/Acceptance/RunCommandTest.php b/bridge/symfony-console/tests/Acceptance/RunCommandTest.php index 3c9ac374..23c133a2 100644 --- a/bridge/symfony-console/tests/Acceptance/RunCommandTest.php +++ b/bridge/symfony-console/tests/Acceptance/RunCommandTest.php @@ -13,10 +13,12 @@ use Testo\Lifecycle\BeforeTest; use Testo\Output\Html\HtmlPlugin; use Testo\Test; +use Tests\Bridge\SymfonyConsole\Stub\CapturedConsoleStreams; +use Tests\Bridge\SymfonyConsole\Stub\DiscardConsoleStreams; use Tests\Bridge\SymfonyConsole\Testo\Sandbox; /** - * Acceptance tests for the `--log-html` flag of `testo run`. + * Acceptance tests for the `--log-html` and `--no-progress` flags of `testo run`. * * Each test drives the real command end-to-end — Symfony parses the flags, {@see Run::initialize()} * normalizes them and a whole nested run happens in-process — inside a fresh {@see Sandbox} holding a @@ -94,6 +96,36 @@ public function withoutTheFlagNothingIsResolvedAndNoReportIsWritten(): void ); } + public function noProgressLeavesOnlyTheFinalReport(): void + { + $this->sandbox->writeFile('testo.php', self::configPointingAtTheStubSuite(CapturedConsoleStreams::class)); + + $tester = $this->run(['--no-progress' => true]); + $output = CapturedConsoleStreams::output(); + + Assert::same($tester->getStatusCode(), Command::SUCCESS, $output); + Assert::string($output)->ignoringAnsi() + ->notContains('Suite: Stub') + ->notContains('PassingCase') + ->notContains('itPasses') + ->contains('Summary') + ->contains('1 passed'); + } + + public function withoutNoProgressTheTestsAreListedAsTheyRun(): void + { + $this->sandbox->writeFile('testo.php', self::configPointingAtTheStubSuite(CapturedConsoleStreams::class)); + + $tester = $this->run(); + $output = CapturedConsoleStreams::output(); + + Assert::same($tester->getStatusCode(), Command::SUCCESS, $output); + Assert::string($output)->ignoringAnsi() + ->contains('Suite: Stub') + ->contains('itPasses') + ->contains('Summary'); + } + #[BeforeTest] public function setUp(): void { @@ -111,8 +143,10 @@ public function tearDown(): void * The smallest config a nested run needs: no sources, one suite pointing at this module's stub case, * and a fresh inert reporter in place of the process-wide default (see the class docblock). * The stub directory is embedded as an absolute path — the sandbox CWD is elsewhere. + * + * @param class-string $streams Plugin that binds the run's console streams. */ - private static function configPointingAtTheStubSuite(): string + private static function configPointingAtTheStubSuite(string $streams = DiscardConsoleStreams::class): string { $stub = \var_export(\dirname(__DIR__) . '/Stub/Run', true); @@ -126,7 +160,6 @@ private static function configPointingAtTheStubSuite(): string use Testo\\Application\\Config\\Plugin\\ApplicationPlugins; use Testo\\Application\\Config\\SuiteConfig; use Testo\\Output\\Html\\HtmlPlugin; - use Tests\\Bridge\\SymfonyConsole\\Stub\\DiscardConsoleStreams; return new ApplicationConfig( src: [], @@ -137,7 +170,7 @@ private static function configPointingAtTheStubSuite(): string ), ], plugins: ApplicationPlugins::without(HtmlPlugin::class) - ->with(HtmlPlugin::inert(), new DiscardConsoleStreams()), + ->with(HtmlPlugin::inert(), new \\{$streams}()), ); PHP; } diff --git a/bridge/symfony-console/tests/Stub/CapturedConsoleStreams.php b/bridge/symfony-console/tests/Stub/CapturedConsoleStreams.php new file mode 100644 index 00000000..a09866dd --- /dev/null +++ b/bridge/symfony-console/tests/Stub/CapturedConsoleStreams.php @@ -0,0 +1,43 @@ +set(new ConsoleStreams($sink, $sink), ConsoleStreams::class); + } +} diff --git a/core/Output/Terminal/Internal/TerminalInput.php b/core/Output/Terminal/Internal/TerminalInput.php new file mode 100644 index 00000000..7c697f3c --- /dev/null +++ b/core/Output/Terminal/Internal/TerminalInput.php @@ -0,0 +1,25 @@ +out = new SharedStream($streams->stdout); $this->errorOutput = $streams->stderr; @@ -103,7 +113,7 @@ public function __construct( public function suiteStartedFromInfo(SuiteInfo $info): void { $this->currentSuiteName = $info->name; - $this->write(null, Formatter::suiteHeader($info->name, $this->format)); + $this->writeProgress(null, Formatter::suiteHeader($info->name, $this->format)); } /** @@ -111,7 +121,7 @@ public function suiteStartedFromInfo(SuiteInfo $info): void */ public function handleSuiteResult(SuiteInfo $info, SuiteResult $result): void { - $this->write(null, Formatter::suiteSummary($result)); + $this->writeProgress(null, Formatter::suiteSummary($result)); } /** @@ -119,7 +129,7 @@ public function handleSuiteResult(SuiteInfo $info, SuiteResult $result): void */ public function caseStartedFromInfo(CaseInfo $info): void { - $this->write(null, Formatter::caseHeader($info->name, $this->format)); + $this->writeProgress(null, Formatter::caseHeader($info->name, $this->format)); } /** @@ -135,8 +145,8 @@ public function handleCaseResult(CaseInfo $info, CaseResult $result): void $this->currentTestName = []; $this->currentIndentLevel = []; - $this->write(null, Formatter::caseFooter($this->format)); - $this->write(null, Formatter::caseSummary($result, $this->format)); + $this->writeProgress(null, Formatter::caseFooter($this->format)); + $this->writeProgress(null, Formatter::caseSummary($result, $this->format)); } /** @@ -154,11 +164,11 @@ public function batchStartedFromInfo(TestInfo $info): void $indent = $this->format === OutputFormat::Verbose ? ' ' : ' '; $symbol = Style::dim(Symbol::DataProvider->value); $id = $info->identity->pipelineId; - $this->write($id, "{$indent}{$symbol} {$info->name}\n"); + $this->writeProgress($id, "{$indent}{$symbol} {$info->name}\n"); // The description belongs to the test, not to each dataset — print it once here, at the root // of the dataset tree, so it is not repeated under every dataset (see handle*Test). - $this->write($id, Formatter::description( + $this->writeProgress($id, Formatter::description( (string) $info->testDefinition->getDescription(), 0, $this->format, @@ -217,10 +227,10 @@ public function closeTest(TestInfo $info): void * Streams a captured channel {@see Message} to the terminal in real time. * * A colored channel header (name + time of the group's first message) is printed when the group - * changes; same-group content is appended verbatim. Live streaming happens only at - * {@see Verbosity::Verbose} and above; at lower verbosity the output of a *failed* test is shown - * after the fact (see {@see printFailures()}). Suppressed in Dots mode, whose single-character - * per-test layout multi-line output would break. + * changes; same-group content is appended verbatim. Live streaming is part of the progress and + * happens only at {@see Verbosity::Verbose} and above; otherwise the output of a *failed* test is + * shown after the fact (see {@see printFailures()}). Suppressed in Dots mode, whose + * single-character per-test layout multi-line output would break. * * @param int|null $owner Run of the test the message belongs to * ({@see \Testo\Core\Context\Identity\TestIdentity::$pipelineId}), which decides both the @@ -241,9 +251,9 @@ public function logMessage(Message $message, ?int $owner = null): void return; } - # Every other channel streams only at Verbose+ and is suppressed in the Dots layout (whose - # single-character-per-test format multi-line output would break). - if ($this->format === OutputFormat::Dots || !$this->verbosity->atLeast(Verbosity::Verbose)) { + # Every other channel streams only at Verbose+ with progress on and is suppressed in the Dots + # layout (whose single-character-per-test format multi-line output would break). + if ($this->format === OutputFormat::Dots || !$this->streamsLive()) { return; } @@ -321,6 +331,7 @@ public function printEnvironment(): void default => 'enabled', }; $this->write(null, \sprintf(' %s %s', Style::info('OPcache:'), $opcache) . "\n\n"); + $this->endsWithBlankLine = !$this->progress; } /** @@ -373,7 +384,7 @@ private static function buildFullTestName( * invocation, so its channels are worth printing even for a passing test — which normally stays * quiet at {@see Verbosity::Normal}. * - * Skipped when the output was already streamed live ({@see Verbosity::Verbose} and above), + * Skipped when the output was already streamed live ({@see streamsLive()}), * when the user asked for less noise ({@see Verbosity::Quiet}), in the single-character Dots * layout, and for a failed/aborted test whose output {@see printFailures()} already prints. */ @@ -384,7 +395,8 @@ private function printSingleTestOutput(RunResult $result): void $test === null || $result->summary->total() !== 1 || $this->format === OutputFormat::Dots - || $this->verbosity !== Verbosity::Normal + || $this->verbosity === Verbosity::Quiet + || $this->streamsLive() || $test->status->isFailure() || $test->status === Status::Aborted ) { @@ -401,9 +413,35 @@ private function printSingleTestOutput(RunResult $result): void */ private function write(?int $owner, string $text): void { + if ($this->endsWithBlankLine) { + $text = \ltrim($text, "\n"); + if ($text === '') { + return; + } + + $this->endsWithBlankLine = false; + } + $this->out->write($owner, $text); } + /** + * Whether channel messages reach the terminal while the test runs. + */ + private function streamsLive(): bool + { + return $this->progress && $this->verbosity->atLeast(Verbosity::Verbose); + } + + /** + * Writes a line of the live progress: a suite, case or test as it goes. The final report does not + * depend on any of it. + */ + private function writeProgress(?int $owner, string $text): void + { + $this->progress and $this->write($owner, $text); + } + /** * Channel grouping for the given owner's block, opened on demand. */ @@ -429,7 +467,7 @@ private function handlePassedTest(TestResult $result, ?int $duration): void description: $this->resultDescription($result), ); - $this->write($result->info->identity->pipelineId, Formatter::formatRun($item, $this->format)); + $this->writeProgress($result->info->identity->pipelineId, Formatter::formatRun($item, $this->format)); $this->printMultipleRuns($result); unset($this->currentTestName[$result->info->identity->pipelineId]); } @@ -456,7 +494,7 @@ private function handleFailedTest(TestResult $result, ?int $duration): void description: $this->resultDescription($result), ); - $this->write($result->info->identity->pipelineId, Formatter::formatRun($item, $this->format)); + $this->writeProgress($result->info->identity->pipelineId, Formatter::formatRun($item, $this->format)); $this->printMultipleRuns($result); unset($this->currentTestName[$result->info->identity->pipelineId]); } @@ -515,7 +553,7 @@ private function printMultipleRuns(TestResult $result): void description: (string) $runKey, ); - $this->write($result->info->identity->pipelineId, Formatter::formatRun($item, $this->format)); + $this->writeProgress($result->info->identity->pipelineId, Formatter::formatRun($item, $this->format)); $runNumber++; } } @@ -534,7 +572,7 @@ private function handleSkippedTest(TestResult $result, ?int $duration): void indentLevel: $this->indentLevel($result), ); - $this->write($result->info->identity->pipelineId, Formatter::formatRun($item, $this->format)); + $this->writeProgress($result->info->identity->pipelineId, Formatter::formatRun($item, $this->format)); unset($this->currentTestName[$result->info->identity->pipelineId]); } @@ -552,7 +590,7 @@ private function handleRiskyTest(TestResult $result, ?int $duration): void indentLevel: $this->indentLevel($result), ); - $this->write($result->info->identity->pipelineId, Formatter::formatRun($item, $this->format)); + $this->writeProgress($result->info->identity->pipelineId, Formatter::formatRun($item, $this->format)); unset($this->currentTestName[$result->info->identity->pipelineId]); } @@ -587,8 +625,8 @@ function: $result->info->testDefinition->reflection, $details = $details === '' ? $diffBlock : $diffBlock . "\n\n" . $details; } - // At lower verbosity nothing was streamed live — surface the test's captured output here. - if (!$this->verbosity->atLeast(Verbosity::Verbose)) { + // Nothing was streamed live — surface the test's captured output here. + if (!$this->streamsLive()) { $output = self::renderMessages($result->messages); $output === '' or $details = $details === '' ? $output : $details . "\n\n" . $output; } diff --git a/core/Output/Terminal/TerminalPlugin.php b/core/Output/Terminal/TerminalPlugin.php index 1c71be99..c393165a 100644 --- a/core/Output/Terminal/TerminalPlugin.php +++ b/core/Output/Terminal/TerminalPlugin.php @@ -23,6 +23,7 @@ use Testo\Event\TestSuite\TestSuitesLocated; use Testo\Event\TestSuite\TestSuiteStarting; use Testo\Output\ConsoleStreams; +use Testo\Output\Terminal\Internal\TerminalInput; use Testo\Output\Terminal\Renderer\ColorMode; use Testo\Output\Terminal\Renderer\RunStatus; use Testo\Output\Terminal\Renderer\Style; @@ -60,7 +61,9 @@ public function configure(Container $container): void ?? ($container->has(ColorMode::class) ? $container->get(ColorMode::class) : ColorMode::Always); Style::setColorsEnabled($colorMode->shouldUseColors()); - $this->logger = $container->get(TerminalLogger::class); + $this->logger = $container->get(TerminalLogger::class, [ + 'progress' => !$container->get(TerminalInput::class)->noProgress, + ]); $listeners = $container->get(EventListenerCollector::class); diff --git a/skills/testo-run-tests/SKILL.md b/skills/testo-run-tests/SKILL.md index 7d6a91d1..1e6c0eef 100644 --- a/skills/testo-run-tests/SKILL.md +++ b/skills/testo-run-tests/SKILL.md @@ -114,6 +114,9 @@ over-narrow filter — widen it (a typo in `--filter`, a `--path` that matches n bare `--log-html` → `runtime/report`), `--log-report=` (the full run as a versioned JSON document — the data behind the HTML), `--teamcity` — reports for CI and IDEs, not for agent parsing. +- `--no-progress` — terminal output without the per-test stream (no suite, case or test lines, no + dots): only the failure details and the final summary. Pair it with `--log-json=` for a short CI + log; `--json`, `--teamcity` and the `--log-*` reports are unaffected. - `--config=path/to/testo.php` when the config is not at the project root. - In an interactive terminal the default renderer also reports the run's progress and outcome to the terminal itself (OSC 7501 program status, shown in the tab by terminals that support it). It is off diff --git a/tests/Output/Unit/Terminal/TerminalLoggerTest.php b/tests/Output/Unit/Terminal/TerminalLoggerTest.php index 7d557c2f..d87d4754 100644 --- a/tests/Output/Unit/Terminal/TerminalLoggerTest.php +++ b/tests/Output/Unit/Terminal/TerminalLoggerTest.php @@ -279,6 +279,149 @@ static function (TerminalLogger $logger) use ($suiteInfo, $caseInfo, $caseResult ->contains('1 passed'); } + public function withoutProgressOnlyTheFinalReportIsWritten(): void + { + $passed = self::test('passingTest', Status::Passed); + $failed = self::test('failingTest', Status::Failed, new \RuntimeException('boom')); + $batch = self::test('describedTest', Status::Passed); + $caseInfo = $passed->info->caseInfo; + $suiteInfo = new SuiteInfo('Output/Unit', CaseDefinitions::fromArray()); + $summary = new Summary(['Passed' => 2, 'Failed' => 1]); + $caseResult = new CaseResult([$passed, $failed, $batch], Status::Failed, $summary); + $suiteResult = new SuiteResult([$caseResult], Status::Failed, $summary); + $run = new RunResult([$suiteResult], Status::Failed, $summary, new RunTiming()); + + $output = self::withoutColors(static fn(): string => self::capture( + static function (TerminalLogger $logger) use ( + $suiteInfo, $caseInfo, $passed, $failed, $batch, $caseResult, $suiteResult, $run, + ): void { + $logger->suiteStartedFromInfo($suiteInfo); + $logger->caseStartedFromInfo($caseInfo); + $logger->handleTestResult($passed, 0); + $logger->handleTestResult($failed, 0); + $logger->batchStartedFromInfo($batch->info); + $logger->testStartedFromInfo($batch->info, 'Dataset #0 [a]'); + $logger->handleTestResult($batch, 0); + $logger->batchFinishedFromInfo($batch->info); + $logger->closeTest($batch->info); + $logger->handleCaseResult($caseInfo, $caseResult); + $logger->handleSuiteResult($suiteInfo, $suiteResult); + $logger->printSummary($run); + }, + format: OutputFormat::Verbose, + progress: false, + )); + + Assert::string($output) + ->notContains('Suite: Output/Unit') + ->notContains('Case:') + ->notContains('passingTest') + ->notContains('describedTest') + ->notContains('Sample description line') + ->contains('Failures:') + ->contains('Output/Unit / ') + ->contains(':: failingTest') + ->contains('Total') + ->contains('2 passed, 1 failed'); + Assert::same(\substr_count($output, 'failingTest'), 1); + Assert::same(\substr_count($output, 'boom'), 2); + } + + public function verboseRunWithoutProgressPrintsCapturedOutputOnlyInTheFailureBlock(): void + { + $message = new Message(0.0, 'stdout', Level::Info, "captured line\n"); + $failed = self::test('failingTest', Status::Failed, new \RuntimeException('boom'), new MessageLog([$message])); + $run = self::run([$failed], Status::Failed, summary: new Summary(['Failed' => 1])); + + $output = self::withoutColors(static fn(): string => self::capture( + static function (TerminalLogger $logger) use ($message, $failed, $run): void { + $logger->logMessage($message, $failed->info->identity->pipelineId); + $logger->handleTestResult($failed, 0); + $logger->closeTest($failed->info); + $logger->printSummary($run); + }, + verbosity: Verbosity::Verbose, + progress: false, + )); + + Assert::same(\substr_count($output, 'captured line'), 1); + Assert::string($output)->matchesRegex('/Failures:.*Output:.*captured line/s'); + } + + public function verboseSingleTestRunWithoutProgressSurfacesItsOutput(): void + { + $test = self::test('passingTest', Status::Passed, messages: new MessageLog([ + new Message(0.0, 'stdout', Level::Info, 'nothing streamed live'), + ])); + $run = self::run([$test], Status::Passed); + + $output = self::capture( + static function (TerminalLogger $logger) use ($test, $run): void { + $logger->handleTestResult($test, 0); + $logger->printSummary($run); + }, + verbosity: Verbosity::Verbose, + progress: false, + ); + + Assert::same(\substr_count($output, 'nothing streamed live'), 1); + } + + public function dotsWithoutProgressPrintNothingWhileTheRunGoes(): void + { + $passed = self::test('passingTest', Status::Passed); + $failed = self::test('failingTest', Status::Failed, new \RuntimeException('boom')); + $caseResult = new CaseResult([$passed, $failed], Status::Failed, new Summary(['Passed' => 1, 'Failed' => 1])); + + $output = self::capture( + static function (TerminalLogger $logger) use ($passed, $failed, $caseResult): void { + $logger->caseStartedFromInfo($passed->info->caseInfo); + $logger->handleTestResult($passed, 0); + $logger->handleTestResult($failed, 0); + $logger->handleCaseResult($passed->info->caseInfo, $caseResult); + }, + format: OutputFormat::Dots, + progress: false, + ); + + Assert::same($output, ''); + } + + public function multipleRunsAreOmittedWithoutProgress(): void + { + $runA = self::test('passingTest', Status::Passed); + $runB = self::test('passingTest', Status::Failed); + $test = self::test('passingTest', Status::Passed, attributes: [ + MultipleResult::class => new MultipleResult(['first' => $runA, 'second' => $runB]), + ]); + + $output = self::capture( + static fn(TerminalLogger $logger) => $logger->handleTestResult($test, 0), + progress: false, + ); + + Assert::same($output, ''); + } + + #[DataSet([Status::Failed, 'Failures:'], 'failures come first')] + #[DataSet([Status::Passed, 'Summary'], 'summary comes first')] + public function withoutProgressTheReportIsOneBlankLineBelowTheEnvironment(Status $status, string $heading): void + { + $test = self::test('passingTest', $status); + $run = self::run([$test], $status, summary: new Summary([$status->name => 1])); + + $output = self::withoutColors(static fn(): string => self::capture( + static function (TerminalLogger $logger) use ($test, $run): void { + $logger->printEnvironment(); + $logger->handleTestResult($test, 0); + $logger->printSummary($run); + }, + progress: false, + )); + + Assert::string($output)->matchesRegex('/OPcache: [^\n]*\n\n ' . \preg_quote($heading, '/') . '/'); + } + #[DataSet([Status::Skipped, '○'], 'skipped renders the open circle')] #[DataSet([Status::Cancelled, '○'], 'cancelled reuses the skipped circle')] #[DataSet([Status::Risky, '?'], 'risky renders the question mark')] @@ -549,12 +692,13 @@ private static function capture( \Closure $scenario, OutputFormat $format = OutputFormat::Compact, Verbosity $verbosity = Verbosity::Normal, + bool $progress = true, ): string { $stream = \fopen('php://memory', 'rb+'); \assert($stream !== false); try { - $scenario(new TerminalLogger(new ConsoleStreams($stream), $format, $verbosity)); + $scenario(new TerminalLogger(new ConsoleStreams($stream), $format, $verbosity, $progress)); \rewind($stream); $output = \stream_get_contents($stream); } finally { diff --git a/tests/Output/Unit/Terminal/TerminalPluginTest.php b/tests/Output/Unit/Terminal/TerminalPluginTest.php index 8e13d0e3..4a82270f 100644 --- a/tests/Output/Unit/Terminal/TerminalPluginTest.php +++ b/tests/Output/Unit/Terminal/TerminalPluginTest.php @@ -40,6 +40,7 @@ use Testo\Event\TestSuite\TestSuitesLocated; use Testo\Event\TestSuite\TestSuiteStarting; use Testo\Output\ConsoleStreams; +use Testo\Output\Terminal\Internal\TerminalInput; use Testo\Output\Terminal\ProgramStatus; use Testo\Output\Terminal\Renderer\ColorMode; use Testo\Output\Terminal\Renderer\Style; @@ -218,6 +219,39 @@ public function withoutATerminalNoProgramStatusIsWritten(): void Assert::string($output)->notContains("\033]7501;"); } + public function noProgressInputLeavesOnlyTheFinalReport(): void + { + $passed = self::makeTestInfo('passingTest'); + $failed = self::makeTestInfo('failingTest'); + $failure = new TestResult(info: $failed, status: Status::Failed, failure: new \RuntimeException('boom')); + $suite = new SuiteInfo('Output/Unit', CaseDefinitions::fromArray($passed->caseInfo->definition)); + + $output = self::capture( + static function (EventDispatcher $dispatcher) use ($passed, $failed, $failure, $suite): void { + $dispatcher->dispatch(new SessionStarting()); + $dispatcher->dispatch(new TestSuiteStarting($suite)); + $dispatcher->dispatch(new TestCaseStarting($passed->caseInfo)); + $dispatcher->dispatch(new TestPipelineFinished($passed, self::passed($passed))); + $dispatcher->dispatch(new TestPipelineFinished($failed, $failure)); + $dispatcher->dispatch(new SessionFinished(new RunResult( + [], + status: Status::Failed, + summary: new Summary(['Passed' => 1, 'Failed' => 1]), + ))); + }, + noProgress: true, + ); + + Assert::string($output) + ->contains('Testo') + ->notContains('Suite: Output/Unit') + ->notContains('passingTest') + ->contains('Failures:') + ->contains(':: failingTest') + ->contains('1 passed, 1 failed'); + Assert::same(\substr_count($output, 'failingTest'), 1); + } + private static function report(): ReportInfo { return new ReportInfo('html', 'Testo HTML report', Path::create('runtime/report/index.html')); @@ -229,8 +263,9 @@ private static function report(): ReportInfo * * @param \Closure(EventDispatcher): void $scenario * @param bool $status Report program status to the terminal stream, as on an interactive terminal. + * @param bool $noProgress Run as with `--no-progress`. */ - private static function capture(\Closure $scenario, bool $status = false): string + private static function capture(\Closure $scenario, bool $status = false, bool $noProgress = false): string { $stdout = \fopen('php://memory', 'w+'); $stderr = \fopen('php://memory', 'w+'); @@ -247,6 +282,9 @@ private static function capture(\Closure $scenario, bool $status = false): strin $container->set(new ConsoleStreams($stdout, $stderr), ConsoleStreams::class); $container->set(Verbosity::Verbose, Verbosity::class); $status and $container->set(new ProgramStatus($stdout), ProgramStatus::class); + $input = new TerminalInput(); + $input->noProgress = $noProgress; + $container->set($input); (new TerminalPlugin(ColorMode::Never))->configure($container); $scenario($dispatcher); diff --git a/tools/structarmed/structarmed-baseline.php b/tools/structarmed/structarmed-baseline.php index d4e5ae56..b2664c35 100644 --- a/tools/structarmed/structarmed-baseline.php +++ b/tools/structarmed/structarmed-baseline.php @@ -717,6 +717,20 @@ 'class' => 'Testo\Output\Teamcity\TeamcityPlugin', 'layer' => 'Core', ], + [ + 'rule' => 'core.internal_is_usable_only_within_its_package', + 'message' => 'Class [Testo\Output\Terminal\Internal\TerminalInput] must not use internal [Testo\Application\Config\Internal\Attribute\InflectableConfig] — it is private to package [Testo\Application\Config]', + 'file' => 'core/Output/Terminal/Internal/TerminalInput.php', + 'class' => 'Testo\Output\Terminal\Internal\TerminalInput', + 'layer' => 'Core', + ], + [ + 'rule' => 'core.internal_is_usable_only_within_its_package', + 'message' => 'Class [Testo\Output\Terminal\Internal\TerminalInput] must not use internal [Testo\Application\Config\Internal\Attribute\InputOption] — it is private to package [Testo\Application\Config]', + 'file' => 'core/Output/Terminal/Internal/TerminalInput.php', + 'class' => 'Testo\Output\Terminal\Internal\TerminalInput', + 'layer' => 'Core', + ], [ 'rule' => 'core.class_must_declare_api_or_internal', 'message' => 'Enum [Testo\Output\Terminal\Renderer\ColorMode] must be annotated @api or @internal',