Emulates AT_SYMLINK_NOFOLLOW instead of sometimes implementing it (#1588)
Some checks failed
Release CLI / Pre-release build (push) Has been cancelled
Release CLI / Pre-release test (macos-12) (push) Has been cancelled
Release CLI / Pre-release test (ubuntu-22.04) (push) Has been cancelled
Release CLI / Pre-release test (windows-2022) (push) Has been cancelled
Release CLI / Release (push) Has been cancelled

Signed-off-by: Adrian Cole <adrian@tetrate.io>
This commit is contained in:
Crypt Keeper
2023-07-22 08:03:47 +08:00
committed by GitHub
parent a53861846a
commit fb6147ca94
16 changed files with 52 additions and 99 deletions

View File

@@ -531,14 +531,8 @@ func TestDirFS_Utimesns(t *testing.T) {
require.NoError(t, err)
t.Run("doesn't exist", func(t *testing.T) {
err := testFS.Utimens("nope", nil, true)
err := testFS.Utimens("nope", nil)
require.EqualErrno(t, sys.ENOENT, err)
err = testFS.Utimens("nope", nil, false)
if SupportsSymlinkNoFollow {
require.EqualErrno(t, sys.ENOENT, err)
} else {
require.EqualErrno(t, sys.ENOSYS, err)
}
})
// Note: This sets microsecond granularity because Windows doesn't support
@@ -603,12 +597,11 @@ func TestDirFS_Utimesns(t *testing.T) {
},
}
for _, fileType := range []string{"dir", "file", "link", "link-follow"} {
for _, fileType := range []string{"dir", "file", "link"} {
for _, tt := range tests {
tc := tt
fileType := fileType
name := fileType + " " + tc.name
symlinkNoFollow := fileType == "link"
t.Run(name, func(t *testing.T) {
tmpDir := t.TempDir()
@@ -634,9 +627,6 @@ func TestDirFS_Utimesns(t *testing.T) {
path = "file"
statPath = "file"
case "link":
path = "file-link"
statPath = "file-link"
case "link-follow":
path = "file-link"
statPath = "file"
default:
@@ -646,11 +636,7 @@ func TestDirFS_Utimesns(t *testing.T) {
oldSt, errno := testFS.Lstat(statPath)
require.EqualErrno(t, 0, errno)
errno = testFS.Utimens(path, tc.times, !symlinkNoFollow)
if symlinkNoFollow && !SupportsSymlinkNoFollow {
require.EqualErrno(t, sys.ENOSYS, errno)
return
}
errno = testFS.Utimens(path, tc.times)
require.EqualErrno(t, 0, errno)
newSt, errno := testFS.Lstat(statPath)