Skip to content

Stop Workspace's chdir-to-home from leaking the process cwd across tests - #14043

Closed
fbartho wants to merge 2 commits into
warpdotdev:masterfrom
fbartho:fb/13980-rootview-chdir-test-isolation
Closed

fbartho wants to merge 2 commits into
warpdotdev:masterfrom
fbartho:fb/13980-rootview-chdir-test-isolation

Conversation

@fbartho

@fbartho fbartho commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor

Closes #13980

Description

Workspace::new (view.rs) unconditionally called terminal::platform::init(), which on macOS (platform.rs) does env::set_current_dir(home_dir) with no restoration. The first test in a shared process that constructs a Workspace permanently relocates the whole test binary's cwd to $HOME — a first-writer-wins process-global side effect (same shape as #13974's cache cluster, via the OS cwd instead of a static). Every later test resolving a crate-relative path then fails depending on scheduling: test_load_local / test_load_before_session (open ../README.md), test_resolve_command (resolves ../script/run).

Fix

#[cfg(not(test))] on the platform::init() call site in Workspace::new, matching the crate's existing pattern for process-global side effects under test (block.rs, context_chips/logging.rs, keyboard.rs). platform::init() itself is untouched — its non-test callers keep it.

Secondary fix

test_resolve_command also reads the ambient PATH with no synchronization against the already-#[serial] PATH-overriding tests in pane_group::pane::local_harness_launch_tests; added the same marker so it joins that serial group. Independent of the cwd leak, and would otherwise still flake.

Linked Issue

  • The linked issue is labeled ready-to-spec or ready-to-implement.
  • Where appropriate, screenshots or a short video of the implementation are included below (especially for user-visible or UI changes).
    • Not applicable: test-only change, no UI.

Testing

Full crate suite under plain cargo test -p warp --lib (nextest's per-process isolation masks this class):

Agent Mode

  • Warp Agent Mode - This PR was created via Warp's AI Agent Mode

fbartho added 2 commits July 20, 2026 13:16
On macOS, terminal::platform::init() unconditionally chdirs the
process to the user's home directory with no restoration. Workspace::
new called it on every construction with no #[cfg(not(test))] guard,
so the first test in the binary that constructed a Workspace (there
are dozens in workspace/view_tests.rs) permanently relocated the
whole test process's cwd to $HOME. Every later test in the same
process that resolved a relative path against the crate-root cwd then
failed non-deterministically depending on test scheduling.

Gate the call so it only runs outside test builds, matching the
existing #[cfg(not(test))] pattern already used elsewhere in this
crate for other process-global side effects (block.rs,
context_chips/logging.rs, keyboard.rs).

Closes warpdotdev#13980
test_resolve_command reads the ambient process PATH via
resolve_executable, but carried no #[serial_test::serial] marker.
pane_group::pane::local_harness_launch_tests temporarily overrides
PATH via an RAII EnvVarGuard and is already serialized against the
crate's other PATH/HOME-mutating tests. Without joining that same
group, test_resolve_command could run concurrently with those tests
and observe a PATH pointing only at a temp directory, failing its
pwd/env lookups.

This is a secondary, narrower contributor alongside warpdotdev#13980's cwd leak
(fixed separately in workspace/view.rs) — this test's relative-path
assertion was cwd-sensitive, while its PATH-based assertions were
independently exposed to this race.

Refs warpdotdev#13980
@cla-bot cla-bot Bot added the cla-signed label Jul 20, 2026
@github-actions github-actions Bot added the external-contributor Indicates that a PR has been opened by someone outside the Warp team. label Jul 20, 2026
@fbartho
fbartho marked this pull request as ready for review July 20, 2026 22:49
@warp-for-oss

warp-for-oss Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

@fbartho

Every PR must be linked to a same-repo issue before Oz can review it.

This PR is linked to #13980, but no linked issue is marked ready-to-implement yet. Only repository maintainers apply that label, so please wait for a maintainer to mark the issue. Once it is marked, push a new commit or comment /oz-review to re-trigger review.

See the contribution guidelines for the full readiness model.

Powered by Oz

@warp-for-oss warp-for-oss 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.

@fbartho

Every PR must be linked to a same-repo issue before Oz can review it.

This PR is linked to #13980, but no linked issue is marked ready-to-implement yet. Only repository maintainers apply that label, so please wait for a maintainer to mark the issue. Once it is marked, push a new commit or comment /oz-review to re-trigger review.

See the contribution guidelines for the full readiness model.

Powered by Oz

@github-actions

Copy link
Copy Markdown
Contributor

Hi @fbartho — a reviewer requested changes on this PR and it hasn't had activity from you in 7 days. When you get a chance, please push updates or reply to the review so a reviewer can take another look. Without activity, this PR will be automatically closed after 14 days of inactivity.

@fbartho

fbartho commented Jul 28, 2026

Copy link
Copy Markdown
Contributor Author

(Just commenting so stale-bot doesn't think this is dead).

1 similar comment
@fbartho

fbartho commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

(Just commenting so stale-bot doesn't think this is dead).

@github-actions

Copy link
Copy Markdown
Contributor

Hi @fbartho — a reviewer requested changes on this PR and it hasn't had activity from you in 7 days. When you get a chance, please push updates or reply to the review so a reviewer can take another look. Without activity, this PR will be automatically closed after 14 days of inactivity.

@fbartho

fbartho commented Aug 12, 2026

Copy link
Copy Markdown
Contributor Author

This PR is still a valid fix. The upstream ticket is still awaiting maintainer review, please advise @oss-maintainers?

@github-actions

Copy link
Copy Markdown
Contributor

Hi @fbartho — a reviewer requested changes on this PR and it hasn't had activity from you in 7 days. When you get a chance, please push updates or reply to the review so a reviewer can take another look. Without activity, this PR will be automatically closed after 14 days of inactivity.

@fbartho

fbartho commented Aug 20, 2026

Copy link
Copy Markdown
Contributor Author

Temporarily closing in until the linked issue #13980 gets processed.

@fbartho fbartho closed this Aug 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed external-contributor Indicates that a PR has been opened by someone outside the Warp team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

app tests: unconditional chdir to home directory in RootView construction leaks the process cwd, breaking every test that resolves a relative path

1 participant