Skip to content

Commit

Permalink
Implement --no-results (to complement --no-progress) and refactor pro…
Browse files Browse the repository at this point in the history
…gress printer and result printer selection
  • Loading branch information
sebastianbergmann committed Sep 29, 2022
1 parent 75ef0d8 commit 6770c48
Show file tree
Hide file tree
Showing 10 changed files with 131 additions and 21 deletions.
3 changes: 2 additions & 1 deletion ChangeLog-10.0.md
Expand Up @@ -17,7 +17,8 @@ All notable changes of the PHPUnit 10.0 release series are documented in this fi
* `#[ExcludeStaticPropertyFromBackup('className', 'propertyName')]` attribute for excluding a static property from the backup/restore of static properties in user-defined classes
* `--log-events-text <file>` option that controls streaming of event information (without event telemetry) in text format to a file
* `--log-events-verbose-text <file>` option that controls streaming of event information (with event telemetry) in text format to a file
* `--no-progress` option to disable the progress output
* `--no-progress` option to disable test execution progress output
* `--no-results` option to disable test result output
* `--no-output` option to disable all output
* `--display-incomplete` option and `displayDetailsOnIncompleteTests` XML configuration attribute to control whether details on incomplete tests should be displayed
* `--display-skipped` option and `displayDetailsOnSkippedTests` XML configuration attribute to control whether details on skipped tests should be displayed
Expand Down
8 changes: 8 additions & 0 deletions src/TextUI/Configuration/Cli/Builder.php
Expand Up @@ -77,6 +77,7 @@ final class Builder
'no-extensions',
'no-output',
'no-progress',
'no-results',
'order-by=',
'process-isolation',
'repeat=',
Expand Down Expand Up @@ -195,6 +196,7 @@ public function fromParameters(array $parameters, array $additionalLongOptions):
$noExtensions = null;
$noOutput = null;
$noProgress = null;
$noResults = null;
$noLogging = null;
$processIsolation = null;
$randomOrderSeed = null;
Expand Down Expand Up @@ -619,6 +621,11 @@ public function fromParameters(array $parameters, array $additionalLongOptions):

break;

case '--no-results':
$noResults = true;

break;

case '--globals-backup':
$backupGlobals = true;

Expand Down Expand Up @@ -824,6 +831,7 @@ public function fromParameters(array $parameters, array $additionalLongOptions):
$noExtensions,
$noOutput,
$noProgress,
$noResults,
$noLogging,
$processIsolation,
$randomOrderSeed,
Expand Down
24 changes: 23 additions & 1 deletion src/TextUI/Configuration/Cli/Configuration.php
Expand Up @@ -72,6 +72,7 @@ final class Configuration
private readonly ?bool $noExtensions;
private readonly ?bool $noOutput;
private readonly ?bool $noProgress;
private readonly ?bool $noResults;
private readonly ?bool $noLogging;
private readonly ?bool $processIsolation;
private readonly ?int $randomOrderSeed;
Expand Down Expand Up @@ -109,7 +110,7 @@ final class Configuration
private readonly ?string $logEventsText;
private readonly ?string $logEventsVerboseText;

public function __construct(?string $argument, ?string $atLeastVersion, ?bool $backupGlobals, ?bool $backupStaticProperties, ?bool $beStrictAboutChangesToGlobalState, ?string $bootstrap, ?string $cacheDirectory, ?bool $cacheResult, ?string $cacheResultFile, ?bool $checkVersion, ?string $colors, null|int|string $columns, ?string $configuration, ?string $coverageClover, ?string $coverageCobertura, ?string $coverageCrap4J, ?string $coverageHtml, ?string $coveragePhp, ?string $coverageText, ?bool $coverageTextShowUncoveredFiles, ?bool $coverageTextShowOnlySummary, ?string $coverageXml, ?bool $pathCoverage, ?string $coverageCacheDirectory, ?bool $warmCoverageCache, ?int $defaultTimeLimit, ?bool $disableCodeCoverageIgnore, ?bool $disallowTestOutput, ?bool $enforceTimeLimit, ?array $excludeGroups, ?int $executionOrder, ?int $executionOrderDefects, ?bool $failOnEmptyTestSuite, ?bool $failOnIncomplete, ?bool $failOnRisky, ?bool $failOnSkipped, ?bool $failOnWarning, ?string $filter, ?bool $generateConfiguration, ?bool $migrateConfiguration, ?array $groups, ?array $testsCovering, ?array $testsUsing, ?bool $help, ?string $includePath, ?array $iniSettings, ?string $junitLogfile, ?bool $listGroups, ?bool $listSuites, ?bool $listTests, ?string $listTestsXml, ?bool $noCoverage, ?bool $noExtensions, ?bool $noOutput, ?bool $noProgress, ?bool $noLogging, ?bool $processIsolation, ?int $randomOrderSeed, ?int $repeat, ?bool $reportUselessTests, ?bool $resolveDependencies, ?bool $reverseList, ?bool $stderr, ?bool $strictCoverage, ?bool $stopOnDefect, ?bool $stopOnError, ?bool $stopOnFailure, ?bool $stopOnIncomplete, ?bool $stopOnRisky, ?bool $stopOnSkipped, ?bool $stopOnWarning, ?string $teamcityLogfile, ?string $testdoxHtmlFile, ?string $testdoxTextFile, ?string $testdoxXmlFile, ?array $testSuffixes, ?string $testSuite, ?string $excludeTestSuite, ?string $unrecognizedOrderBy, ?bool $useDefaultConfiguration, ?bool $displayDetailsOnIncompleteTests, ?bool $displayDetailsOnSkippedTests, ?bool $displayDetailsOnTestsThatTriggerDeprecations, ?bool $displayDetailsOnTestsThatTriggerErrors, ?bool $displayDetailsOnTestsThatTriggerNotices, ?bool $displayDetailsOnTestsThatTriggerWarnings, ?bool $version, ?array $coverageFilter, ?string $logEventsText, ?string $logEventsVerboseText, ?bool $printerTeamCity, ?bool $printerTestDox)
public function __construct(?string $argument, ?string $atLeastVersion, ?bool $backupGlobals, ?bool $backupStaticProperties, ?bool $beStrictAboutChangesToGlobalState, ?string $bootstrap, ?string $cacheDirectory, ?bool $cacheResult, ?string $cacheResultFile, ?bool $checkVersion, ?string $colors, null|int|string $columns, ?string $configuration, ?string $coverageClover, ?string $coverageCobertura, ?string $coverageCrap4J, ?string $coverageHtml, ?string $coveragePhp, ?string $coverageText, ?bool $coverageTextShowUncoveredFiles, ?bool $coverageTextShowOnlySummary, ?string $coverageXml, ?bool $pathCoverage, ?string $coverageCacheDirectory, ?bool $warmCoverageCache, ?int $defaultTimeLimit, ?bool $disableCodeCoverageIgnore, ?bool $disallowTestOutput, ?bool $enforceTimeLimit, ?array $excludeGroups, ?int $executionOrder, ?int $executionOrderDefects, ?bool $failOnEmptyTestSuite, ?bool $failOnIncomplete, ?bool $failOnRisky, ?bool $failOnSkipped, ?bool $failOnWarning, ?string $filter, ?bool $generateConfiguration, ?bool $migrateConfiguration, ?array $groups, ?array $testsCovering, ?array $testsUsing, ?bool $help, ?string $includePath, ?array $iniSettings, ?string $junitLogfile, ?bool $listGroups, ?bool $listSuites, ?bool $listTests, ?string $listTestsXml, ?bool $noCoverage, ?bool $noExtensions, ?bool $noOutput, ?bool $noProgress, ?bool $noResults, ?bool $noLogging, ?bool $processIsolation, ?int $randomOrderSeed, ?int $repeat, ?bool $reportUselessTests, ?bool $resolveDependencies, ?bool $reverseList, ?bool $stderr, ?bool $strictCoverage, ?bool $stopOnDefect, ?bool $stopOnError, ?bool $stopOnFailure, ?bool $stopOnIncomplete, ?bool $stopOnRisky, ?bool $stopOnSkipped, ?bool $stopOnWarning, ?string $teamcityLogfile, ?string $testdoxHtmlFile, ?string $testdoxTextFile, ?string $testdoxXmlFile, ?array $testSuffixes, ?string $testSuite, ?string $excludeTestSuite, ?string $unrecognizedOrderBy, ?bool $useDefaultConfiguration, ?bool $displayDetailsOnIncompleteTests, ?bool $displayDetailsOnSkippedTests, ?bool $displayDetailsOnTestsThatTriggerDeprecations, ?bool $displayDetailsOnTestsThatTriggerErrors, ?bool $displayDetailsOnTestsThatTriggerNotices, ?bool $displayDetailsOnTestsThatTriggerWarnings, ?bool $version, ?array $coverageFilter, ?string $logEventsText, ?string $logEventsVerboseText, ?bool $printerTeamCity, ?bool $printerTestDox)
{
$this->argument = $argument;
$this->atLeastVersion = $atLeastVersion;
Expand Down Expand Up @@ -167,6 +168,7 @@ public function __construct(?string $argument, ?string $atLeastVersion, ?bool $b
$this->noExtensions = $noExtensions;
$this->noOutput = $noOutput;
$this->noProgress = $noProgress;
$this->noResults = $noResults;
$this->noLogging = $noLogging;
$this->processIsolation = $processIsolation;
$this->randomOrderSeed = $randomOrderSeed;
Expand Down Expand Up @@ -1325,6 +1327,26 @@ public function noProgress(): bool
return $this->noProgress;
}

/**
* @psalm-assert-if-true !null $this->noResults
*/
public function hasNoResults(): bool
{
return $this->noResults !== null;
}

/**
* @throws Exception
*/
public function noResults(): bool
{
if ($this->noResults === null) {
throw new Exception;
}

return $this->noResults;
}

/**
* @psalm-assert-if-true !null $this->noLogging
*/
Expand Down
23 changes: 15 additions & 8 deletions src/TextUI/Configuration/Configuration.php
Expand Up @@ -95,6 +95,8 @@ final class Configuration
private bool $requireCoverageMetadata;
private bool $registerMockObjectsFromTestArgumentsRecursively;
private bool $noProgress;
private bool $noResults;
private bool $noOutput;
private int $executionOrder;
private int $executionOrderDefects;
private bool $resolveDependencies;
Expand All @@ -108,7 +110,6 @@ final class Configuration
private ?string $logEventsVerboseText;
private ?array $testsCovering;
private ?array $testsUsing;
private bool $defaultOutput;
private bool $teamCityOutput;
private bool $testDoxOutput;
private int $repeat;
Expand All @@ -123,7 +124,7 @@ final class Configuration
/**
* @psalm-param list<array{className: class-string, parameters: array<string, string>}> $extensionBootstrappers
*/
public function __construct(?string $configurationFile, ?string $bootstrap, bool $cacheResult, ?string $cacheDirectory, ?string $coverageCacheDirectory, 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 $failOnEmptyTestSuite, bool $failOnIncomplete, bool $failOnRisky, bool $failOnSkipped, bool $failOnWarning, bool $outputToStandardErrorStream, int|string $columns, bool $tooFewColumnsRequested, bool $loadPharExtensions, ?string $pharExtensionDirectory, array $extensionBootstrappers, bool $backupGlobals, bool $backupStaticProperties, bool $beStrictAboutChangesToGlobalState, bool $colors, bool $processIsolation, bool $stopOnDefect, bool $stopOnError, bool $stopOnFailure, bool $stopOnWarning, bool $stopOnIncomplete, bool $stopOnRisky, bool $stopOnSkipped, bool $enforceTimeLimit, int $defaultTimeLimit, int $timeoutForSmallTests, int $timeoutForMediumTests, int $timeoutForLargeTests, bool $reportUselessTests, bool $strictCoverage, bool $disallowTestOutput, bool $displayDetailsOnIncompleteTests, bool $displayDetailsOnSkippedTests, bool $displayDetailsOnTestsThatTriggerDeprecations, bool $displayDetailsOnTestsThatTriggerErrors, bool $displayDetailsOnTestsThatTriggerNotices, bool $displayDetailsOnTestsThatTriggerWarnings, bool $reverseDefectList, bool $requireCoverageMetadata, bool $registerMockObjectsFromTestArgumentsRecursively, bool $noProgress, int $executionOrder, int $executionOrderDefects, bool $resolveDependencies, ?string $logfileText, ?string $logfileTeamcity, ?string $logfileJunit, ?string $logfileTestdoxHtml, ?string $logfileTestdoxText, ?string $logfileTestdoxXml, ?string $logEventsText, ?string $logEventsVerboseText, bool $defaultOutput, bool $teamCityOutput, bool $testDoxOutput, int $repeat, ?array $testsCovering, ?array $testsUsing, ?string $filter, ?array $groups, ?array $excludeGroups, ?string $includePath, int $randomOrderSeed, bool $includeUncoveredFiles, ?string $xmlValidationErrors)
public function __construct(?string $configurationFile, ?string $bootstrap, bool $cacheResult, ?string $cacheDirectory, ?string $coverageCacheDirectory, 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 $failOnEmptyTestSuite, bool $failOnIncomplete, bool $failOnRisky, bool $failOnSkipped, bool $failOnWarning, bool $outputToStandardErrorStream, int|string $columns, bool $tooFewColumnsRequested, bool $loadPharExtensions, ?string $pharExtensionDirectory, array $extensionBootstrappers, bool $backupGlobals, bool $backupStaticProperties, bool $beStrictAboutChangesToGlobalState, bool $colors, bool $processIsolation, bool $stopOnDefect, bool $stopOnError, bool $stopOnFailure, bool $stopOnWarning, bool $stopOnIncomplete, bool $stopOnRisky, bool $stopOnSkipped, bool $enforceTimeLimit, int $defaultTimeLimit, int $timeoutForSmallTests, int $timeoutForMediumTests, int $timeoutForLargeTests, bool $reportUselessTests, bool $strictCoverage, bool $disallowTestOutput, bool $displayDetailsOnIncompleteTests, bool $displayDetailsOnSkippedTests, bool $displayDetailsOnTestsThatTriggerDeprecations, bool $displayDetailsOnTestsThatTriggerErrors, bool $displayDetailsOnTestsThatTriggerNotices, bool $displayDetailsOnTestsThatTriggerWarnings, bool $reverseDefectList, bool $requireCoverageMetadata, bool $registerMockObjectsFromTestArgumentsRecursively, bool $noProgress, bool $noResults, bool $noOutput, int $executionOrder, int $executionOrderDefects, bool $resolveDependencies, ?string $logfileText, ?string $logfileTeamcity, ?string $logfileJunit, ?string $logfileTestdoxHtml, ?string $logfileTestdoxText, ?string $logfileTestdoxXml, ?string $logEventsText, ?string $logEventsVerboseText, bool $teamCityOutput, bool $testDoxOutput, int $repeat, ?array $testsCovering, ?array $testsUsing, ?string $filter, ?array $groups, ?array $excludeGroups, ?string $includePath, int $randomOrderSeed, bool $includeUncoveredFiles, ?string $xmlValidationErrors)
{
$this->configurationFile = $configurationFile;
$this->bootstrap = $bootstrap;
Expand Down Expand Up @@ -193,6 +194,8 @@ public function __construct(?string $configurationFile, ?string $bootstrap, bool
$this->requireCoverageMetadata = $requireCoverageMetadata;
$this->registerMockObjectsFromTestArgumentsRecursively = $registerMockObjectsFromTestArgumentsRecursively;
$this->noProgress = $noProgress;
$this->noResults = $noResults;
$this->noOutput = $noOutput;
$this->executionOrder = $executionOrder;
$this->executionOrderDefects = $executionOrderDefects;
$this->resolveDependencies = $resolveDependencies;
Expand All @@ -204,7 +207,6 @@ public function __construct(?string $configurationFile, ?string $bootstrap, bool
$this->logfileTestdoxXml = $logfileTestdoxXml;
$this->logEventsText = $logEventsText;
$this->logEventsVerboseText = $logEventsVerboseText;
$this->defaultOutput = $defaultOutput;
$this->teamCityOutput = $teamCityOutput;
$this->testDoxOutput = $testDoxOutput;
$this->repeat = $repeat;
Expand Down Expand Up @@ -768,6 +770,16 @@ public function noProgress(): bool
return $this->noProgress;
}

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

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

public function executionOrder(): int
{
return $this->executionOrder;
Expand Down Expand Up @@ -943,11 +955,6 @@ public function logEventsVerboseText(): string
return $this->logEventsVerboseText;
}

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

public function outputIsTeamCity(): bool
{
return $this->teamCityOutput;
Expand Down
27 changes: 19 additions & 8 deletions src/TextUI/Configuration/Merger.php
Expand Up @@ -524,18 +524,16 @@ public function merge(CliConfiguration $cliConfiguration, XmlConfiguration $xmlC
$logEventsVerboseText = $cliConfiguration->logEventsVerboseText();
}

$defaultOutput = true;
$teamCityOutput = false;
$testDoxOutput = false;

if ($cliConfiguration->hasTeamCityPrinter() && $cliConfiguration->teamCityPrinter()) {
$teamCityOutput = true;
$defaultOutput = false;
} elseif ($cliConfiguration->hasTestDoxPrinter() && $cliConfiguration->testdoxPrinter()) {
}

$testDoxOutput = false;

if ($cliConfiguration->hasTestDoxPrinter() && $cliConfiguration->testdoxPrinter()) {
$testDoxOutput = true;
$defaultOutput = false;
} elseif ($cliConfiguration->hasNoOutput() && $cliConfiguration->noOutput()) {
$defaultOutput = false;
}

$noProgress = false;
Expand All @@ -544,6 +542,18 @@ public function merge(CliConfiguration $cliConfiguration, XmlConfiguration $xmlC
$noProgress = true;
}

$noResults = false;

if ($cliConfiguration->hasNoResults() && $cliConfiguration->noResults()) {
$noResults = true;
}

$noOutput = false;

if ($cliConfiguration->hasNoOutput() && $cliConfiguration->noOutput()) {
$noOutput = true;
}

$repeat = 0;

if ($cliConfiguration->hasRepeat()) {
Expand Down Expand Up @@ -679,6 +689,8 @@ public function merge(CliConfiguration $cliConfiguration, XmlConfiguration $xmlC
$requireCoverageMetadata,
$registerMockObjectsFromTestArgumentsRecursively,
$noProgress,
$noResults,
$noOutput,
$executionOrder,
$executionOrderDefects,
$resolveDependencies,
Expand All @@ -690,7 +702,6 @@ public function merge(CliConfiguration $cliConfiguration, XmlConfiguration $xmlC
$logfileTestdoxXml,
$logEventsText,
$logEventsVerboseText,
$defaultOutput,
$teamCityOutput,
$testDoxOutput,
$repeat,
Expand Down
1 change: 1 addition & 0 deletions src/TextUI/Help.php
Expand Up @@ -109,6 +109,7 @@ final class Help
['spacer' => ''],

['arg' => '--no-progress', 'desc' => 'Disable output of test execution progress'],
['arg' => '--no-results', 'desc' => 'Disable output of test results'],
['arg' => '--no-output', 'desc' => 'Disable all output'],
['spacer' => ''],

Expand Down

0 comments on commit 6770c48

Please sign in to comment.