Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comparing dirs with symlinks does not work #141

Closed
mat007 opened this issue Feb 26, 2019 · 2 comments
Closed

Comparing dirs with symlinks does not work #141

mat007 opened this issue Feb 26, 2019 · 2 comments
Labels

Comments

@mat007
Copy link

mat007 commented Feb 26, 2019

The following test

func TestSymlinks(t *testing.T) {
	rootDirectory := fs.NewDir(t, "root",
		fs.WithDir("source",
			fs.WithFile("foo.txt", "foo"),
			fs.WithSymlink("fool.txt", "foo.txt"),
			fs.WithSymlink("sourcel", "source")))
	defer rootDirectory.Remove()
	expected := fs.Expected(t,
		fs.WithDir("source",
			fs.WithFile("foo.txt", "foo"),
			fs.WithSymlink("fool.txt", "foo.txt"),
			fs.WithSymlink("sourcel", "source")))
	assert.Assert(t, fs.Equal(rootDirectory.Path(), expected))
}

fails on Mac with Go 1.11 with


--- FAIL: TestTarSymlinks (0.00s)
    ....._test.go:82: assertion failed: directory /var/folders/3f/77_0lxwn02x9v1rxz9314qzc0000gp/T/root-331223324 does not match expected:
        /source/fool.txt
          mode: expected Lrwxrwxrwx got Lrwxr-xr-x
          target: expected foo.txt got /var/folders/3f/77_0lxwn02x9v1rxz9314qzc0000gp/T/root-331223324/source/foo.txt
        /source/sourcel
          mode: expected Lrwxrwxrwx got Lrwxr-xr-x
          target: expected source got /var/folders/3f/77_0lxwn02x9v1rxz9314qzc0000gp/T/root-331223324/source/source

Did I miss something obvious?

@dnephin dnephin added the bug label Feb 26, 2019
@dnephin
Copy link
Member

dnephin commented Feb 26, 2019

os.Symlink seems to create links with mode os.ModeSymlink | 0777 on linux (and os.ModeSymlink | 0666 on windows). From your output it seems that on darwin the default is os.ModeSymlink | 0755 ? If that is the case (and it's not a setting in your environment) I guess we need a fs/manifest_darwin.go to set a defaultSymlinkMode.

fs.Symlink creates a target with an absolute path, so I guess it is not symmetrical when used on a manifest. This feels like a bug to me. I'm not sure how easy that will be to fix.

@dnephin
Copy link
Member

dnephin commented Feb 21, 2020

Created #192 for the WithSymlink problem

DominicLavery added a commit to DominicLavery/gotest.tools that referenced this issue Jan 7, 2022
dnephin added a commit that referenced this issue Jan 15, 2022
fs: Fix #141 comparing symlink permissions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants