This commit is contained in:
nuno maduro
2026-05-01 15:19:19 +01:00
parent 5c3cbc14d2
commit 3802fa80e6

View File

@ -883,10 +883,24 @@ final class Tia implements AddsOutput, HandlesArguments, Terminable
return; return;
} }
// Failures that overlap with the change-driven set are already
// pulled in by edges — don't double-count them as a separate
// reason in the breakdown.
$newFailures = $failedFromCache === []
? 0
: count(array_diff($failedFromCache, $affectedFromChanges));
$reasons = []; $reasons = [];
$singleReason = (int) ($affectedFromChanges !== []) + (int) ($newFailures > 0) === 1;
if ($affectedFromChanges !== []) { if ($affectedFromChanges !== []) {
$reasons[] = sprintf( $reasons[] = $singleReason
? sprintf(
'from %d changed file%s',
count($changedFiles),
count($changedFiles) === 1 ? '' : 's',
)
: sprintf(
'%d from %d changed file%s', '%d from %d changed file%s',
count($affectedFromChanges), count($affectedFromChanges),
count($changedFiles), count($changedFiles),
@ -894,22 +908,22 @@ final class Tia implements AddsOutput, HandlesArguments, Terminable
); );
} }
// Failures that overlap with the change-driven set are already
// counted there — don't double-count them in the breakdown.
$newFailures = $failedFromCache === []
? 0
: count(array_diff($failedFromCache, $affectedFromChanges));
if ($newFailures > 0) { if ($newFailures > 0) {
$reasons[] = sprintf( $reasons[] = $singleReason
'%d cached failure%s', ? sprintf(
'from %d previous failure%s',
$newFailures,
$newFailures === 1 ? '' : 's',
)
: sprintf(
'%d from previous failure%s',
$newFailures, $newFailures,
$newFailures === 1 ? '' : 's', $newFailures === 1 ? '' : 's',
); );
} }
$this->output->writeln(sprintf( $this->output->writeln(sprintf(
' <fg=cyan>TIA</> %d affected test%s%s.', ' <fg=cyan>TIA</> %d affected test file%s%s.',
count($affected), count($affected),
count($affected) === 1 ? '' : 's', count($affected) === 1 ? '' : 's',
$reasons === [] ? '' : ' ('.implode(', ', $reasons).')', $reasons === [] ? '' : ' ('.implode(', ', $reasons).')',