Skip to content

Commit

Permalink
Revert "Closes #5952"
Browse files Browse the repository at this point in the history
This reverts commit 1964ae3.
  • Loading branch information
sebastianbergmann committed Feb 13, 2025
1 parent 18b9ed6 commit e743ec6
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 2 deletions.
1 change: 1 addition & 0 deletions ChangeLog-12.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ All notable changes of the PHPUnit 12.0 release series are documented in this fi

### Fixed

* [#5951](https://github.com/sebastianbergmann/phpunit/issues/5951#issuecomment-2656364815): Restore the `includeUncoveredFiles` configuration option
* A `Test\Passed` event is no longer emitted in addition to a `Test\Failed` or `Test\Errored` event when an assertion failure or an unexpected exception is triggered in an after-test method
* A `TestSuite\Finished` event is now emitted when a before-first-test method errors

Expand Down
6 changes: 6 additions & 0 deletions src/Runner/CodeCoverage.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ public function init(Configuration $configuration, CodeCoverageFilterRegistry $c
$this->codeCoverage()->enableAnnotationsForIgnoringCode();
}

if ($configuration->includeUncoveredFiles()) {
$this->codeCoverage()->includeUncoveredFiles();
} else {
$this->codeCoverage()->excludeUncoveredFiles();
}

if ($codeCoverageFilterRegistry->get()->isEmpty()) {
if (!$codeCoverageFilterRegistry->configured()) {
EventFacade::emitter()->testRunnerTriggeredWarning(
Expand Down
9 changes: 8 additions & 1 deletion src/TextUI/Configuration/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@
*/
private array $excludeGroups;
private int $randomOrderSeed;
private bool $includeUncoveredFiles;
private TestSuiteCollection $testSuite;
private string $includeTestSuite;
private string $excludeTestSuite;
Expand Down Expand Up @@ -186,7 +187,7 @@
* @param null|non-empty-string $generateBaseline
* @param non-negative-int $shortenArraysForExportThreshold
*/
public function __construct(array $cliArguments, ?string $configurationFile, ?string $bootstrap, bool $cacheResult, ?string $cacheDirectory, ?string $coverageCacheDirectory, Source $source, string $testResultCacheFile, ?string $coverageClover, ?string $coverageCobertura, ?string $coverageCrap4j, int $coverageCrap4jThreshold, ?string $coverageHtml, int $coverageHtmlLowUpperBound, int $coverageHtmlHighLowerBound, string $coverageHtmlColorSuccessLow, string $coverageHtmlColorSuccessMedium, string $coverageHtmlColorSuccessHigh, string $coverageHtmlColorWarning, string $coverageHtmlColorDanger, ?string $coverageHtmlCustomCssFile, ?string $coveragePhp, ?string $coverageText, bool $coverageTextShowUncoveredFiles, bool $coverageTextShowOnlySummary, ?string $coverageXml, bool $pathCoverage, bool $ignoreDeprecatedCodeUnitsFromCodeCoverage, bool $disableCodeCoverageIgnore, bool $failOnDeprecation, bool $failOnPhpunitDeprecation, bool $failOnEmptyTestSuite, bool $failOnIncomplete, bool $failOnNotice, bool $failOnRisky, bool $failOnSkipped, bool $failOnWarning, bool $stopOnDefect, bool $stopOnDeprecation, ?string $specificDeprecationToStopOn, bool $stopOnError, bool $stopOnFailure, bool $stopOnIncomplete, bool $stopOnNotice, bool $stopOnRisky, bool $stopOnSkipped, bool $stopOnWarning, bool $outputToStandardErrorStream, int $columns, bool $noExtensions, ?string $pharExtensionDirectory, array $extensionBootstrappers, bool $backupGlobals, bool $backupStaticProperties, bool $beStrictAboutChangesToGlobalState, bool $colors, bool $processIsolation, bool $enforceTimeLimit, int $defaultTimeLimit, int $timeoutForSmallTests, int $timeoutForMediumTests, int $timeoutForLargeTests, bool $reportUselessTests, bool $strictCoverage, bool $disallowTestOutput, bool $displayDetailsOnIncompleteTests, bool $displayDetailsOnSkippedTests, bool $displayDetailsOnTestsThatTriggerDeprecations, bool $displayDetailsOnPhpunitDeprecations, bool $displayDetailsOnTestsThatTriggerErrors, bool $displayDetailsOnTestsThatTriggerNotices, bool $displayDetailsOnTestsThatTriggerWarnings, bool $reverseDefectList, bool $requireCoverageMetadata, bool $noProgress, bool $noResults, bool $noOutput, int $executionOrder, int $executionOrderDefects, bool $resolveDependencies, ?string $logfileTeamcity, ?string $logfileJunit, ?string $logfileTestdoxHtml, ?string $logfileTestdoxText, ?string $logEventsText, ?string $logEventsVerboseText, bool $teamCityOutput, bool $testDoxOutput, bool $testDoxOutputSummary, ?array $testsCovering, ?array $testsUsing, ?array $testsRequiringPhpExtension, ?string $filter, ?string $excludeFilter, array $groups, array $excludeGroups, int $randomOrderSeed, TestSuiteCollection $testSuite, string $includeTestSuite, string $excludeTestSuite, ?string $defaultTestSuite, array $testSuffixes, Php $php, bool $controlGarbageCollector, int $numberOfTestsBeforeGarbageCollection, ?string $generateBaseline, bool $debug, int $shortenArraysForExportThreshold)
public function __construct(array $cliArguments, ?string $configurationFile, ?string $bootstrap, bool $cacheResult, ?string $cacheDirectory, ?string $coverageCacheDirectory, Source $source, string $testResultCacheFile, ?string $coverageClover, ?string $coverageCobertura, ?string $coverageCrap4j, int $coverageCrap4jThreshold, ?string $coverageHtml, int $coverageHtmlLowUpperBound, int $coverageHtmlHighLowerBound, string $coverageHtmlColorSuccessLow, string $coverageHtmlColorSuccessMedium, string $coverageHtmlColorSuccessHigh, string $coverageHtmlColorWarning, string $coverageHtmlColorDanger, ?string $coverageHtmlCustomCssFile, ?string $coveragePhp, ?string $coverageText, bool $coverageTextShowUncoveredFiles, bool $coverageTextShowOnlySummary, ?string $coverageXml, bool $pathCoverage, bool $ignoreDeprecatedCodeUnitsFromCodeCoverage, bool $disableCodeCoverageIgnore, bool $failOnDeprecation, bool $failOnPhpunitDeprecation, bool $failOnEmptyTestSuite, bool $failOnIncomplete, bool $failOnNotice, bool $failOnRisky, bool $failOnSkipped, bool $failOnWarning, bool $stopOnDefect, bool $stopOnDeprecation, ?string $specificDeprecationToStopOn, bool $stopOnError, bool $stopOnFailure, bool $stopOnIncomplete, bool $stopOnNotice, bool $stopOnRisky, bool $stopOnSkipped, bool $stopOnWarning, bool $outputToStandardErrorStream, int $columns, bool $noExtensions, ?string $pharExtensionDirectory, array $extensionBootstrappers, bool $backupGlobals, bool $backupStaticProperties, bool $beStrictAboutChangesToGlobalState, bool $colors, bool $processIsolation, bool $enforceTimeLimit, int $defaultTimeLimit, int $timeoutForSmallTests, int $timeoutForMediumTests, int $timeoutForLargeTests, bool $reportUselessTests, bool $strictCoverage, bool $disallowTestOutput, bool $displayDetailsOnIncompleteTests, bool $displayDetailsOnSkippedTests, bool $displayDetailsOnTestsThatTriggerDeprecations, bool $displayDetailsOnPhpunitDeprecations, bool $displayDetailsOnTestsThatTriggerErrors, bool $displayDetailsOnTestsThatTriggerNotices, bool $displayDetailsOnTestsThatTriggerWarnings, bool $reverseDefectList, bool $requireCoverageMetadata, bool $noProgress, bool $noResults, bool $noOutput, int $executionOrder, int $executionOrderDefects, bool $resolveDependencies, ?string $logfileTeamcity, ?string $logfileJunit, ?string $logfileTestdoxHtml, ?string $logfileTestdoxText, ?string $logEventsText, ?string $logEventsVerboseText, bool $teamCityOutput, bool $testDoxOutput, bool $testDoxOutputSummary, ?array $testsCovering, ?array $testsUsing, ?array $testsRequiringPhpExtension, ?string $filter, ?string $excludeFilter, array $groups, array $excludeGroups, int $randomOrderSeed, bool $includeUncoveredFiles, TestSuiteCollection $testSuite, string $includeTestSuite, string $excludeTestSuite, ?string $defaultTestSuite, array $testSuffixes, Php $php, bool $controlGarbageCollector, int $numberOfTestsBeforeGarbageCollection, ?string $generateBaseline, bool $debug, int $shortenArraysForExportThreshold)
{
$this->cliArguments = $cliArguments;
$this->configurationFile = $configurationFile;
Expand Down Expand Up @@ -285,6 +286,7 @@ public function __construct(array $cliArguments, ?string $configurationFile, ?st
$this->groups = $groups;
$this->excludeGroups = $excludeGroups;
$this->randomOrderSeed = $randomOrderSeed;
$this->includeUncoveredFiles = $includeUncoveredFiles;
$this->testSuite = $testSuite;
$this->includeTestSuite = $includeTestSuite;
$this->excludeTestSuite = $excludeTestSuite;
Expand Down Expand Up @@ -1225,6 +1227,11 @@ public function randomOrderSeed(): int
return $this->randomOrderSeed;
}

public function includeUncoveredFiles(): bool
{
return $this->includeUncoveredFiles;
}

public function testSuite(): TestSuiteCollection
{
return $this->testSuite;
Expand Down
3 changes: 3 additions & 0 deletions src/TextUI/Configuration/Merger.php
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,8 @@ public function merge(CliConfiguration $cliConfiguration, XmlConfiguration $xmlC
}
}

$includeUncoveredFiles = $xmlConfiguration->codeCoverage()->includeUncoveredFiles();

$includePaths = [];

if ($cliConfiguration->hasIncludePath()) {
Expand Down Expand Up @@ -889,6 +891,7 @@ public function merge(CliConfiguration $cliConfiguration, XmlConfiguration $xmlC
$groups,
$excludeGroups,
$randomOrderSeed,
$includeUncoveredFiles,
$xmlConfiguration->testSuite(),
$includeTestSuite,
$excludeTestSuite,
Expand Down
9 changes: 8 additions & 1 deletion src/TextUI/Configuration/Xml/CodeCoverage/CodeCoverage.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
final readonly class CodeCoverage
{
private bool $pathCoverage;
private bool $includeUncoveredFiles;
private bool $ignoreDeprecatedCodeUnits;
private bool $disableCodeCoverageIgnore;
private ?Clover $clover;
Expand All @@ -38,9 +39,10 @@
private ?Text $text;
private ?Xml $xml;

public function __construct(bool $pathCoverage, bool $ignoreDeprecatedCodeUnits, bool $disableCodeCoverageIgnore, ?Clover $clover, ?Cobertura $cobertura, ?Crap4j $crap4j, ?Html $html, ?Php $php, ?Text $text, ?Xml $xml)
public function __construct(bool $pathCoverage, bool $includeUncoveredFiles, bool $ignoreDeprecatedCodeUnits, bool $disableCodeCoverageIgnore, ?Clover $clover, ?Cobertura $cobertura, ?Crap4j $crap4j, ?Html $html, ?Php $php, ?Text $text, ?Xml $xml)
{
$this->pathCoverage = $pathCoverage;
$this->includeUncoveredFiles = $includeUncoveredFiles;
$this->ignoreDeprecatedCodeUnits = $ignoreDeprecatedCodeUnits;
$this->disableCodeCoverageIgnore = $disableCodeCoverageIgnore;
$this->clover = $clover;
Expand All @@ -57,6 +59,11 @@ public function pathCoverage(): bool
return $this->pathCoverage;
}

public function includeUncoveredFiles(): bool
{
return $this->includeUncoveredFiles;
}

public function ignoreDeprecatedCodeUnits(): bool
{
return $this->ignoreDeprecatedCodeUnits;
Expand Down
1 change: 1 addition & 0 deletions src/TextUI/Configuration/Xml/DefaultConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public static function create(): self
),
new CodeCoverage(
false,
true,
false,
false,
null,
Expand Down
8 changes: 8 additions & 0 deletions src/TextUI/Configuration/Xml/Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ private function source(string $filename, DOMXPath $xpath): Source
private function codeCoverage(string $filename, DOMXPath $xpath): CodeCoverage
{
$pathCoverage = false;
$includeUncoveredFiles = true;
$ignoreDeprecatedCodeUnits = false;
$disableCodeCoverageIgnore = false;

Expand All @@ -363,6 +364,12 @@ private function codeCoverage(string $filename, DOMXPath $xpath): CodeCoverage
false,
);

$includeUncoveredFiles = $this->getBooleanAttribute(
$element,
'includeUncoveredFiles',
true,
);

$ignoreDeprecatedCodeUnits = $this->getBooleanAttribute(
$element,
'ignoreDeprecatedCodeUnits',
Expand Down Expand Up @@ -490,6 +497,7 @@ private function codeCoverage(string $filename, DOMXPath $xpath): CodeCoverage

return new CodeCoverage(
$pathCoverage,
$includeUncoveredFiles,
$ignoreDeprecatedCodeUnits,
$disableCodeCoverageIgnore,
$clover,
Expand Down
1 change: 1 addition & 0 deletions tests/unit/TextUI/Configuration/Xml/LoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ public function testCodeCoverageConfigurationIsReadCorrectly(): void
$codeCoverage = $this->configuration('configuration_codecoverage.xml')->codeCoverage();

$this->assertTrue($codeCoverage->pathCoverage());
$this->assertTrue($codeCoverage->includeUncoveredFiles());
$this->assertTrue($codeCoverage->ignoreDeprecatedCodeUnits());
$this->assertTrue($codeCoverage->disableCodeCoverageIgnore());

Expand Down

0 comments on commit e743ec6

Please sign in to comment.