Skip to content

fix(tools): validate corpus checker timeout as finite positive float (#585) - #586

Merged
LunaStev merged 1 commit into
wavefnd:masterfrom
DYNOSuprovo:fix/corpus-checker-timeout-validation
Sep 11, 2026
Merged

LunaStev merged 1 commit into
wavefnd:masterfrom
DYNOSuprovo:fix/corpus-checker-timeout-validation

Conversation

@DYNOSuprovo

Copy link
Copy Markdown
Contributor

Summary

Validate the --timeout CLI option in tools/check_wave_corpus.py to ensure it receives a finite positive floating-point number (> 0), producing a concise argparse usage error upon invalid input.

Fixes #585.

Motivation

Previously, check_wave_corpus.py used type=float without validation for --timeout, accepting 0, negative values, nan, inf, and -inf. These non-positive or non-finite values fail to provide a finite positive per-file budget and were forwarded down to subprocess execution. Validating at the CLI boundary ensures actionable diagnostic errors before process creation or compiler discovery.

Target and compatibility impact

  • check_wave_corpus.py rejects non-positive (<= 0) and non-finite (nan, inf, -inf) timeouts with exit status 2 and an error message naming --timeout.
  • Valid finite positive float inputs (including fractional numbers like 0.25) and the 15.0-second default remain unchanged.

Validation

  • Added table-driven tests in tools/test_check_wave_corpus.py covering:
    • Default timeout value (15.0s).
    • Valid positive values (integer and fractional float).
    • Rejection of zero (0, 0.0, -0.0), negative values (-1, -0.001), NaN (nan, NaN, -nan), infinities (inf, -inf, Infinity), and non-numeric strings with exit code 2 and no tracebacks.
    • Rejection of invalid timeouts in main() before resolve_wavec is invoked.
    • Verification of --help output.
  • All test suites passed:
    • python3 -m unittest tools.test_check_wave_corpus (5 passed).
    • python3 -m unittest discover -s tools -p "test_*.py" (38 passed).

Checklist

  • Commits include a DCO Signed-off-by line.
  • Tests cover new behavior or the PR explains why no test is needed.
  • User-facing changes include documentation or diagnostics updates.
  • The change preserves the license boundary between the compiler and std/.

@LunaStev

Copy link
Copy Markdown
Member

LGTM.

This overlaps with #587, which addresses the same #585 timeout validation issue. Both approaches are functionally correct, but this implementation is cleaner overall: validation is kept at the argparse type boundary through a dedicated parser, parse_args()/main() accept explicit argv values for direct testing, and the regression coverage explicitly verifies that invalid timeouts are rejected before compiler discovery.

Because the two PRs are duplicates, I’m proceeding with this one and will close #587 in favor of it.

@LunaStev
LunaStev merged commit d24b14f into wavefnd:master Sep 11, 2026
23 of 26 checks passed
@LunaStev LunaStev mentioned this pull request Sep 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reject non-finite and non-positive corpus checker timeouts

2 participants