Skip to content

Commit a28dae2

Browse files
Closes #6239
1 parent a2b49aa commit a28dae2

34 files changed

+1629
-291
lines changed

ChangeLog-10.5.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ All notable changes of the PHPUnit 10.5 release series are documented in this fi
66

77
### Added
88

9+
* [#6239](https://github.com/sebastianbergmann/phpunit/issues/6239): `--do-not-fail-on-deprecation`, `--do-not-fail-on-phpunit-deprecation`, `--do-not-fail-on-empty-test-suite`, `--do-not-fail-on-incomplete`, `--do-not-fail-on-notice`, `--do-not-fail-on-risky`, `--do-not-fail-on-skipped`, and `--do-not-fail-on-warning` CLI options
910
* `--do-not-report-useless-tests` CLI option as a replacement for `--dont-report-useless-tests`
1011

1112
### Deprecated

src/TextUI/Configuration/Cli/Builder.php

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,14 @@ final class Builder
112112
'fail-on-risky',
113113
'fail-on-skipped',
114114
'fail-on-warning',
115+
'do-not-fail-on-deprecation',
116+
'do-not-fail-on-phpunit-deprecation',
117+
'do-not-fail-on-empty-test-suite',
118+
'do-not-fail-on-incomplete',
119+
'do-not-fail-on-notice',
120+
'do-not-fail-on-risky',
121+
'do-not-fail-on-skipped',
122+
'do-not-fail-on-warning',
115123
'stop-on-defect',
116124
'stop-on-deprecation',
117125
'stop-on-error',
@@ -211,6 +219,14 @@ public function fromParameters(array $parameters): Configuration
211219
$failOnRisky = null;
212220
$failOnSkipped = null;
213221
$failOnWarning = null;
222+
$doNotFailOnDeprecation = null;
223+
$doNotFailOnPhpunitDeprecation = null;
224+
$doNotFailOnEmptyTestSuite = null;
225+
$doNotFailOnIncomplete = null;
226+
$doNotFailOnNotice = null;
227+
$doNotFailOnRisky = null;
228+
$doNotFailOnSkipped = null;
229+
$doNotFailOnWarning = null;
214230
$stopOnDefect = null;
215231
$stopOnDeprecation = null;
216232
$stopOnError = null;
@@ -579,45 +595,181 @@ public function fromParameters(array $parameters): Configuration
579595
break;
580596

581597
case '--fail-on-deprecation':
598+
$this->warnWhenOptionsConflict(
599+
$doNotFailOnDeprecation,
600+
'--fail-on-deprecation',
601+
'--do-not-fail-on-deprecation',
602+
);
603+
582604
$failOnDeprecation = true;
583605

584606
break;
585607

586608
case '--fail-on-phpunit-deprecation':
609+
$this->warnWhenOptionsConflict(
610+
$doNotFailOnPhpunitDeprecation,
611+
'--fail-on-phpunit-deprecation',
612+
'--do-not-fail-on-phpunit-deprecation',
613+
);
614+
587615
$failOnPhpunitDeprecation = true;
588616

589617
break;
590618

591619
case '--fail-on-empty-test-suite':
620+
$this->warnWhenOptionsConflict(
621+
$doNotFailOnEmptyTestSuite,
622+
'--fail-on-empty-test-suite',
623+
'--do-not-fail-on-empty-test-suite',
624+
);
625+
592626
$failOnEmptyTestSuite = true;
593627

594628
break;
595629

596630
case '--fail-on-incomplete':
631+
$this->warnWhenOptionsConflict(
632+
$doNotFailOnIncomplete,
633+
'--fail-on-incomplete',
634+
'--do-not-fail-on-incomplete',
635+
);
636+
597637
$failOnIncomplete = true;
598638

599639
break;
600640

601641
case '--fail-on-notice':
642+
$this->warnWhenOptionsConflict(
643+
$doNotFailOnNotice,
644+
'--fail-on-notice',
645+
'--do-not-fail-on-notice',
646+
);
647+
602648
$failOnNotice = true;
603649

604650
break;
605651

606652
case '--fail-on-risky':
653+
$this->warnWhenOptionsConflict(
654+
$doNotFailOnRisky,
655+
'--fail-on-risky',
656+
'--do-not-fail-on-risky',
657+
);
658+
607659
$failOnRisky = true;
608660

609661
break;
610662

611663
case '--fail-on-skipped':
664+
$this->warnWhenOptionsConflict(
665+
$doNotFailOnSkipped,
666+
'--fail-on-skipped',
667+
'--do-not-fail-on-skipped',
668+
);
669+
612670
$failOnSkipped = true;
613671

614672
break;
615673

616674
case '--fail-on-warning':
675+
$this->warnWhenOptionsConflict(
676+
$doNotFailOnWarning,
677+
'--fail-on-warning',
678+
'--do-not-fail-on-warning',
679+
);
680+
617681
$failOnWarning = true;
618682

619683
break;
620684

685+
case '--do-not-fail-on-deprecation':
686+
$this->warnWhenOptionsConflict(
687+
$failOnDeprecation,
688+
'--do-not-fail-on-deprecation',
689+
'--fail-on-deprecation',
690+
);
691+
692+
$doNotFailOnDeprecation = true;
693+
694+
break;
695+
696+
case '--do-not-fail-on-phpunit-deprecation':
697+
$this->warnWhenOptionsConflict(
698+
$failOnPhpunitDeprecation,
699+
'--do-not-fail-on-phpunit-deprecation',
700+
'--fail-on-phpunit-deprecation',
701+
);
702+
703+
$doNotFailOnPhpunitDeprecation = true;
704+
705+
break;
706+
707+
case '--do-not-fail-on-empty-test-suite':
708+
$this->warnWhenOptionsConflict(
709+
$failOnEmptyTestSuite,
710+
'--do-not-fail-on-empty-test-suite',
711+
'--fail-on-empty-test-suite',
712+
);
713+
714+
$doNotFailOnEmptyTestSuite = true;
715+
716+
break;
717+
718+
case '--do-not-fail-on-incomplete':
719+
$this->warnWhenOptionsConflict(
720+
$failOnIncomplete,
721+
'--do-not-fail-on-incomplete',
722+
'--fail-on-incomplete',
723+
);
724+
725+
$doNotFailOnIncomplete = true;
726+
727+
break;
728+
729+
case '--do-not-fail-on-notice':
730+
$this->warnWhenOptionsConflict(
731+
$failOnNotice,
732+
'--do-not-fail-on-notice',
733+
'--fail-on-notice',
734+
);
735+
736+
$doNotFailOnNotice = true;
737+
738+
break;
739+
740+
case '--do-not-fail-on-risky':
741+
$this->warnWhenOptionsConflict(
742+
$failOnRisky,
743+
'--do-not-fail-on-risky',
744+
'--fail-on-risky',
745+
);
746+
747+
$doNotFailOnRisky = true;
748+
749+
break;
750+
751+
case '--do-not-fail-on-skipped':
752+
$this->warnWhenOptionsConflict(
753+
$failOnSkipped,
754+
'--do-not-fail-on-skipped',
755+
'--fail-on-skipped',
756+
);
757+
758+
$doNotFailOnSkipped = true;
759+
760+
break;
761+
762+
case '--do-not-fail-on-warning':
763+
$this->warnWhenOptionsConflict(
764+
$failOnWarning,
765+
'--do-not-fail-on-warning',
766+
'--fail-on-warning',
767+
);
768+
769+
$doNotFailOnWarning = true;
770+
771+
break;
772+
621773
case '--stop-on-defect':
622774
$stopOnDefect = true;
623775

@@ -949,6 +1101,14 @@ public function fromParameters(array $parameters): Configuration
9491101
$failOnRisky,
9501102
$failOnSkipped,
9511103
$failOnWarning,
1104+
$doNotFailOnDeprecation,
1105+
$doNotFailOnPhpunitDeprecation,
1106+
$doNotFailOnEmptyTestSuite,
1107+
$doNotFailOnIncomplete,
1108+
$doNotFailOnNotice,
1109+
$doNotFailOnRisky,
1110+
$doNotFailOnSkipped,
1111+
$doNotFailOnWarning,
9521112
$stopOnDefect,
9531113
$stopOnDeprecation,
9541114
$stopOnError,
@@ -1035,4 +1195,22 @@ private function markProcessed(string $option): void
10351195
);
10361196
}
10371197
}
1198+
1199+
/**
1200+
* @psalm-param non-empty-string $option
1201+
*/
1202+
private function warnWhenOptionsConflict(?bool $current, string $option, string $opposite): void
1203+
{
1204+
if ($current === null) {
1205+
return;
1206+
}
1207+
1208+
EventFacade::emitter()->testRunnerTriggeredPhpunitWarning(
1209+
sprintf(
1210+
'Options %s and %s cannot be used together',
1211+
$option,
1212+
$opposite,
1213+
),
1214+
);
1215+
}
10381216
}

0 commit comments

Comments
 (0)