Skip to content

test(cli): start splitting cli test suite - #4895

Merged
cv merged 4 commits into
mainfrom
codex/cli-test-file-split
Jun 6, 2026
Merged

cv merged 4 commits into
mainfrom
codex/cli-test-file-split

Conversation

@cv

@cv cv commented Jun 6, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Start the mechanical split of the large CLI test file by moving shared CLI test setup into test/cli/helpers.ts and extracting two already-isolated describe blocks into dedicated test/cli/ files. This establishes the reviewable pattern for follow-up splits without changing CLI behavior.

Related Issue

Refs #4892

Changes

  • Moved the shared CLI runner, registry, timeout, and stub helpers from test/cli.test.ts into test/cli/helpers.ts.
  • Extracted the Docker outage coverage into test/cli/docker-outage.test.ts.
  • Extracted live gateway inference, upgrade-sandboxes, and share coverage into test/cli/list-share-live-inference.test.ts.
  • Switched default CLI test HOME setup to mkdtempSync so split files can run in parallel without timestamp collisions.
  • Made the Podman installer preflight fixture return structured Docker info with empty CDISpecDirs, keeping the test isolated from host CDI state.

Type of Change

  • Code change (feature, bug fix, or refactor)
  • Code change with doc updates
  • Doc only (prose changes, no code sample modifications)
  • Doc only (includes code sample changes)

Verification

Ran the full checks with umask 022 because this local shell defaults to 077, which makes existing permission-mode tests create 0o600 fixtures before the code under test runs.

  • npx prek run --all-files passes
  • npm test passes
  • Tests added or updated for new or changed behavior
  • No secrets, API keys, or credentials committed
  • Docs updated for user-facing behavior changes
  • npm run docs builds without warnings (doc changes only)
  • Doc pages follow the style guide (doc changes only)
  • New doc pages include SPDX header and frontmatter (new pages only)

Signed-off-by: Carlos Villela cvillela@nvidia.com

Summary by CodeRabbit

  • Tests
    • Refactored CLI test infrastructure for improved hermeticity, shared helpers, and more consistent environment handling
    • Added end-to-end suites covering Docker outage classification and CLI behavior when Docker is unreachable
    • Added tests for live gateway inference, listing/upgrade detection, and share command behaviors
    • Improved stubs and preflight checks for more reliable compatibility and probing simulations

Signed-off-by: Carlos Villela <cvillela@nvidia.com>
@cv cv self-assigned this Jun 6, 2026
@coderabbitai

coderabbitai Bot commented Jun 6, 2026 •

Copy link
Copy Markdown
Contributor

Ready to act? Review this PR in Change Stack to turn feedback into patch suggestions you can inspect and refine.

Review Change Stack

Warning

Review limit reached

@cv, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 3 minutes and 33 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: fee71605-997b-4be6-ae81-2d91bfc7201a

📥 Commits

Reviewing files that changed from the base of the PR and between b29cfc5 and f2b1f36.

📒 Files selected for processing (1)
  • test/cli/helpers.ts
📝 Walkthrough

Walkthrough

Adds a centralized CLI test helpers module, refactors existing CLI tests to use it (including hermetic temporary HOME handling), and introduces focused Vitest suites for Docker-outage classification and live inference/upgrade/share CLI behaviors; also tweaks a preflight docker stub.

Changes

CLI Test Infrastructure and Coverage

Layer / File(s) Summary
Test utilities foundation and hermetic helpers
test/cli/helpers.ts
New module exporting CLI constants, version reader, result/error types, child-process utilities, run/runWithEnv, sandbox registry and recording command writers, docker stubs, and high-level setup builders (createLogsTestSetup, createDoctorTestSetup, createDebugCommandTestEnv).
Refactored main CLI test file
test/cli.test.ts
Replaces inline CLI test utilities with imports from test/cli/helpers.ts, replaces hardcoded /tmp HOME paths with fs.mkdtempSync(...), removes trailing Docker-outage and live-inference suites moved to dedicated files, and removes redundant TypeScript casts at writeSandboxRegistry call sites.
Docker daemon outage classification tests
test/cli/docker-outage.test.ts
New suite that stubs docker/openshell, builds a temp HOME/bin, and asserts CLI commands (status, connect, logs, policy-list) show docker_unreachable header and Docker-recovery hint when daemon is unreachable; includes driver/phase regressions.
Live inference listing and sandbox upgrade tests
test/cli/list-share-live-inference.test.ts
New suite testing list live gateway inference (with fallback and probing scenarios), upgrade-sandboxes --check staleness detection and probing behavior, and alpha share subcommand routing and help output.
Install preflight docker stub enhancement
test/install-preflight.test.ts
docker stub in preflight test now handles docker info --format by returning JSON with ServerVersion/Name/CDISpecDirs while preserving plain docker info behavior.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • NVIDIA/NemoClaw#4622: Uses the shared writeHealthyDockerStub(...) helper and touches related logs --follow test flows.
  • NVIDIA/NemoClaw#4605: Related Docker-outage classification logic that these tests exercise.
  • NVIDIA/NemoClaw#4550: Related upgrade/version probing changes exercised by the new upgrade-sandboxes --check tests.

Suggested labels

area: cli, area: ci, chore

Suggested reviewers

  • prekshivyas
  • cjagwani

Poem

🐰 I hopped through tests both near and far,
Extracted helpers, a shining star.
Docker stubs and hermetic HOME,
Live inference checks — no more roam.
Tests now tidy, quick, and spry — hop, high!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 9.52% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main objective of the PR: splitting the CLI test suite by extracting shared helpers and specific test coverage into separate files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/cli-test-file-split

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

github-actions Bot commented Jun 6, 2026 •

Copy link
Copy Markdown
Contributor

E2E Advisor Recommendation

Required E2E: None
Optional E2E: None

Workflow run

Full advisor summary

E2E Recommendation Advisor

Base: origin/main
Head: HEAD
Confidence: high

Required E2E

  • None. No E2E is recommended because this PR changes only test files and test helpers. The diff refactors and splits existing CLI/installer test coverage and adjusts the local test harness; it does not modify product source, workflows, deployment assets, policies, credentials handling, sandbox lifecycle implementation, inference routing, or real assistant user-flow code. Unit/Vitest CI should cover these changes.

Optional E2E

  • None.

New E2E recommendations

  • None.

@github-actions

github-actions Bot commented Jun 6, 2026 •

Copy link
Copy Markdown
Contributor

E2E Scenario Advisor Recommendation

Required scenario E2E: None
Optional scenario E2E: None

Workflow run

Full scenario advisor summary

E2E Scenario Advisor

Base: origin/main
Head: HEAD
Confidence: high

Required scenario E2E

  • None. Changed files are CLI/unit test refactors and additions outside test/e2e-scenario/ and do not modify scenario workflows, scenario metadata, expected-state contracts, suite definitions, runtime/runner code, suite scripts, or scenario-relevant install/onboarding helpers.

Optional scenario E2E

  • None.

Relevant changed files

  • None.

@github-actions

github-actions Bot commented Jun 6, 2026 •

Copy link
Copy Markdown
Contributor

PR Review Advisor

Findings: 0 needs attention, 0 worth checking, 0 nice ideas
Since last review: 0 prior items resolved, 0 still apply, 0 new items found

Consider writing more tests for

Workflow run details

This is an automated advisory review. A human maintainer must make the final merge decision.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 2

🧹 Nitpick comments (1)
test/cli/helpers.ts (1)

166-170: Widen writeSandboxRegistry() override types to match what it actually writes to sandboxes.json

test/cli/helpers.ts defines SandboxEntry with only a small set of fields, but writeSandboxRegistry() spreads whatever keys it’s given into the JSON. Tests therefore resort to as unknown as Partial<SandboxEntry> to pass fields not in SandboxEntry (e.g. dashboardPort, openshellVersion, hostGpuDetected, sandboxGpuEnabled, sandboxGpuMode, sandboxGpuDevice, etc.).

Suggested fix
+export type SandboxOverrides = Partial<SandboxEntry> & Record<string, unknown>;
+
 export function writeSandboxRegistry(
   home: string,
-  sandboxNameOrOverrides: string | Partial<SandboxEntry> = "alpha",
-  sandboxOverridesArg: Partial<SandboxEntry> = {},
+  sandboxNameOrOverrides: string | SandboxOverrides = "alpha",
+  sandboxOverridesArg: SandboxOverrides = {},
 ): void {
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/cli/helpers.ts` around lines 166 - 170, The tests pass arbitrary extra
fields into writeSandboxRegistry but SandboxEntry is too narrow, causing callers
to cast to unknown; widen the function's parameter types so it accurately models
what is written to sandboxes.json by changing the signatures for
sandboxNameOrOverrides and sandboxOverridesArg in writeSandboxRegistry to accept
either the existing SandboxEntry or a more permissive type (e.g.
Partial<Record<string, unknown>> or an extended SandboxEntry type) and/or update
the SandboxEntry type itself to include the commonly used fields (dashboardPort,
openshellVersion, hostGpuDetected, sandboxGpuEnabled, sandboxGpuMode,
sandboxGpuDevice, etc.) so no unsafe casts are needed when spreading arbitrary
keys into the JSON.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@test/cli/helpers.ts`:
- Around line 108-120: Replace the hard-coded "node" invocation in runWithEnv()
with process.execPath so the spawned subprocess uses the exact Node binary
running the tests (change the execSync call to use process.execPath and keep the
same arg quoting/CLI variable usage); additionally, widen the SandboxEntry type
used by writeSandboxRegistry() (and any test overrides) to match the actual JSON
shape written by sandboxes.json—make the override accept Partial<Record<string,
unknown>> or extend SandboxEntry with optional fields like dashboardPort,
openshellVersion and GPU metadata so tests can pass unknown fields without
unsafe casting.

In `@test/cli/list-share-live-inference.test.ts`:
- Around line 372-423: The share-command tests are not hermetic because they
only set HOME; update the test block to create a temporary localBin, write no-op
stub executables for the external commands used by the share flow (e.g., "sshfs"
and the sandbox helper invoked by the CLI), make them executable, and then call
runWithEnv with both HOME and PATH pointing to this localBin (prepend localBin
to PATH) so the tests use the stubs; use the existing helpers in the test
(writeSandboxRegistry, runWithEnv) and the same stub pattern used in other CLI
tests to locate where to modify the tests that call runWithEnv("alpha share",
...), runWithEnv("alpha share mount", ...), and similar.

---

Nitpick comments:
In `@test/cli/helpers.ts`:
- Around line 166-170: The tests pass arbitrary extra fields into
writeSandboxRegistry but SandboxEntry is too narrow, causing callers to cast to
unknown; widen the function's parameter types so it accurately models what is
written to sandboxes.json by changing the signatures for sandboxNameOrOverrides
and sandboxOverridesArg in writeSandboxRegistry to accept either the existing
SandboxEntry or a more permissive type (e.g. Partial<Record<string, unknown>> or
an extended SandboxEntry type) and/or update the SandboxEntry type itself to
include the commonly used fields (dashboardPort, openshellVersion,
hostGpuDetected, sandboxGpuEnabled, sandboxGpuMode, sandboxGpuDevice, etc.) so
no unsafe casts are needed when spreading arbitrary keys into the JSON.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: c44de56d-4e77-417e-a1d7-ea87ea85aab6

📥 Commits

Reviewing files that changed from the base of the PR and between 76f6c77 and 00cd9ed.

📒 Files selected for processing (5)
  • test/cli.test.ts
  • test/cli/docker-outage.test.ts
  • test/cli/helpers.ts
  • test/cli/list-share-live-inference.test.ts
  • test/install-preflight.test.ts

Comment thread test/cli/helpers.ts Outdated
Comment thread test/cli/list-share-live-inference.test.ts
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
Comment thread test/cli/helpers.ts Fixed
cv added 2 commits June 6, 2026 01:36
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
@cv
cv merged commit c707ede into main Jun 6, 2026
33 checks passed
@cv
cv deleted the codex/cli-test-file-split branch June 6, 2026 17:46
@coderabbitai coderabbitai Bot mentioned this pull request Jun 6, 2026
14 of 21 tasks
@cv cv mentioned this pull request Jun 7, 2026
2 tasks done
@cv cv added the v0.0.61 label Jun 7, 2026
@wscurran wscurran added the chore Build, CI, dependency, or tooling maintenance label Jun 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Build, CI, dependency, or tooling maintenance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants