Skip to content

make test_temp_path_resolve_existing_cwd() work with symlink in TMPDIR#403

Closed
martinvonz wants to merge 1 commit intoStebalien:masterfrom
martinvonz:mz/usxvsoqvnywv
Closed

make test_temp_path_resolve_existing_cwd() work with symlink in TMPDIR#403
martinvonz wants to merge 1 commit intoStebalien:masterfrom
martinvonz:mz/usxvsoqvnywv

Conversation

@martinvonz
Copy link
Copy Markdown

Here's a simple way to reproduce a test failure before this commit:

ln -s /tmp /tmp/here
TMPDIR=/tmp/here cargo test

That fails something like this:

test test_temp_path_resolve_existing_cwd ... FAILED

failures:

---- test_temp_path_resolve_existing_cwd stdout ----

thread 'test_temp_path_resolve_existing_cwd' (137617) panicked at tests/namedtempfile.rs:376:5:
assertion `left == right` failed
  left: "/tmp/.tmpDu1A7l/foo"
 right: "/tmp/here/.tmpDu1A7l/foo"
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

This commit fixes it by canonicalizing the CWD path in the test.

Here's a simple way to reproduce a test failure before this commit:

```
ln -s /tmp /tmp/here
TMPDIR=/tmp/here cargo test
```

That fails something like this:

```
test test_temp_path_resolve_existing_cwd ... FAILED

failures:

---- test_temp_path_resolve_existing_cwd stdout ----

thread 'test_temp_path_resolve_existing_cwd' (137617) panicked at tests/namedtempfile.rs:376:5:
assertion `left == right` failed
  left: "/tmp/.tmpDu1A7l/foo"
 right: "/tmp/here/.tmpDu1A7l/foo"
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```

This commit fixes it by canonicalizing the CWD path in the test.
Stebalien added a commit that referenced this pull request May 7, 2026
Thanks to @martinvonz for reporting this.

To test, run:

    ln -s /tmp /tmp/here
    TMPDIR=/tmp/here cargo test

fixes #403
@Stebalien
Copy link
Copy Markdown
Owner

Windows was failing because paths were getting converted to UNC syntax. So, instead of using the normalized paths in the rest of the tests, I just used the return value of std::env::current_dir and verified that we successfully changed to the correct directory.

I'm not super happy with it but... it works and it's just a test.

@Stebalien
Copy link
Copy Markdown
Owner

But thanks for the PR and the easy reproducer!

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