Validate --k and --seed in the CLI - #28
Merged
Merged
Conversation
--k and --seed were parsed as unbounded ints, so `leakgauge --k 0` ran zero seeded repeats (a degenerate, empty result) and negative values were accepted too — both failing confusingly downstream. Reject --k < 1 and --seed < 0 in _run with a clear message naming the flag, matching the existing --max-steps check (stderr message + return 2, nothing written). Add test_cli_validation.py covering the rejections and a valid run. Closes bamdadd#6
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.
Closes #6.
--kand--seedwere parsed as unbounded ints, soleakgauge --k 0ran zero seeded repeats (a degenerate/empty result) and a negative--seedwas accepted too — both failing confusingly downstream instead of giving a clear message.Change: reject
--k < 1and--seed < 0in_run, matching the existing--max-stepsguard exactly — a clear stderr message naming the flag andreturn 2, with nothing written. No other logic changes.Acceptance criteria:
leakgauge --k 0and a negative--seedexit with code 2 and a message naming the offending flag. ✅Tests: added
tests/test_cli_validation.pyasserting exit code 2 for--k 0,--k -1, and--seed -1(nothing written), plus a valid--k 2 --seed 0run still succeeding. Full suite +ruff check/formatpass locally.