feat(extension): add default_testsuite_as_full to neutralize partial-run for defaultTestSuite-resolved selection#237
Merged
Conversation
…run for defaultTestSuite-resolved selection When `phpunit.xml` declares `defaultTestSuite`, PHPUnit fills `Configuration::includeTestSuites()` with that name even on a bare `phpunit` run. The #221 partial-run detection therefore marks every such run as partial, which (since #225) silently skips the `strict_required` gate with no way to reach it from the user's default workflow. Add an opt-in `default_testsuite_as_full` parameter (default `false`) that neutralises the `--testsuite` partial signal — but only that signal, and only when `includeTestSuites === [defaultTestSuite]`. Other partial signals (`--filter`, path args, `--group`, …) keep their verdict, so the escape hatch cannot silently relax unrelated selections. Output-persistence skipping (the #221 guarantee) is re-enabled together with the gate, which is the user-chosen trade-off documented in `docs/ci.md`. Closes #236
…te_as_full opt-in Review follow-ups for #237: - WARN when `default_testsuite_as_full=true` but `defaultTestSuite` is absent or empty. Without this, the opt-in is silently inert and users can't tell why their `strict_required` gate still skips. Gated on the opt-in itself so non-opt-in callers stay silent. - New `OpenApiCoverageExtensionBootstrapTest` cases pin the bootstrap wiring end-to-end: opt-in + missing default → WARN, opt-in + empty default → WARN, opt-in + matching default → no WARN, no opt-in even with matching default → no WARN. The subscriber's persistent-write WARN is already exercised by `CoverageReportSubscriberPartialRunTest`. - ASCII-only ci.md heading for the opt-in section so its anchor (`#default_testsuite_as_full-opt-in`) is robust across GitHub renderer versions; setup.md / strict-required.md links re-pointed accordingly.
Collaborator
Author
Follow-up commit (
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
OpenApiCoverageExtensionに opt-in パラメータdefault_testsuite_as_fullを追加。trueかつConfiguration::includeTestSuites()がConfiguration::defaultTestSuite()と完全一致するときだけ--testsuite由来の partial 判定を解除し、strict_requiredゲート等が defaultTestSuite ベースの canonical full run でも到達可能になるようにする。Why
phpunit.xmlにdefaultTestSuiteを宣言しているプロジェクトでは、引数なしのphpunit実行でも PHPUnit がConfiguration::includeTestSuites()にその名前を埋める。結果として #221 の partial 判定が常に立ち、strict_requiredゲート (#225) はユーザーの default workflow からは決して評価されない (常に[OpenAPI Strict Required] NOTE: skipped on partial runs ...のみ)。複数 suite を切っているプロジェクト (
make testで Stripe 統合だけ別 job に分離する等) はdefaultTestSuiteを外せず、phpunit-override 等の二重 config を強いられる状況だった。#236 で議論した 3 案のうち短期推奨の opt-in パラメータ案 (A) を採用。
--testsuitesignal のみを打ち消す scoped escape hatch にすることで、--filter/ path args 等の他 partial signal は引き続き保護する。Fixes #236
Verification
失敗テストを先に追加 (
tests/Unit/Internal/PartialRunDecisionTest.phpの新規 5 ケース) し、PartialRunDecision::fromSignals/OpenApiCoverageExtension::detectPartialRunを実装して green に。composer ci(PHPUnit 1715 / 4029 assertions + PHPStan level 6 + PHP-CS-Fixer dry) すべて pass。手元の studio-api 構成での再現は本 PR では未実施 (本リポジトリの単体テストに反映済み)。Reviewer 側で必要なら issue feat(extension): treat defaultTestSuite-resolved selection as full run for strict_required / coverage gates #236 の再現プロジェクトで
default_testsuite_as_full=trueを設定し、[OpenAPI Strict Required] NOTE: skipped on partial runsが出なくなることを確認できます。composer testpassescomposer stanpassescomposer cs-checkpassesNotes for reviewers
PartialRunDecision::fromSignalsは internal クラスなので、optional 引数 2 つの追加は SemVer 上問題なし (UPGRADING.md の Frozen に該当しない)。既存呼び出しは引数の名前付きで指定されているため、追加位置 (末尾) で破壊しないことを確認済み。default_testsuite_as_full=trueを立てると output_file 等の persistent 書き込みも実行される。defaultTestSuite に含まれない suite (例: 別 job で動かす Integration suite) が抜けた状態のレポートが書かれる点はユーザー側のトレードオフ。docs/ci.mdの新節とdocs/strict-required.mdの Partial-run skipping 節に明記。Configuration::hasDefaultTestSuite()/defaultTestSuite()は PHPUnit 11/12/13 すべてに存在するためreadTestSuiteList()のような dynamic dispatch は不要。hasDefaultTestSuite()の guard はNoDefaultTestSuiteExceptionの throw を避けるために必須。