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

View File

@ -883,33 +883,47 @@ final class Tia implements AddsOutput, HandlesArguments, Terminable
return; return;
} }
$reasons = [];
if ($affectedFromChanges !== []) {
$reasons[] = sprintf(
'%d from %d changed file%s',
count($affectedFromChanges),
count($changedFiles),
count($changedFiles) === 1 ? '' : 's',
);
}
// Failures that overlap with the change-driven set are already // Failures that overlap with the change-driven set are already
// counted there — don't double-count them in the breakdown. // pulled in by edges — don't double-count them as a separate
// reason in the breakdown.
$newFailures = $failedFromCache === [] $newFailures = $failedFromCache === []
? 0 ? 0
: count(array_diff($failedFromCache, $affectedFromChanges)); : count(array_diff($failedFromCache, $affectedFromChanges));
$reasons = [];
$singleReason = (int) ($affectedFromChanges !== []) + (int) ($newFailures > 0) === 1;
if ($affectedFromChanges !== []) {
$reasons[] = $singleReason
? sprintf(
'from %d changed file%s',
count($changedFiles),
count($changedFiles) === 1 ? '' : 's',
)
: sprintf(
'%d from %d changed file%s',
count($affectedFromChanges),
count($changedFiles),
count($changedFiles) === 1 ? '' : 's',
);
}
if ($newFailures > 0) { if ($newFailures > 0) {
$reasons[] = sprintf( $reasons[] = $singleReason
'%d cached failure%s', ? sprintf(
$newFailures, 'from %d previous failure%s',
$newFailures === 1 ? '' : 's', $newFailures,
); $newFailures === 1 ? '' : 's',
)
: sprintf(
'%d from previous failure%s',
$newFailures,
$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).')',