From 534df1cac3a68344358a553ec1e019d759fda8b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Sat, 6 May 2023 08:45:56 +0100 Subject: [PATCH] CI: go back to macos-latest Now that it seems we found a fix to #200, there is no reason to stick to macos-11, which will likely be deprecated soon. Update actions/setup-go to its latest version as well. The new version uses caching by default, which we do not need. While here, tidy up the cloneFile docs a bit. --- .github/workflows/test.yml | 5 +++-- clonefile.go | 2 +- clonefile_darwin.go | 2 +- clonefile_other.go | 4 +++- exe.go | 5 ++--- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5b325d71..d952a1f6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,16 +15,17 @@ jobs: - '1.20.x' os: - ubuntu-latest - - macos-11 + - macos-latest - windows-latest runs-on: ${{ matrix.os }} steps: - name: Checkout code uses: actions/checkout@v3 - name: Install Go - uses: actions/setup-go@v3 + uses: actions/setup-go@v4 with: go-version: ${{ matrix.go-version }} + cache: false # our tests are quick enough - name: Test run: | go test ./... diff --git a/clonefile.go b/clonefile.go index dd2467d4..c841d67d 100644 --- a/clonefile.go +++ b/clonefile.go @@ -5,7 +5,7 @@ package testscript import "os" -// cloneFile creates to as a hard link to the from file. +// cloneFile makes a clone of a file via a hard link. func cloneFile(from, to string) error { return os.Link(from, to) } diff --git a/clonefile_darwin.go b/clonefile_darwin.go index c0e7a9e6..79645bc2 100644 --- a/clonefile_darwin.go +++ b/clonefile_darwin.go @@ -2,7 +2,7 @@ package testscript import "golang.org/x/sys/unix" -// cloneFile clones the file from to the file to. +// cloneFile makes a clone of a file via MacOS's `clonefile` syscall. func cloneFile(from, to string) error { return unix.Clonefile(from, to, 0) } diff --git a/clonefile_other.go b/clonefile_other.go index 5682a927..d66b841b 100644 --- a/clonefile_other.go +++ b/clonefile_other.go @@ -5,7 +5,9 @@ package testscript import "fmt" -// We don't want to use hard links on Windows, as that can lead to "access denied" errors when removing. +// 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. func cloneFile(from, to string) error { return fmt.Errorf("unavailable") } diff --git a/exe.go b/exe.go index 475ab70f..9b383542 100644 --- a/exe.go +++ b/exe.go @@ -117,10 +117,9 @@ func RunMain(m TestingM, commands map[string]func() int) (exitCode int) { // Second, symlinks might not be available on some environments, so we have to // implement a "full copy" fallback anyway. // -// However, we do try to use a hard link, since that will probably work on most +// However, we do try to use cloneFile, since that will probably work on most // unix-like setups. Note that "go test" also places test binaries in the -// system's temporary directory, like we do. We don't use hard links on Windows, -// as that can lead to "access denied" errors when removing. +// system's temporary directory, like we do. func copyBinary(from, to string) error { if err := cloneFile(from, to); err == nil { return nil