Skip to content

Commit cbd8443

Browse files
committed
[tests] Suppress extra JSON progress records
1 parent 860f47d commit cbd8443

3 files changed

Lines changed: 14 additions & 22 deletions

File tree

docs/commands/tests.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,8 @@ Behavior
167167
command stores that payload inside ``output`` while keeping the standard
168168
DevTools JSON envelope. ``--json`` and ``--pretty-json`` therefore expose
169169
the same structured result, with formatting as the only difference.
170+
- in structured mode, the command suppresses intermediary ``Running...`` log
171+
records so the output stream contains a single final JSON document.
170172
- when structured capture is active but PHPUnit does not emit parseable JSON,
171173
the command preserves the raw subprocess text inside ``output.raw_output``
172174
instead of dropping it.

src/Console/Command/TestsCommand.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int
181181
$processOutput = $structuredOutput ? new BufferedOutput() : $output;
182182
$cacheEnabled = $this->isCacheEnabled($input);
183183

184-
$this->getLogger()
185-
->info('Running PHPUnit tests...', [
186-
'input' => $input,
187-
]);
184+
if (! $structuredOutput) {
185+
$this->getLogger()
186+
->info('Running PHPUnit tests...', [
187+
'input' => $input,
188+
]);
189+
}
188190

189191
try {
190192
$minimumCoverage = $this->resolveMinimumCoverage($input);

tests/Console/Command/TestsCommandTest.php

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -254,9 +254,7 @@ public function executeWillDisablePhpUnitProgressWhenJsonIsRequested(): void
254254

255255
return TestsCommand::SUCCESS;
256256
})->shouldBeCalled();
257-
$this->logger->info('Running PHPUnit tests...', Argument::that(
258-
static fn(array $context): bool => $context['input'] instanceof InputInterface
259-
))->shouldBeCalled();
257+
$this->logger->info(Argument::cetera())->shouldNotBeCalled();
260258
$this->logger->log(
261259
'info',
262260
'PHPUnit tests completed successfully.',
@@ -299,9 +297,7 @@ public function executeWillCaptureStructuredPhpUnitSummaryWhenAgentEnvironmentIs
299297

300298
return TestsCommand::SUCCESS;
301299
})->shouldBeCalled();
302-
$this->logger->info('Running PHPUnit tests...', Argument::that(
303-
static fn(array $context): bool => $context['input'] instanceof InputInterface
304-
))->shouldBeCalled();
300+
$this->logger->info(Argument::cetera())->shouldNotBeCalled();
305301
$this->logger->log(
306302
'info',
307303
'PHPUnit tests completed successfully.',
@@ -343,9 +339,7 @@ public function executeWillKeepPrettyJsonInsideTheStandardCommandLogOutput(): vo
343339

344340
return TestsCommand::SUCCESS;
345341
})->shouldBeCalled();
346-
$this->logger->info('Running PHPUnit tests...', Argument::that(
347-
static fn(array $context): bool => $context['input'] instanceof InputInterface
348-
))->shouldBeCalled();
342+
$this->logger->info(Argument::cetera())->shouldNotBeCalled();
349343
$this->logger->log(
350344
'info',
351345
'PHPUnit tests completed successfully.',
@@ -384,9 +378,7 @@ public function executeWillCaptureStructuredPhpUnitSummaryAfterCoveragePreludeWh
384378

385379
return TestsCommand::SUCCESS;
386380
})->shouldBeCalled();
387-
$this->logger->info('Running PHPUnit tests...', Argument::that(
388-
static fn(array $context): bool => $context['input'] instanceof InputInterface
389-
))->shouldBeCalled();
381+
$this->logger->info(Argument::cetera())->shouldNotBeCalled();
390382
$this->logger->log(
391383
'info',
392384
'PHPUnit tests completed successfully.',
@@ -424,9 +416,7 @@ public function executeWillKeepRawPhpUnitOutputWhenStructuredSummaryCannotBeDeco
424416

425417
return TestsCommand::SUCCESS;
426418
})->shouldBeCalled();
427-
$this->logger->info('Running PHPUnit tests...', Argument::that(
428-
static fn(array $context): bool => $context['input'] instanceof InputInterface
429-
))->shouldBeCalled();
419+
$this->logger->info(Argument::cetera())->shouldNotBeCalled();
430420
$this->logger->log(
431421
'info',
432422
'PHPUnit tests completed successfully.',
@@ -604,9 +594,7 @@ public function executeWillEmitStructuredCoverageFailurePayloadWhenMinimumCovera
604594

605595
return TestsCommand::SUCCESS;
606596
})->shouldBeCalled();
607-
$this->logger->info('Running PHPUnit tests...', Argument::that(
608-
static fn(array $context): bool => $context['input'] instanceof InputInterface
609-
))->shouldBeCalled();
597+
$this->logger->info(Argument::cetera())->shouldNotBeCalled();
610598
$this->logger->log(Argument::cetera())->shouldNotBeCalled();
611599
$this->logger->error(
612600
'Minimum line coverage of 80.00% was not met. Current coverage: 75.00% (75/100 lines).',

0 commit comments

Comments
 (0)