Skip to content

[Test Quality] Pin exact errors and anchoring for --memory-limit/--pids-limit parsers - #11526

Merged
lpcox merged 1 commit into
mainfrom
test-quality/resource-limit-parsers-75545f8b507c8253
Nov 13, 2026
Merged

lpcox merged 1 commit into
mainfrom
test-quality/resource-limit-parsers-75545f8b507c8253

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Contract

parseMemoryLimit / parsePidsLimit (src/option-parsers.ts) must accept only fully-matching values (<digits><b|k|m|g>, ^\d+$) and return the documented error text. Values flow into Docker mem_limit/pids_limit in compose.

Previous weakness

Tests only asserted toHaveProperty('error') on a few trivially bad inputs. A regression dropping the $ anchors (accepting 2gb, 1000abc, 1e3, 2g\n512m) and the wrong-error-branch case were not detected.

Change

Test-only, src/option-parsers-agent-opts.test.ts: table-driven malformed inputs (trailing/leading junk, whitespace, newline, hex/exponent, sign, decimals) asserting the exact error object (no value), plus zero cases asserting the distinct "positive" error message.

Evidence

  • Baseline: ./node_modules/.bin/jest --runInBand --no-coverage --runTestsByPath src/option-parsers-agent-opts.test.ts → 39 passed.
  • Temporary mutation (removed $ anchors in both regexes): old tests → 1 failed (only the memory trailing case in rejects invalid formats... pids 1000abc missed); new tests → 10 failed on the intended assertions (e.g. 2gb, 1000abc, 1e3, 0x10, newline cases).
  • Mutation restored; final run: 58 passed. ESLint: 0 errors (pre-existing any warnings only).
  • No tests removed.

CI

Discovered by root Jest via npm test in .github/workflows/build.yml. Unit-level evidence only; no container/network enforcement involved.

Generated by Test Quality Improver · copilot · auto (Claude Sonnet 5.5) · ~25 AIC · ⌖ ~2 AIC · ⊞ 11.6K · ◷

  • expires on Dec 13, 2026, 12:36 PM UTC

@lpcox
lpcox marked this pull request as ready for review November 13, 2026 14:23
Copilot AI adaptive review requested due to automatic review settings November 13, 2026 14:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active issues are identified, and the change is limited to focused parser contract tests covering malformed and zero-valued inputs with exact error assertions.

No open issues 🎉

What changed in this PR

This test-only PR strengthens parser contract coverage for --memory-limit and --pids-limit, asserting exact errors for malformed and zero-valued inputs.

Changes:

  • Adds table-driven cases for whitespace, junk, signs, decimals, newlines, hexadecimal, and exponent formats.
  • Verifies exact error objects and distinct positivity errors without an unintended value.
File Description
src/​option-parsers-agent-opts.test.ts Expands parser tests with comprehensive malformed-input, exact-error, and zero-value assertions.

Review effort: Lite (dynamic)

@github-actions

Copy link
Copy Markdown
Contributor Author

✅ Copilot review passed with no inline comments.

@github-actions[bot] Add the ready-for-aw label to this PR to trigger agentic CI smoke tests.

@lpcox
lpcox merged commit e4dc5a4 into main Nov 13, 2026
39 of 41 checks passed
@lpcox
lpcox deleted the test-quality/resource-limit-parsers-75545f8b507c8253 branch November 13, 2026 15:29
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.

2 participants