Skip to content

Commit

Permalink
testscript: fix "signal: killed" exec errors on MacOS
Browse files Browse the repository at this point in the history
On `MacOS` there are lots of reports of unexpected failing tests with output similar to this:

```
 [signal: killed]
            FAIL: testscripts/myecho.txt:1: unexpected command failure
```

On CI builds the workaround has been to downgrade to a builder with MacOS <= 11 (e.g. macos-11 on GitHub).

In development on a MacBook, this is not an option.

This commit works around what seem to be a upstream bug in `os.Link` by adding a small sleep before `TestingM.Run()` to allow the write of the test
command symlinks to be ready.

See rogpeppe#200
  • Loading branch information
bep committed May 3, 2023
1 parent 22b9127 commit f6df25d
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions testscript/exe.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"path/filepath"
"runtime"
"strings"
"time"
)

// TestingM is implemented by *testing.M. It's defined as an interface
Expand Down Expand Up @@ -97,6 +98,14 @@ func RunMain(m TestingM, commands map[string]func() int) (exitCode int) {
ts.cmdExec(neg, append([]string{name}, args...))
}
}

if runtime.GOOS == "darwin" {
// There seem to be an issue with os.Link on newer versions of macOS.
// Wait a little to make sure the test binaries are ready.
// See issue #200.
time.Sleep(200 * time.Millisecond)
}

return m.Run()
}
// The command being registered is being invoked, so run it, then exit.
Expand Down

0 comments on commit f6df25d

Please sign in to comment.