Skip to content

Conversation

@caxu-rh
Copy link
Contributor

@caxu-rh caxu-rh commented Jan 22, 2026

On some systems, /tmp and /var are symlinks to /private/tmp and /private/var, respectively. This may cause the test to fail, because the created directory is not actually at the path where it was created.

Get the canonical path of the created directory and compare that to the output of ReadSymlinkedDirectory.

While we're here, avoid hardcoding specific test paths and prefer using t.TempDir() instead. This also simplifies the cleanup logic.

@github-actions github-actions bot added the storage Related to "storage" package label Jan 22, 2026
Copy link
Contributor

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

I expect that works, but really tests should not be hard-coding specific paths in /tmp (and exposing the invoking user to attacks by other users on the machine) in the first place. Can you convert the test to be based on t.TempDir(), please? That might work around the macOS /tmp situation as a side effect.

On some systems, /tmp and /var are symlinks to /private/tmp and
/private/var, respectively. This may cause the test to fail,
because the created directory is not actually at the path where it
was created.

Get the canonical path of the created directory and compare that to
the output of ReadSymlinkedDirectory.

While we're here, avoid hardcoding specific test paths and prefer
using t.TempDir() instead. This also simplifies the cleanup logic.

Signed-off-by: Caleb Xu <caxu@redhat.com>
@caxu-rh caxu-rh force-pushed the fileutils-symlink-test branch from 19562db to 5d306e0 Compare January 23, 2026 19:22
@caxu-rh
Copy link
Contributor Author

caxu-rh commented Jan 23, 2026

Thanks for the feedback, I made adjustments to avoid using hardcoded paths for the test. The path returned by t.TempDir() is still not a canonical one, so the filepath.EvalSymlinks call is still necessary.

I wonder if this should work now on Windows too, but I don't have the means to test it right now, so I've left the TODO in place.

@TomSweeneyRedHat
Copy link
Member

If @mtrmac is hip with this, so am I. Provisionally:
LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

storage Related to "storage" package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants