Skip to content

fix(util): align parseArgs option parsing#3495

Merged
proggeramlug merged 1 commit into
PerryTS:mainfrom
andrewtdiz:codex/node-compat-util-parse-args
May 31, 2026
Merged

fix(util): align parseArgs option parsing#3495
proggeramlug merged 1 commit into
PerryTS:mainfrom
andrewtdiz:codex/node-compat-util-parse-args

Conversation

@andrewtdiz
Copy link
Copy Markdown
Contributor

Closes #3015
Closes #3017
Closes #3018
Closes #3019
Closes #3021

Summary

  • Extends node:util.parseArgs() descriptor handling for multiple arrays and default values, including default type validation.
  • Parses omitted config.args from process.argv.slice(2) and preserves non-string argv values for positionals/tokens while rejecting non-string option values.
  • Expands grouped short options and preserves unknown long/short options when strict: false.
  • Adds a small parity-runner // parity-argv: fixture hook so default-argv behavior can be tested against Node and Perry with the same CLI arguments.

Why Batched

These issues share the same runtime parser state machine and result-shaping code. Fixing them together avoids layering incompatible partial parseArgs behavior across multiple PRs.

Tests Added

  • test-parity/node-suite/util/parse-args/multiple-defaults.ts
  • test-parity/node-suite/util/parse-args/default-validation.ts
  • test-parity/node-suite/util/parse-args/short-groups-and-unknown.ts
  • test-parity/node-suite/util/parse-args/default-args-and-non-string.ts

Verification

  • PATH=/home/github-runner/actions-runner/externals/node24/bin:$PATH ./run_parity_tests.sh --suite node-suite --module util/parse-args -> 9 pass, 0 fail, 0 compile fail.
  • PATH=/home/github-runner/actions-runner/externals/node24/bin:$PATH ./run_parity_tests.sh --suite node-suite --module util -> 77 pass, 1 existing mismatch (node-suite/util/get-system-error), 0 compile fail.
  • RUSTC_WRAPPER= cargo check -p perry-runtime -p perry-codegen -p perry-hir -p perry-api-manifest -p perry -> passed with existing repository warnings.
  • cargo fmt --all -- --check -> passed.
  • git diff --check && git diff --cached --check -> passed.
  • ./scripts/check_file_size.sh -> passed.
  • jq empty test-parity/known_failures.json -> passed.

Known Limitations

  • This PR does not address the existing util parity mismatch in node-suite/util/get-system-error.
  • The new parity argv hook intentionally supports simple whitespace-separated test arguments; it is only used for deterministic fixture CLI args here.

Non-Goals

  • No unrelated node:util APIs.
  • No broad CLI parser rewrite beyond the parseArgs behaviors covered by the linked issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants