From fd1755f577ecebf98ce6e8eb15d403ef8a622cb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Fri, 5 May 2023 15:06:33 +0200 Subject: [PATCH] testscript: use unix.CloneFile on MacOs To fix unexpected errors of type: ``` [signal: killed] FAIL: testscripts/myecho.txt:1: unexpected command failure ``` Fixes #200 --- clonefile.go | 2 +- clonefile_darwin.go | 2 +- clonefile_other.go | 4 +--- go.mod | 4 ++-- go.sum | 8 ++++---- 5 files changed, 9 insertions(+), 11 deletions(-) diff --git a/clonefile.go b/clonefile.go index c841d67d..dd2467d4 100644 --- a/clonefile.go +++ b/clonefile.go @@ -5,7 +5,7 @@ package testscript import "os" -// cloneFile makes a clone of a file via a hard link. +// cloneFile creates to as a hard link to the from file. func cloneFile(from, to string) error { return os.Link(from, to) } diff --git a/clonefile_darwin.go b/clonefile_darwin.go index 79645bc2..c0e7a9e6 100644 --- a/clonefile_darwin.go +++ b/clonefile_darwin.go @@ -2,7 +2,7 @@ package testscript import "golang.org/x/sys/unix" -// cloneFile makes a clone of a file via MacOS's `clonefile` syscall. +// cloneFile clones the file from to the file to. func cloneFile(from, to string) error { return unix.Clonefile(from, to, 0) } diff --git a/clonefile_other.go b/clonefile_other.go index d66b841b..5682a927 100644 --- a/clonefile_other.go +++ b/clonefile_other.go @@ -5,9 +5,7 @@ package testscript import "fmt" -// cloneFile does not attempt anything on Windows, as hard links on it have -// led to "access denied" errors when deleting files at the end of a test. -// We haven't tested platforms like plan9 or wasm/wasi. +// We don't want to use hard links on Windows, as that can lead to "access denied" errors when removing. func cloneFile(from, to string) error { return fmt.Errorf("unavailable") } diff --git a/go.mod b/go.mod index 0bd85f6b..60d685dc 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,6 @@ module fortio.org/testscript go 1.20 require ( - golang.org/x/sys v0.8.0 - golang.org/x/tools v0.8.0 + golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f + golang.org/x/tools v0.1.12 ) diff --git a/go.sum b/go.sum index b13d5c28..7bd4c707 100644 --- a/go.sum +++ b/go.sum @@ -1,4 +1,4 @@ -golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU= -golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/tools v0.8.0 h1:vSDcovVPld282ceKgDimkRSC8kpaH1dgyc9UMzlt84Y= -golang.org/x/tools v0.8.0/go.mod h1:JxBZ99ISMI5ViVkT1tr6tdNmXeTrcpVSD3vZ1RsRdN4= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f h1:v4INt8xihDGvnrfjMDVXGxw9wrfxYyCjk0KbXjhR55s= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/tools v0.1.12 h1:VveCTK38A2rkS8ZqFY25HIDFscX5X9OoEhJd3quQmXU= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=