fix(cli): stop watch taking an option's value as the watched path - #1292
Merged
Conversation
cmd_watch knew only -f/--filter as consuming a value, so every other option's value fell to the positional branch and became the path. `bashunit watch --tag slow tests/` polled a directory named slow and handed the real path to --tag; when a value happened to name a real directory it polled that one and dropped the option without saying so. The set of value-taking options now lives in one predicate rather than a second list that can drift, and a test derives the truth from cmd_test's own parser -- an option takes a value there precisely when its case arm ends in an unconditional shift. Both directions are checked, and the guard is mutation-tested. Closes #1291
…-values # Conflicts: # CHANGELOG.md
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.
🤔 Background
Related #1291
cmd_watchknew only-f/--filteras consuming a value, so every other option's value fell through to the positional branch and became the path being polled.bashunit watch --tag slow tests/polled a directory namedslowand handed the real path to--tag. That case is loud only because of the path validation added in #1263; whenever a value happens to name a real directory,watchpolls the wrong one and drops the option silently.💡 Changes
cmd_testcmd_test's own parser — an option takes a value there precisely when its case arm ends in an unconditionalshift— and checks both directions, so neither a new option nor a removed one can slip through. Mutation-tested: dropping--tagand adding a bogus entry each fail it by name