Skip to content

test(args): regression coverage for BoolishValueParser on env bools#89

Merged
Mikola Lysenko (mikolalysenko) merged 1 commit into
mainfrom
feat/bool-env-regression-tests
May 28, 2026
Merged

test(args): regression coverage for BoolishValueParser on env bools#89
Mikola Lysenko (mikolalysenko) merged 1 commit into
mainfrom
feat/bool-env-regression-tests

Conversation

@mikolalysenko
Copy link
Copy Markdown
Collaborator

Summary

Follow-up to #82 (telemetry coverage + paid-tier fallback). PR #82 wired clap::builder::BoolishValueParser onto every bool global with an env attribute so SOCKET_OFFLINE=1, SOCKET_DEBUG=1, etc. parse correctly — previously they crashed clap with error: invalid value '1' for '--offline'.

That commit shipped without paired regression tests; I added them on the same branch but they landed after the squash-merge cutoff. This PR is just those tests, rebased onto the current main.

Two #[serial] tests in crates/socket-patch-cli/tests/cli_global_args.rs:

  • bool_env_vars_accept_one_and_yesSOCKET_OFFLINE=1, SOCKET_GLOBAL=yes, SOCKET_JSON=on, SOCKET_VERBOSE=1, SOCKET_SILENT=y, SOCKET_DRY_RUN=1, SOCKET_YES=yes, SOCKET_BREAK_LOCK=1, SOCKET_DEBUG=1, SOCKET_TELEMETRY_DISABLED=1 all parse as true.
  • bool_env_vars_reject_zero_and_falseySOCKET_OFFLINE=0, SOCKET_DEBUG=false, SOCKET_TELEMETRY_DISABLED=no, SOCKET_JSON=off all parse as false. Guards against an over-eager parser flipping a bool on any non-empty string.

The existing env_vars_populate_global_args is also marked #[serial] in this commit — env-var state is process-global, so without serialization the negative-case test flakes by inheriting SOCKET_OFFLINE=1 from the positive case running concurrently.

Test plan

Assisted-by: Claude Code:opus-4-7

Two new tests in cli_global_args.rs:

- bool_env_vars_accept_one_and_yes: SOCKET_OFFLINE=1, SOCKET_GLOBAL=yes,
  SOCKET_JSON=on, etc. all parse as `true`. Pins the BoolishValueParser
  wiring we just added — without it clap fails with
  `error: invalid value '1' for '--offline'` (the bug that prompted
  the fix).
- bool_env_vars_reject_zero_and_falsey: SOCKET_OFFLINE=0,
  SOCKET_DEBUG=false, SOCKET_TELEMETRY_DISABLED=no, SOCKET_JSON=off
  all parse as `false`. Guards against an over-eager parser flipping
  a bool on any non-empty string.

Both new tests + the existing env_vars_populate_global_args are now
`#[serial]` — env-var state is process-global, so parallel test
runs race the cleanup. Without serialization the negative-case test
flakes by inheriting `SOCKET_OFFLINE=1` from the positive case.

Assisted-by: Claude Code:opus-4-7
@mikolalysenko Mikola Lysenko (mikolalysenko) merged commit f97167d into main May 28, 2026
42 checks passed
@mikolalysenko Mikola Lysenko (mikolalysenko) deleted the feat/bool-env-regression-tests branch May 28, 2026 18:06
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