Skip to content

CLI tests: pass the state directory instead of setting NODESPACE_HOME - #4408

Merged
mstomar125 merged 1 commit into
mainfrom
cli-tests-no-env
Nov 30, 2026
Merged

mstomar125 merged 1 commit into
mainfrom
cli-tests-no-env

Conversation

@mstomar125

Copy link
Copy Markdown
Contributor

What

  • nodespace_cli::with_state_dir(dir, fut): a task-local state directory for the refusal-marker lookup of failed dials. Nothing in the binary calls it, so production lookups are unchanged.
  • connect_refused_returns_friendly_error and a_daemon_that_is_not_running_is_its_own_outcome_and_exit_status pass an empty directory through it; isolate_state_dir() (a process-wide set_var) is removed.
  • New test connect_refused_reports_the_refusal_marker_in_the_given_state_dir.
  • launched_session daemons each set_var("NODESPACE_HOME"); a mutex held for the daemon's life now serializes them.

Why

A process-wide env change races with other tests under plain multi-threaded cargo test (CI uses nextest, one process per test, so it was unaffected).

Tests (plain cargo test -p nodespace-cli --no-fail-fast, default threads, isolated HOME/NODESPACE_HOME under /tmp)

  • 3 runs, clean home: all green (354 unit + 159 integration passed, 1 ignored each time).
  • 1 run with a live incompatible-database.json (existing databasePath) in $NODESPACE_HOME/.nodespace: green.
  • Before the launched_session mutex, the 3 default-thread runs each failed exactly launched_session::a_launch_with_no_project_runs_in_a_private_folder_with_the_environment_set (158 passed, 1 failed).
  • fmt --check and clippy --all-targets -D warnings clean.

Mutation

  • Lookup ignores the given dir, clean home: new marker test fails.
  • Same mutation, home holding a marker: both friendly-error tests fail.
  • Mutex absent is the main baseline below.

Flake baseline (origin/main 6645d6a, launched_session group, default threads, 3 runs)

Failed 3/3 (5 passed, 1 failed) on the same no-project test at launched_session.rs:513, so the flake exists on main before this change, and in this environment it is deterministic rather than intermittent.

🤖 Generated with Claude Code

…E_HOME

The two in-process tests that dial a missing daemon set NODESPACE_HOME for the
whole test process to keep the refusal-marker lookup hermetic. Add
nodespace_cli::with_state_dir, a task-local state directory for failed dials
(production lookups unchanged), and use it in those tests; add a test that the
given directory's marker is the one reported.

The launched_session daemons each set NODESPACE_HOME for the process, so under
plain multi-threaded cargo test they overwrite each other (that file's
no-project test failed every run, on main too). Serialize them with a mutex
held for the daemon's life.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@mstomar125
mstomar125 merged commit 8954dfc into main Nov 30, 2026
@mstomar125
mstomar125 deleted the cli-tests-no-env branch November 30, 2026 12:24
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.

1 participant