Skip to content

Commit

Permalink
CI: go back to macos-latest
Browse files Browse the repository at this point in the history
Now that it seems we found a fix to rogpeppe#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.
  • Loading branch information
mvdan authored and bep committed May 13, 2023
1 parent 5150104 commit 521381c
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,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 ./...
Expand Down
2 changes: 1 addition & 1 deletion testscript/clonefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
2 changes: 1 addition & 1 deletion testscript/clonefile_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
4 changes: 3 additions & 1 deletion testscript/clonefile_other.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
5 changes: 2 additions & 3 deletions testscript/exe.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 521381c

Please sign in to comment.