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 7ff90d9
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 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,13 @@ func RunMain(m TestingM, commands map[string]func() int) (exitCode int) {
ts.cmdExec(neg, append([]string{name}, args...))
}
}

if runtime.GOOS == "darwin" {
// Make sure all of the io operations above gets some time to complete.
// 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 7ff90d9

Please sign in to comment.