Skip to main content

default_session_dir

Function default_session_dir 

Source
pub fn default_session_dir(id: &str) -> PathBuf
Expand description

Where the default session directory lives when the user hasn’t passed --session-path. Three cases:

  • Normal invocation (installed binary, user shell): the session lands at <cwd>/logs/<id>. This is the documented, long-standing user-facing behavior.

  • In-process tests that pre-sandboxed cwd (e.g. checkpoint_resume_staircase in_dir(tmp, runner::run)): <cwd>/logs/<id> is already inside the test’s tempdir sandbox, so leave it alone — the test reads back from <cwd>/logs/latest and would be broken by a redirect.

  • Cargo-spawned invocation where cwd lands inside the workspace (cargo test integration tests that spawn nmbrs as a subprocess without --session-path, plus cargo run --bin nmbrs runs from the workspace root): the default would otherwise be the user-visible <workspace>/logs/<id>, and the session-keep rotation would evict real run sessions. Redirect into $TMPDIR/nmbrs-sessions/<id> — .cargo/config.toml already points TMPDIR at <workspace>/target/test-tmp, so cargo-spawned sessions live in target/test-tmp/ alongside other test artifacts. See feedback_tests_no_project_root.

Tests that want to read back their session contents must still pass --session-path to a known path — this fallback is the blast-radius limiter, not a substitute for explicit sandboxing.