Repository navigation
fix: accept space separated values for --min and --exactly - #1921
Open
YoussefMansour9 wants to merge 1 commit into
Open
YoussefMansour9 wants to merge 1 commit into
YoussefMansour9 wants to merge 1 commit into
Conversation
`--min` and `--exactly` only accepted the `--min=50` notation. When the
space separated notation was used, the plugin kept the `--min` token but
left the `50` token behind, so `ArgvInput` received an option without a
value and threw:
$ pest --coverage --min 50
Symfony\Component\Console\Exception\RuntimeException
The "--min" option requires a value.
The run aborted with an unhandled exception and a stack trace, even
though every other valued option Pest forwards to PHPUnit accepts both
notations (`pest --filter add` works). The orphaned value token was also
forwarded to PHPUnit as a positional argument.
`handleArguments()` now walks the arguments positionally instead of
filtering them, so an option that takes a value also claims the token
that follows it. Value-less options (`--coverage`, `--only-covered`) keep
their current behaviour and never consume the next token, and a bare
`--min` with no value still produces the regular "requires a value"
error rather than swallowing the option that follows it.
MrPunyapal
requested changes
Oct 25, 2026
|
|
||
| $value = $originals[$index + 1] ?? null; | ||
|
|
||
| if ($requiresValue && $value !== null && ! Str::startsWith($value, '-')) { |
Member
There was a problem hiding this comment.
Nothing tests this guard. Your description says a bare --min still raises the requires-a-value error instead of taking the next option, but the only new cases exercise a value that is present. Add a case where handleArguments(['--min', '--filter', 'add']) throws Symfony\Component\Console\Exception\RuntimeException.
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.
What
--minand--exactlyonly accept the--min=50notation. With the space separatednotation the run dies with an unhandled exception:
The same applies to
--exactly 100.Why it happens
Coverage::handleArguments()picks its own options out of the argument list witharray_filter(), matching only--minand--min=…. With--coverage --min 50the
--mintoken is collected but the separate50token is not, soArgvInputgets a
VALUE_REQUIREDoption with nothing after it and throws. As a side effect theorphaned
50is left in the forwarded arguments and reaches PHPUnit as a positionalargument.
This is inconsistent with the rest of the CLI — valued options that Pest forwards to
PHPUnit accept both notations, so
pest --filter addworks fine.The fix
handleArguments()now walks the arguments positionally rather than filtering them,so an option that takes a value also claims the token that follows it. Deliberately
preserved behaviour:
--coverageand--only-coveredtake no value and never consume the next token,so
pest --only-covered --filter addstill forwards--filter adduntouched.--minwith no value still produces the normal "requires a value" errorinstead of swallowing the option that follows it.
Tests
Added to
tests/Plugins/Coverage.php, covering both notations for--minand--exactly, that PHPUnit-owned arguments are not consumed, and that value-lessoptions do not eat the following token. The four new cases fail on
5.xand passwith this change.
Full suite is green locally (
1588 passed, both serial and--parallel), pluspint,rector --dry-runandphpstan.